3

I'd like to capture the audio (music + sound effects) coming from my iPhone game. AVCaptureSession seems to have only the microphone as audio source. I'd like to capture the audio, put it into CMSampleBufferRefs and append these to an AVAssetWriterInput.

I'm currently looking into Audio Queues. Any other ideas?

MrDatabase
  • 43,245
  • 41
  • 111
  • 153

1 Answers1

4

There is no API to directly capture all the sound effects and music from your game.

The most common solution is for an app to generate all sound twice, once for audio output, plus a second identical copy in the from of PCM samples to feed a DSP or Audio Unit mixer. Then feed the mixer output to AVAssetWriter or other file output. This technique is much easier to implement if all the sounds produced by your app are in the form of raw PCM audio played via Audio Queue or the RemoteIO Audio Unit API, which may require significant rewrites to your music and game sound code.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Interesting. Just out of curiosity could one capture the "audio data" before it's sent to the output hardware using RemoteIO Audio Unit API? – MrDatabase Oct 31 '11 at 19:57
  • 1
    MrDatabase - If your app is creating all the audio samples, it could write them to a file and never send them to RemoteIO. Or send them out to audio an hour later, etc. – hotpaw2 Oct 31 '11 at 20:04
  • The app has two forms of audio: compressed mp3 played by AVAudioPlayer and uncompressed wav played by a sound engine. – MrDatabase Oct 31 '11 at 20:07
  • 1
    An app would have to uncompress any compressed audio before it would be possible (currently, AFAIK) to mix or composite audio. There are (non-trivial to use) AVFoundation APIs to support doing so. – hotpaw2 Oct 31 '11 at 20:10