I want to do something like beat slicing.
I can set up a timer to get the AudioQueueLevelMeterState periodically.
However, there doesn’t seem to be a way to relate the time that the AudioQueueLevelMeterState is queried with the contents of the AudioQueueBuffer?
For example, let’s say that my buffer is 1 second long. I run a timer that queries the meter state 60 times per second. At 0.5 seconds I get the level I want. Consequently, I want to take a chunk of that audio buffer from the point I get the level onwards, i.e. the remaining 0.5 seconds.
Any ideas? Any ways to do it all in the buffer so to speak?
Any advice much appreciated.
Many thanks, xj
Got this sorted eventually. I ditched AudioQueue as a way to record the audio and instead went for an AudioUnit. AudioQueue was so difficult that eventually I had to seriously question if it was the correct API to use for what I wanted to do. In some forums people had said that AudioUnits were hard to work with, but to be honest after everything I’d been through with AudioQueue, AudioUnit was pretty straightforward.
Anyway, to answer my own question. Eventually I had to resolve synchronisation issues with the metering and recording, so I ditched the timer mechanism to sample the levels. I still use AudioQueue but just for the metering. In the recording callback I grab the
kAudioQueueProperty_CurrentLevelMeterfrom the AudioQueue. The recording callback receives the frame count, so that way I can perfectly synchronise the frame position with the meter sample.