Re: SampleGrabber Buffer Sync to audio

On 19 Apr 2006 06:48:49 -0700, DiegoMol wrote:

OK, was really usefull to ask to the people of this group, thanks for
the quick and nice help.-

1.- i've done the code to run on VB, all is working
2.- i got the sample information from songs and i'm reading it.-
3.- all is workign in a nice way, and the result from each element on
the buffer array is between -32728 - +32728

actually my VU meter is working, and i'm using a formula to get the DB

decibels = 20 * Log10(channelvalue/ 32768.0)

i'm using ISampleGrabberCB.BufferCB setting teh callback or the
ISampleGrabber.GetCurrentBuffer as well, i actually have tested the
buffers from both sources
BUT!! how to sync the buffer with the audio that i'm listening?

playing 44100 stereo wav files of 16 bits i know that we have 176400
and reading as example 1764 samples each 10 ms.- is not sync at all.-

Yes, this is probably the trickiest part. You can get a little closer by
reducing the size of the buffers. The only highly accurate way is to know
the renderer's current play cursor position, but unfortunately you don't
have access to this in DirectShow. You could attach time stamps to each of
your VU meter samples and either render them as a image stream to a video
renderer or simply hold the rendering of the VU samples until the specified
reference time.