Search code examples
cocoaaudioqtkit

How to perform audio file analysis with Cocoa?


my aim is to perform analysis (like DFT) on an audio file (mp3).
Then :

  • my input is a file
  • And my output is a treatment

I would like to use QTKit framework to perform this, but I am a bit disappointed:

  • QTMovie is able to open a file but I don't see own to access to decompressed audio buffer
  • QTSampleBuffer can be treat with QTCaptureDecompressedAudioOutput but I don't find how to open a file (the only input seems to be QTCaptureDeviceInput)

Is there a way to do what I want with QTKit or should I use Core Audio (or other) which will be more difficult (and I prefer Objective-C than C or C++) ?

(Actually I have no code, I am just trying to find the good way and it the first time I use sound...)


Solution

  • QTKit won't let you do that. You'll have to use Core Audio. You could always take a look at this code (which is written for the iPhone but most of the code works on Mac OS X) to understand everything a bit more. It detects frequency using FFT.

    I also was afraid of using Core Audio, but in the end it all worked out pretty well.