12

How does one record audio using iOS? Not the input recording from the microphone, but I want to be able to capture/record the current playing audio within my app?

So, e.g. I start a recording session, and any sound that plays within my app only, I want to record it to a file?

I have done research on this but I am confused with what to use as it looks like mixing audio frameworks can cause problems?

I just want to be able to capture and save the audio playing within my application.

some_id
  • 29,466
  • 62
  • 182
  • 304
  • How do you play the audio within your app? – sbooth Feb 29 '12 at 23:10
  • I will be using audio units. Will the recorder itself be a unit? – some_id Jun 30 '12 at 17:54
  • just to clarify, when you say you want to record the sound playing within your app (not the microphone), you just mean you want to record directly off the sound card, correct? So, say if someone head headphones in they could still record whatever it is they would b hearing. – luca590 Jul 19 '13 at 06:33
  • @luca590 - Yeah exactly. The sound being handled by the app. This can be done by recording the audio in an audio unit callback asynchronously when handling the audio buffer(before or after processing) This way you can feed off of the audio unit that handles all the audio. – some_id Jul 19 '13 at 15:03

4 Answers4

5

Well if you're looking to just record the audio that YOUR app produces, then yes this is very much possible.

What isn't possible, is recording all audio that is output through the speaker. (EDIT: I just want to clarify that there is no way to record audio output produced by other applications. You can only record the audio samples that YOU produce).

If you want to record your app's audio output, you must use the remote io audio unit (http://atastypixel.com/blog/using-remoteio-audio-unit/).

All you would really need to do is copy the playback buffer after you fill it.

ex)

 memcpy(void *dest, ioData->mBuffers[0].mData, int amount_of_bytes);
Kpmurphy91
  • 554
  • 5
  • 15
2

This is possible by wrapping a Core Audio public utility file CAAudioUnitOutputCapturer http://developer.apple.com/library/mac/#samplecode/CoreAudioUtilityClasses/Introduction/Intro.html

See my reply in this question for the wrapper classes. Properly use Objective C++

Community
  • 1
  • 1
lppier
  • 1,927
  • 3
  • 24
  • 62
  • Do you think it is also possible for recording audio from other apps? Can you record pure audio that for example Spotify is producing? – Piotr Dabkowski Oct 29 '15 at 11:21
  • @PiotrDabkowski iOS does sandboxing, so the audio is probably native to the app itself. There are things like inter-app audio, for which, Spotify in your case has to support in order for you to be able to receive audio from it. – lppier Oct 30 '15 at 00:50
1

Check out the MixerHostAudio sample application from Apple. Its a great way to start learning about Audio Units. Once you have an grasp of that, there are many tutorials online that talk about adding recording.

Beleg
  • 362
  • 2
  • 23
1

There is no public API for capturing or recording all generic audio output from an iOS app.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153