Installing kAudioSessionMode in the Apple SpeakHere example causes a significant reduction in volume. Any workarounds?

I had a problem with too low sound in my own application anytime I use VoiceChat mode, as an idiot check I downloaded an Apple code sample for programming Audio Unit (SpeakHere) and added VoiceChat mode for this application. As it turns out, the problem also arises: starting in this mode leads to the fact that everything will be about 20% of the required volume.

I added this code on line 267 of SpeakHereController.mm, right after the PlayAndRecord category is set:

// set mode -- this results in audio being too soft UInt32 mode = kAudioSessionMode_VoiceChat; error = AudioSessionSetProperty(kAudioSessionProperty_Mode, sizeof(mode), &mode); if (error) printf("couldn't set audio session mode!"); 

I use VoiceChat mode with RemoteIO to get echo cancellation for handsfree use; VoiceProcessingIO works (sort of), but the performance on older iPhones (3GS) is so poor that it is unusable - so I use RemoteIO instead. I confirmed the speaker route is correct. I even tried to set the measurement mode and manually increase the gain - I can’t detect any improvement.

Any suggestions for preventing large dropouts when using AudioSession modes?

+4
source share
1 answer

It turns out that route / current / audio is used when VoiceChat mode is set to determine the best settings for gain, echo cancellation, etc. This means that if you are going to set a specific route, you need to do this before setting the mode - not after.

By doing this in this order, I fixed the volume issue:

  • set PlayAndRecord
  • set the route to the speaker
  • set mode
  • use VoiceProcessingIO in my audio devices
  • maintain a low sampling rate (8k) to maintain good performance on older devices such as 3GS
+1
source

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


All Articles