3

I'm interested in using the Media Player framework on iPhone to access audio in the user's library. I want to be able to load a given audio file and then perform some specialised filtering on it.

Ideally I want to be able to directly load the audio file (or portion thereof for streaming) then use the audio converter services to perform decompression. Once I have the linear PCM data I want to perform some filtering on it before supplying the audio directly to an audio queue.

Is this possible on iPhone?

If so, can anyone tell me how I would access the audio file directly? Is it just a matter of using the "URL" to load it using NSFile (Presumably I obtain that through MPMediaItemPropertyAssetURL)? Or do I need to do something more complicated?

Cheers!

Goz
  • 61,365
  • 24
  • 124
  • 204

1 Answers1

2

The URL you get from MPMediaItemPropertyAssetURL is an Assets Library URL. You can use it to initialize an AVURLAsset. Then create an AVAssetReader with the asset and add to it an AVAssetReaderOutput (instances of AVAssetReaderAudioMixOutput or AVAssetReaderTrackOutput, depending on what you need). This latter object will finally give you access to the media data (-copyNextSampleBuffer).

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256