7

I'm trying to use AVAudioEngine to record sound from the microphone and sound files (which are played when the user taps a button). I have hooked up the mic inputNode to the mainMixer, as well as a couple of AVAudioPlayerNodes for playing sound files. I have installed a tap on the mainMixer to capture the sound and write it to a file. The sound is also routed to the speaker.

This is the basic layout of my audio graph:

         -------------
mic  --> |           |
         | mainMixer | --> speaker
file --> |           |
         -------------
               |
              tap
        (writes to file)

By default the sound is played through the receiver/ear speaker and not the speaker at the bottom of the iPhone.

Unfortunately, this means that the sound output through the speaker is too low and hard to hear - I want the user to be able to hear the sound files as they are played back and recorded. So I would like the sound effects to be played through the bottom speaker.

If I change the audio session to use the bottom speaker for playback I get a feedback loop, since both the mic input and sounds played by the bottom speaker are picked up by the microphone again. (Curiously enough, this works on the iPad, where no feedback loop is created. The iPad doesn't have an ear speaker, of course, so on that device the sound is always heard through the main speaker.)

I have two questions:

  1. Is it possible to route only the sound files to the bottom speaker? I don't want to output the sound of the mic through any of the speakers. Both the sound from the mic and the sound files should be recorded however.

  2. Why do I get a feedback loop on the iPhone but not on the iPad? Is it possible to output all sound through the bottom speaker without getting a feedback loop?

andlin
  • 3,534
  • 3
  • 25
  • 43

0 Answers0