[mad-dev] Equaliser style effect.. i.e visualisation.

Rob Leslie rob@mars.org
Mon, 13 May 2002 13:11:13 -0700


On Monday, May 13, 2002, at 03:49  AM, Thomas Rathbone wrote:
> I'm using the high level API. Could I implement the bar drawing code in
> the filter callback or would this cause problems/delays with the
> decoding process? Otherwise how do I get at the frame structure?

Yes, you could draw during the filter callback. Whether this causes an 
unacceptable delay depends on how much time you take and how soon you need 
the decoded PCM in your output callback. In the case of 44100 Hz Layer III,
  each frame contains about 26 ms of audio (1152 samples), so as long as 
the total processing time per frame (including decoding/synthesis) is less 
than this, you should have no problem maintaining real time.

You may however want to think about synchronization issues. The data you 
get from the filter callback corresponds to samples which will not be 
heard until after they are passed to the audio subsystem in the output 
callback, and after they subsequently wait in the operating system's 
buffer before being played. You could probably devise a simple method to 
synchronize with the output callback, but further synchronizing with the 
audio subsystem depends a lot on your operating system and the available 
audio API.

You may also want to consider your visual frame rate. 26 ms per frame 
yields around 38 frames per second. If that's acceptable, you can proceed 
without complicating matters much further. If you want a higher frame rate,
  you may want to draw in a separate thread so you can smooth the data 
between audio frames.

   -rob