Hi All,
I’m having a bit of trouble with something, and just wanted to see if anyone has had a similar issue and already worked around it (or has alternative suggestions).
I’ve got a demo working well with 3 modes:
- a click track with a tempo adjustment
- recording via the mic on top of the click track
- playing back the recorded audio.
On the iPhone when the headphones are unplugged all of the audio is routed through the earpiece speaker (and so is very quiet), but I’d like it to come out of the main speaker so they can hear it (it doesn’t matter if the click is recorded)
The structure is:
- The click track is a MIDI file played via AKSequencer (which is using AVAudioSequencer behind the scenes).
- I have an AKMixer which has the AKSequencer and an AKAudioPlayer (for playing back the recorded audio)
- Then there is a class based on Aure’s example that wraps AVAudioRecorder, but isn’t plugged into the output.
I have tweaked the AudioKit.start method to use:
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions:AVAudioSessionCategoryOptions.DefaultToSpeaker)
If I do this with headphones plugged in all is fine.
If I do this with the headphones unplugged then the AKSequencer / AVAudioSequencer doesn’t start and from then on it all goes a bit wrong.
Fwiw I’m not particularly wedded to using AKSequencer / AVAudioSequencer, but it seemed like an interesting thing to experiment with - so any tweaks or alternative suggestions on structure are gratefully received!
I’m just about to start adding and removing and debugging to see if I can work out how to make it work - but wanted to ask here, to see if I’m doing anything obviously wrong or anyone has any pointers or experience. I’ll report back if/when I manage to work around this issue so it can benefit someone in the future.
Thanks in advance,