Posts

Posts mit dem Label "CoreAudio" werden angezeigt.

Swift 2, AudioConverter, Callback and Core Audio

Currently I am working on bcAnalyze 3 - our sound analysis tool. I decided to write it in Swift to learn the new language. While most of my doings went well resulting in a first bcAnalyze 3 light version... i hit a wall when starting on AudioConverters and a callback function completely written in Swift. While with some help I managed to define a callback , the AudioConverter didn't run but threw an error when calling it via AudioConverterFillComplexBuffer. After some digging I realized that the AudioBufferList supplied to the callback function was loosing its filled in values. After some days struggling I managed to get it running - I need only samplerate conversions, so, running to do that at least. How to get it running? I supplied a struct as user info in the callback. The struct holds a pointer to the sound data as well as the AudiobufferList... but I'll best show the code: struct audioIO {     var pos: UInt32 = 0     var srcBuffer: Array ...

De-interleaved stereo and AudioBuffers

For the version 2 of bcAnalyze I am digging much deeper into CoreAudio to be able to do some of the things I have planned. The first that bcAnalyze does when it encounters an AudioFile is reading its data into an internal SInt16 buffer. ExtAudioFileRead works well for that if the file format is wav, mp3, aiff or one of the other known formats. While version 1 of bcAnalyze asks the user which channel to read, I decided to overcome this limitation. Still, the UI should only display and work with one channel, but the user should be able to switch between left/right for display and such. Simple solution, tell ExtAudioFileRead to read the stereo data into two buffers, one for each channel. Setting the proper client format was simple. For my purpose the internal format / client formatFlag is set: clientFormat.mFormatFlags = (!kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagIsNonInterleaved); Then, whenever I tried to read a stereo fi...