Why does AudioKit AKMicrophoneTracker not work on a physical iOS device?

When I use AudioKit AKMicrophoneTracker on a physical device, the frequency and amplitude are always 0 . But on the playground and in the iOS simulator, it works great.

Here is an 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 have reset the rights to the physical device to ensure privacy, and iOS correctly tells me to allow access to microphones. It still does not work, although I allow access to microphones.

How can I make AKMicrophoneTracker really read these values?

I am using AudioKit 4.0.3. It works as expected when using:

  • AudioKit Playground on my Mac
  • iPhone 7 Plus simulator running iOS 11.1

This does not work when using:

  • The physical iPhone 7 Plus runs on iOS 11.1.1 (and also runs on iOS 11.1)

I originally posted this as a bug in TrackKout for the AudioKit audio track . However, Aure (a proponent of the project) suggested I post here.

+5
source share
2 answers

Ercell0's answer is correct - its code works fine. My specific problem seems to have been caused by some other AudioKit features that I thought were disabled during testing. This was tantamount to running:

 AudioKit.output = AKMixer() AudioKit.start() 

after initializing AKMicrophoneTracker . This caused the AKMicrophoneTracker problem that I encountered.

Sounds like this might be a bug in AudioKit. I opened question number 1142 on Github.

0
source

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> ... 

enter image description here

+6
source

Source: https://habr.com/ru/post/1273537/


All Articles