I’m developing kind of a "midi"/audio sequencer for the iPhone that is playing back several sounds in a time-synced manner while simultaneously recording one sound. The playback part of it works fine.
The user is able to record sound (e.g vocals) on top of the playback and I’ve implemented a punch-in/punch-out capability for the recording. However, recordStart causes the playback to pause a short while before recommencing, throwing the timing out the window and confusing the user who wants to start singing. recordStop does the same thing, but the decrement to the user experience is less critical (as the recording is finished).
Upon processing recordStart the debug log provides a FMOD message saying that the audio route has changed from headphones to headphones and microphone.
recordStop gives the "opposite" message, saying that the audio route has changed from headphones/mic to headphones.
The iPhone headset/mic is plugged in the whole time, so the pause is not caused by the user unplugging/plugging anything.
Is there a way to switch off the pause?
thx & brgds
- oohmyygoood asked 9 years ago
When you start playback with FMOD, the application is operating in output only mode. When you start recording we need to change modes (or audio session categories to use the Apple lingo). When we change to the "recording and playing" mode, the device does some internal rerouting, it moves the output from the main speaker to the receiver speaker and starts accepting input from the microphone, during this time the OS stop asking for sound data (hence the pause).
It is possible we could allow you to put the device into the "playing and recording" mode at init time, then only activate the mic when you record start. I’ll need to evaluate this and check if it actually solves the pause for you though. I’ll get back to you when I have run some tests.
Ok I have had some time to examine the issue. Basically when recording starts as I said before some internal OS stuff happens that stops the OS requesting data from us for output.
To remove this gap in output playback I have added FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD to the iPhone extra driver data structure. This can be set via System::init which will put the device into recording from the start. This means when you start recording it will being immediately without gap. You may also want to make use of the "forceSpeakerOutput" flag in the iPhone extra driver data structure so output will go to the main speaker (when in play and record mode it will default to the receiver speaker).
The only caveat with this method is if you init as "record and play", and use the forceSpeakerOutput flag, when recording you may get echo because the mic is right near the base speakers. This is unavoidable because switching back to output via the receiver speaker will cause the very gap we are trying to fix. If you don’t use the forceSpeakerOutput flag then all output will be via the receiver speaker (if you are not using headphones) which may be acceptable for your application.
I will be adding this feature to our next dev release, which should be out by the end of the week.
Please login first to submit.