Skip to content

The-TONE-Knows-Inc/Tone-iOS-Framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tone Framework

A Swift package for working with AudioKit and allows to perceive and filter tones (frequencies)

Requirements

  • Swift 5.3+
  • IOS 13+

Usage


import ToneListen

// Instance tone framework by passing client ID
let toneFramework = ToneFramework(clientID: {{ Your client ID }})

//Start listen service:
toneFramework.start()

//To stop service:
toneFramework.stop()

//If you need to be notified when a valid tone was caught, you will need to subscribe to 'notificationName' from NotificationHandler:

// By publishing this property we can ensure that our subscriber (notificationName) will be
// re-rendered when the property changes (i.e. whenever there's a new notification)
@Published var newNotification: String? {
    didSet {
        guard notifiedValue != nil else { return }            
    }
}

notificationSub = NotificationCenter.default.publisher(for: NotificationsHandler.notificationName)
            .map { notification in notification.object as? String }   // Transform the notification into a simple string
            .assign(to: \notifiedValue, on: self)  // Assign the msg to a property using a keypath

// 'notifiedValue' saves an URL or PhoneNumber (string), depending what tone was caught. 

NOTE:

You need to add "Background modes" capabilites to your project to allow using microphone and location services in background.

Also you need to add "frequencies_table.json" file to your project.

Installation

Swift Package Manager

Add the ToneLibrary package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(
        url: "https://github.com/Anilkumar18/ToneLibrary-iOS.git",
        from: "TonelibraryV2"
    ),
  ]
)

Or you can add the ToneLibrary package to your PROJECT package dependencies by following the steps below,

1. Click on (+) at the left bottom.

Screenshot 2024-03-06 at 1 42 13 PM

2. Add the package url "https://github.com/Anilkumar18/ToneLibrary-iOS.git" into the package URL.

3. Select the "Exact version" - 8.0.3.

Screenshot 2024-03-06 at 2 10 19 PM

4. Click on Add package button.

Screenshot 2024-03-06 at 2 12 52 PM

5. The package now gets installed to your project.