Creating samples display like Wavelab eg.

Sickboy <[email protected]>
Newsgroups gmane.comp.audio.mad.devel
Message-ID <[email protected]>
Hi guys,

i could need help in understanding displaying decoded mp3.
I decode the mp3 by the minimad example which works fine.

for (int i=0; i<(nsamples*4); i+=4)
         {
                 sample  = scale(*left_ch++);
                 *redux++ = (sample >> 0) & 0xff;
                 *redux++ = (sample >> 8) & 0xff;

                 if (nchannels == 2)
                 {
                                 sample = scale(*right_ch++);
                                 *redux++ = (sample >> 0) & 0xff;
                                 *redux++ = (sample >> 8) & 0xff;
                 }
         }

After that i got an unsigned char array which is in the little endian format.
Looks like this if i got an stereo file:

Left 1st byte, Left 2nd byte,    Right 1st byte, Right 2nd byte,   Left 1st 
byte, Left 2nd byte, ....

Please correct me if i'm wrong.


Now i try to display these datas in a waveform like in Wavelab, Soundforge, 
Audacity

It would be great if anyone could tell me how to calculate the peaks which 
i have to draw.


Thanks you
daSickboy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.