When I use AudioKit's AKMicrophoneTracker
on a physical device, the the frequency and amplitude are always both 0
. But in the playground and in the iOS simulator, it works perfectly.
Here's a rough example:
class AppDelegate: UIResponder, UIApplicationDelegate {
let tracker = AKMicrophoneTracker()
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// start the tracker and show frequency information
tracker.start()
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { _ in
print(tracker.frequency)
print(tracker.amplitude)
})
}
}
I've reset my physical device's privacy permissions, and iOS is correctly prompting me to allow microphone access. It still doesn't work even though I'm allowing microphone access.
How can I get AKMicrophoneTracker to actually read these values?
I'm using AudioKit 4.0.3. It works as expected when using:
It does not work when using:
I originally posted this as a bug on AudioKit's GitHub issue tracker. However, Aure (the project maintainer) encouraged me to post here instead.
The following worked for me on 7+, 6s:
In AppDelegate:
import UIKit
import AudioKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let tracker = AKMicrophoneTracker()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// start the tracker and show frequency information
tracker.start()
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: { _ in
print(self.tracker.frequency)
print(self.tracker.amplitude)
})
return true
}
...
info.plist
...
<key>NSMicrophoneUsageDescription</key>
<string>WE need your microfone to contact the aliens</string>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With