Use same audio engine for player and recorder in IOS
Is your feature request related to a problem? Please describe. When I use flutter sound player and recorder for real time communication through server in IOS, the sound gets played through built-in-receiver, not built-in-speaker. I configured audio session initially like this, but it is same.
await Permission.microphone.request();
final session = await AudioSession.instance;
await session.configure(AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions.allowBluetooth | AVAudioSessionCategoryOptions.defaultToSpeaker,
avAudioSessionMode: AVAudioSessionMode.voiceChat,
avAudioSessionRouteSharingPolicy:
AVAudioSessionRouteSharingPolicy.defaultPolicy,
avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none,
androidAudioAttributes: const AndroidAudioAttributes(
contentType: AndroidAudioContentType.speech,
flags: AndroidAudioFlags.none,
usage: AndroidAudioUsage.voiceCommunication,
),
androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
androidWillPauseWhenDucked: true,
));
await AVAudioSession().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker);
await session.setActive(true);
await _recorder.openRecorder();
await _player.openPlayer();
Describe the solution you'd like To solve this problem, player and recorder have to use same audio engine in IOS and setVoiceProcessingEnabled as true of AVAudioInputNode as true before recording
let inputNode: AVAudioInputNode
try inputNode.setVoiceProcessingEnabled(true)
Describe alternatives you've considered I don't the native code of flutter_sound, but it seems like player and recorder does not use same audio engine in IOS. That might be why sound plays in receiver rather than speaker.
I'd like to suppose player and recorder use same audio engine in IOS and setVoiceProcessingEnabled as true before recording.
Additional context If there is solution to this problem, please let me know. Thanks : )
Actually Flutter Sound 9.x use the default mic and the default speaker. There is no possibility to select a specific mic and/or a specific speaker. This is really something missing in 9.x.
I am currently working on Flutter Sound 10.x, and it will be possible in this future version to select the speaker and the mic. Unfortunately this new release is far from being released. There is much work to do on this new version because everything is re-coded differently. I expect to release an alpha version at the end of the year or beginning of next year, but only for web. Port on mobiles and desktop will be later during 2025.
Then in 9.x, is there way to solve the problem that the sound is played through receiver rather than speaker when set to voiceChat mode?
Same here.
Port on mobiles and desktop will be later during 2025.
Do you have a update on this schedule? Is it still being worked on?
Yes. Sure, I am busy working on 10.0 But things are slow. Very very slow. This is a big problem for me to work at the same time on the Flutter Sound maintenance and new developments. I have too many things on my shoulders, and we desperately need at least another developer.
Actually I am busy working on Flutter Sound 9.x documentation and this is a big task, but a very important task. I am doing a major cleaning of this documentation.