How To put Audio song in NSdata In iphone - iphone

I want to hold ipod Library song in NSData to send on Webservice.
how i can get that song in NSdata

You can't do that unfortunately (at least without doing something 'illegal'). Apple has iPod Library access API: http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/iPodLibraryAccess_Guide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008765
However these only allow you to pick songs, read meta data, tell ipod to play songs... not much else

Related

Copying music files of iphone library in my app

I want to copy the music files of iphone ipod library using MPMediaPicker. Actually using MPMediaPicker I am able to get the path of ipod music library but when I convert music file at url in NSData, the result is null. I doubt that is it possible to get the music file from ipod library. I am not sure as there is no exception or warning while I am trying to convert url item in NSData using [NSData datawithContentOfUrl:ipod-library-path].
If someone has any idea about this or any alternative to copy music files.
Your are getting Asset URLof music files.So it need to be converted into NSData to write into iphone library.
Refer Get video NSData from ALAsset url iOS link.
Now write data into iphone library.

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.

Are all iphone songs DRM protected while on the phone? AVAssetExportSession cannot find audio

When a song gets placed into itunes and then synced to iphone does it automatically put DRM on it?
I'm trying to copy an mp3 I wrote into a unity3d game on the iphone and play it and use it to make a video of the game.
This fails:
I wrote a song it does not have DRM. I dropped it into itunes and sync up the phone.
I then use an iphone plugin for unity3d that copies it from from the iphone music library to a directory in the game. I can then play the song and create a video of the game with the song. Playing the song works fine. But when I try to access the data using AVAssetExportSession to create the video it cannot find the audio tracks of the mp3.
This succeeds:
But if I paste the song directly into the game directory by dragging it from itunes into the game library it has no problem with the song or finding the audio tracks and creating the video.
Can anyone explain why this is failing. Is it a DRM issue?
Thanks,
To answer the question in the title directly: No, all songs are not automagically DRM protected while on the iPhone.
That being said, you do need to jump through a few hoops if you want to get the song data, and AVAssetExportSession is a good way to do that.
The problem you are having really doesn't sound like a DRM issue. It sounds like a path/URL problem for the audio file. Some example code would help to better answer the other parts of your question.

iPhone Music Library Access

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.

Can audio files be saved like photos and movies in iphone using objective C?

If our iphone application uses the inbuilt camera to click any picture, for saving the image into iPhone's photo library, we use UIImageWriteToSavedPhotosAlbum method. Likewise, to store any video recording into the iPhone, we use UISaveVideoAtPathToSavedPhotosAlbum
Is there any method to save any audio file into iPhone's Sounds library akin to both the methods mentioned above?
There is no way to import audio into the iPod application from the phone. iTunes (on the computer) is currently the only way. You do have a few options to save the file though
1) Create a movie on your own with just the audio
2) save it to disk locally (in the documents directory) and provide a way to get it off the phone (such as CocoaHTTPServer)
3) Email it.
4) Upload to a server