3

On iOS, is it possible to get the user's audio stream in a decompressed format? For example, the MP3 is returned as a WAV that can be used for audio analysis? I'm relatively new to the iOS platform, and I remember seeing that this wasn't possible in older iOS versions. I read that iOS 4 brought in some advanced APIs but I'm not sure where I can find documentations/samples for these.

DShah
  • 9,768
  • 11
  • 71
  • 127
Skoder
  • 3,983
  • 11
  • 46
  • 73
  • you mean that you want to convert the format of audio?? – DShah Aug 27 '11 at 17:00
  • Ultimately I want to be able to analyse the audio and to do this, I need the uncompressed audio stream. Conversion from a compressed format to an uncompressed would be the first step. – Skoder Aug 27 '11 at 18:22
  • What do you mean by "get the user's audio stream"? Intercept the audio the user is currently listening to? Access the user's iPod library and analyze audio in LPCM? or listen to the microphone? – jin Sep 04 '11 at 21:15
  • Any song within the user's library, but the actual decompressed stream so that they can be modified. – Skoder Sep 04 '11 at 23:24

3 Answers3

3

If you don't mind using API for iOS 4.1 and above, you could try using the AVAssetReader class and friends. In this similar question you have a full example on how to extract video frames. I would expect the same to work for audio, and the nice thing is that the reader deals with all the details of decompression. You can even do composition with AVComposition to merge several streams.

These classes are part of the AVFramework, which allows not only reading but also creating your own content.

Community
  • 1
  • 1
Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78
2

Apple has an OpenAL example at http://developer.apple.com/library/mac/#samplecode/OpenALExample/Introduction/Intro.html where Scene.m should interest you.

The Apple documentation has this picture where the Core Audio framework clearly shows that it gives you MP3 out. It also states that you can access audio units in a more radical way if you so need.

The same Core Audio document gives also some information about using MIDI if it may help you.

Edit: You're in luck today.

Community
  • 1
  • 1
Kheldar
  • 5,361
  • 3
  • 34
  • 63
1

In this example an audio file is loaded and fed into an AudioUnit graph. You could fairly easily write an AudioUnit of your own to put into this graph and which analyzes the PCM stream as you see fit. You can even do it in the callback function, although that's probably not a good idea because callbacks are encouraged to be as simple as possible.

richardolsson
  • 4,041
  • 1
  • 17
  • 19