Record audio iOS
Asked Answered
U

4

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.

Undertrump answered 29/2, 2012 at 5:22 Comment(4)
How do you play the audio within your app?Metagalaxy
I will be using audio units. Will the recorder itself be a unit?Undertrump
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.Fuss
@Fuss - 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.Undertrump
R
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);
Rosenstein answered 27/6, 2012 at 1:51 Comment(0)
V
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++

Vitalis answered 1/11, 2012 at 8:57 Comment(2)
Do you think it is also possible for recording audio from other apps? Can you record pure audio that for example Spotify is producing?Tannatannage
@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.Vitalis
W
1

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

Wilkens answered 29/2, 2012 at 15:37 Comment(0)
A
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.

Astraddle answered 28/6, 2012 at 18:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.