iPhone Music Library Access - iphone

I would like to develop an application for iPhone that classifies the user's music according to user-defined genres. The application should be able to have access to iPhone's Music Library and work on the files, this is, fetching an mp3 file, apply some DSP ( like MFCC coefficients ) and then save the results on the file itself.
Is it possible to obtain a song as a file and work on it?

No. You have access to the music library database and can launch a music player to play a certain song but under the SDK you have neither access to the song files themselves nor to the actual PCM data of the music.
Also, access to the music library database on the device is strictly read-only, so you can't modify genres etc. if that was your plan.

I know this is not the answer you are looking for, but given that you can't access the music data from the iPhone, you might consider having a desktop app that accesses the user's music on their Mac/PC, and encodes something into the genre of the music there. Then you could write a music player app for the iPhone that can understand your genre descriptor and function accordingly. You could even go as far as having your iPhone app and desktop app communicate via WiFi to synch up data.

Related

Is it possible to access raw iphone audio output?

Is it possible access raw PCM data from the iphone audio output?
I know I can embed an MP3 and use AudioUnit. But if the user is playing music in the background from their itunes library, is it possible to access that audio data?
This is for an app that shows visual effects, which react to the music.
From what I can tell, it isn't possible, but that's just from lack of finding any information at all, rather than actual confirmation that it can't be done.
If it isn't possible to access the audio stream from the ipod, is it possible to access raw audio output from the Media Player inside an app, or is pretty much not permitted to access raw audio data from the itunes library at all?
EDIT: I found this question: iOS - Access output audio from background program, which say I can't access the audio from a background app. But is it possible to get the audio data from the itunes library if I play it inside the app?
I am busy coding something similar and as far as I know an AUGraph is needed, the hardware pulling from the recorder. You will have to get the URL of the MPMediaItem from the track the user selected with Apple's MPMediaPickerViewController. Then use the URL with Core-Audio. Core-Audio is a beast.
If your app is playing raw audio PCM samples, then your app has access to those samples. An app does not have access to the audio samples that another app (including the Music player) is playing via any public API.
An app can use AVAssetReader and Writer to convert mp3 files from the iTunes Library into raw audio (WAV) files.

How can I record currently playing audio on the 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.

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.

Post-processing on audio from the iPhone user's music library?

I want to apply post-processing to audio from an iPhone user's music library (i.e. the iPod app). This could happen in a number of ways:
Piping the media player's output through an Audio Unit.
Writing a custom audio output device, and having the media player send audio to it.
Getting direct access to the files in the user's music library.
Are any of these things possible? I know all of them would be on the desktop, but what about the iPhone?
I've written some sample code that does just this, which is based on some code from Chris Adamson.

How to access the mp3 stored in iPhone in iPhone SDK

How does one access an MP3 stored in iPhone iTune_controls directory? When i want to see the MP3 it is not visible for me in my applcation.
I'm not sure I understand your question correctly, but it sounds like you want to access an MP3 from your app that is in the iTunes (iPod?) area of the phone, is this correct?
If so then you can't directly access the file, since your app runs in an isolated sand-box.
If on the other hand you're wanting to play an MP3 that's part of your app then look in the iPhone Library - Audio Queue Services section.