How can I record currently playing audio on the iPhone? - iphone

I'd like to record what the iPhone is currently outputting. So I'm thinking about recording audio from Apps like Music (iPod), Skype, any Radio Streaming App, Phone, Instacast... I don't want to record my own audio or the mic input.
Is there an official way to do this? How do I do it? It seems like AVAudioRecorder does not allow this, can somebody confirm?

Officially you can't. The audio stream belongs to the app playing it ,and iOS.
The Sandbox paradigm means that a resource owned by your App can't be used by another App. Resource here means Audio/Video stream or file. Exceptions are when a mediator like Document interaction controller are used.
If you want to do this you'd have to start with deducing AVFoundation's private methods and find out if theres a way there. Needless to say this it wouldn't be saleable on the App store and will probably only be possible on a jailbreak.
Good Luck.

TLDR;
This is only feasible only from time to time, as it's a time expensive process.
You can record the screen while listening your songs on Spotify, Music or whatever music application.
This will generate a video on your Photos application. That video can be converted on MP3 from your computer.

Actually, this is not true. The screen recordings will not actually have the audio from Apple Music at all, as it blocks it. Discord also uses this pipe as well, so you cannot record Discord audio either this way.

Related

Multipeer Connectivity audio streaming stop work on background

I'm doing some audio streaming with iOS 7's Multipeer Connectivity framework. The streaming works well, but when I put the app on background it stops working.
Someone can tell me if this is a framework limitation, or I'm doing something wrong?
And, if it is a framework limitation, is it possible to do something to avoid this?
Can I use Background Tasks, to keep streaming and music working on background?
Is possible do this? If is not possible, do any alternatives exist for MultiPeer audio streaming between iOS devices?.
I´m using this example: https://github.com/tonyd256/TDAudioStreamer.
Explained on this page: http://robots.thoughtbot.com/streaming-audio-to-multiple-listeners-via-ios-multipeer-connectivity.
Thanks a lot!
On the Apple documentation for playing audio in the background (scroll down a bit). Some relevant paragraphs:
When the UIBackgroundModes key contains the audio value, the system’s media frameworks automatically prevent the corresponding app from being suspended when it moves to the background. As long as it is playing audio or video content or recording audio content, the app continues to run in the background. However, if recording or playback stops, the system suspends the app.
You can use any of the system audio frameworks to work with background audio content, and the process for using those frameworks is unchanged.
This means that iOS should recognize that you're playing audio through Core Audio, and keep your app unsuspended, as long as you've correctly configured your app for playing audio in the background.
Because your app is not suspended while playing media files, callbacks operate normally while your app is in the background. In your callbacks, though, you should do only the work necessary to provide data for playback. For example, a streaming audio app would need to download the music stream data from its server and push the current audio samples out for playback. Apps should not perform any extraneous tasks that are unrelated to playback.
You should be able to operate normally as long as your app is still playing audio, and is allowed to do what it needs to in order to continue playing audio. This means that you should be able to continue to use MPC in the background to receive the audio data and play it.
Be sure to read the entire documentation on the subject, especially regarding Audio Sessions.
iOS devices get limited cpu cycles for explicit purposes when they have been backgrounded by the user.
According to Apple's documentation on multitasking and execution in the background, the following types of apps are supported, but have to be explicitly declared:
Apps that play audible content to the user while in the background, such as a music player app
Apps that record audio content while in the background.
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Apps that need to download and process new content regularly
Apps that receive regular updates from external accessories
Your case falls under Apps that play audible content to the user while in the background, such as a music player app. You can find more information from the link provided above.

Recording from radio streaming xcode 4

I'm building an iPhone app which play some radio over internet ..
I want to make user able to record audio from my application to the radio channel he wants ..
what framework I must use .. and what code for implementation please ?
all Regards
Unfortunately, there is no way to directly capture from the "audio bus". You can either capture the audio via the internal microphone or headset microphone, but that's it. If you are rendering the audio, you could obviously also write that audio out to a file as well at the same time. That's pretty much your only option.

iPhone iOS5 what are my options for playing audio I do not have bundled in?

I currently have 3 ways to play audio within my app:
Using AudioServicesPlaySystemSound for vibration and simple
sounds
Using Audio Toolbox for bundled files (3rd party class)
Using AudioServices with AudioFX
What I'm currently investigating is, if I can play other kinds of audio that are already present on the iPhone. I would like to reduce my app's download size, as well as offer more flexibility in terms of the kind of sound that the user can play.
Can I play from within my app:
Audio recordings from the Voice Memos app, or do I have to
create my own recordings? Items from an iPod playlist or Music app?
Items from youtube by pre-loading them, or will I have to stream them every time?
Existing ringtone for the phone?
I am a complete beginner when it comes down to playing audio on an iPhone and am already using two 3rd party classes for audio tasks.
Is there an easy way to accomplish some of the tasks listed above?
1) Audio recordings from the Voice Memos app
It's been asked before and I don't believe it's possible from your app sandbox.
iPhone: Access voice memos programmatically
2) Items from an iPod playlist or Music app
There's an API for that, the iPod Access Library:
http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/iPodLibraryAccess_Guide/Introduction/Introduction.html
3) Items from youtube
Should be possible, using a UIWebView.
http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application
4) Existing ringtone for the phone
No, you can't access the current ringtone programatically.
How can I programmatically determine the default ringtone on an iPhone?
You can download sound files on first start (not in your didFinishLaunchingWithOptions method or your app will likely be killed) and save them locally, then you can just play them when needed. You can play files in their iTunes library, but won't know what they have in the library.
To play from their library, this is a handy example:
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-music-library-access/
You can also record user input from your app with AVAudioRecorder, save that and then play it whenever.

How to play the recorded sound in NSLocalNotifiaction

I implemented local notification in my app but I am just wondering is there a way to play a sound that is not part of the NSMainbundle.Basically in my app, I want user to record a sound that gets played when the local notification is generated instead of playing a pre-recorded sound. I have read out the Apple Documentation but i have also seen 2 -3 Apps on app store which is doing it like the this App link of the App i am wondering how the are playing custom sounds (sounds which are not the part of NSMainBundel)
Anyone has any idea how I can do it ?
Thank you in Advance
What you can do is to utilize the AVAudioRecorder and save its recordings to the documents directory of the iPhone.
After the recording is done, you can play the very same files using an AVAudioPlayer via the path of the recorded files.
HTH

Is it possible to both play a sound and record from the microphone at the same time on the iPhone?

I want to both play sound and record sound at the same time on the iPhone.
All the apps which record sound first disable any music playing. However as music would disrupt their purpose I don't know if they're doing this deliberately or whether the iPhone does it automatically when you record from the microphone.
Does anyone have experience with this?
Refer to this page. Good luck!
I've heard something about this on one episode of the mobile orchard podcast - the one with Michael Tyson, the creator of Loopy. During the discussion, Michael explained that he had to include some code to filter out the sounds that were coming in through the microphone in realtime as other sounds were being played on the speaker.
Based on that discussion, it seems entirely possible to both play and record at the same time, but I'm sure you'll have to do your own filtering to avoid recording the sounds your playing.
You can use either a core audio unit or an audio queue, and
you need to make sure that your audio session category is set to kAudioSessionCategory_PlayAndRecord.
Beware that sound output when you use this session is much quieter
than the normal solo session (observed on 3.0).