SoundRecognition causes Input/Output callbacks to have varying Buffer sizes and introduces Glitching
Hello,
We have noticed an issue with SoundRecognition that causes glitching with our AudioUnit setup in Smule.
Input and output frame sizes are inconsistent.
Input frame size does not match [AVAudioSession sharedInstance].IOBufferDuration
My best guess is that SoundRecognition influences the input frame size and not the output frame size.
To reproduce use the example app here:
https://github.com/MarkoGill/SoundRecognitionBug
Hardware/OS
iPhone 14 Pro on iOS 18 -> Experiences the problem
iPhone 11 on iOS 18 -> Experiences the problem
iPhone 15 on iOS 18 -> Not experiencing the problem
Reproduction Steps
Enable Sound Recognition (Settings > Accessibility > Sound Recognition > On)
Enable a Sound for detection (Sounds > Dog > On)
Open the example app with headset (it routes input to output)
Notice glitching occurs
Check the logs. Record and Playback buffer sizes vary
Example Log:
AU input sample rate: 48000.000000
AU output sample rate: 48000.000000
hardware sample rate: 48000.000000
hardware buffer size: 1104.000000
updated record frame counts: 1024
updated playback frame counts: 1104
Notes:
You can disable Sound Recognition, restart the app, and playback behaves correctly.