iOSでAudioKitを利用して音を入力する機能を実装する際、本体とイヤホンのマイクを考慮する必要がある。
本体とマイクとでは、サンプルレートが異なることがあり、本体は44.1kHz、iPhone同梱のLightningイヤホンは48kHzとなる。
抜き差しは、AVAudioSessionRouteChangeNotificationを利用するのではなく、AVAudioEngineConfigurationChangeNotificationをトリガーにして、AKMicrophoneを再インスタンス化しつなげ直し、AVAudioEngineを再開させる(AKManager.engine.start())。
また、AudioKitがAVAudioEngineConfigurationChangeNotificationをハンドリングしているので、事前に無効にしておく (AKSettings.enableCategoryChangeHandling = false)。
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme