A Swift package for working with AudioKit and allows to perceive and filter tones (frequencies)
- Swift 5.3+
- IOS 13+
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.
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.
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,