Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording output audio with Swift

Tags:

ios

swift

audio

Is it possible to record output audio in an app using Swift? So, for example, say I'm listening to a podcast, and I want to, within a separate app, record a small segment of the podcast's audio. Is there any way to do that?

I've looked around but have only been able to find information on recording microphone recording and such.

like image 265
Alex Coleman Avatar asked Jan 07 '15 20:01

Alex Coleman


People also ask

How do I record audio with Avaudiorecorder?

First you need to import the AVFoundation framework into your view controller. You will need to add three properties to your view controller: a button for the user to tap to start or stop recording, an audio session to manage recording, and an audio recorder to handle the actual reading and saving of data.


1 Answers

It depends on how you are producing the audio. If the production of the audio is within your control, you can put a tap on the output and record to a file as it plays. The easiest way is with the new AVAudioEngine feature (there are other ways, but AVAudioEngine is basically an easy front end for them).

Of course, if the real problem is to take a copy of a podcast, then obviously all you have to do is download the podcast as opposed to listening to it. Similarly, you could buffer and save streaming audio to a file. There are many apps that do this. But this is not because the device's output is being hijacked; it is, again, because we have control of the sound data itself.

like image 113
matt Avatar answered Sep 21 '22 04:09

matt