I\'m trying to draw a waveform from a raw audio file. I demuxed/decoded an audio file using FFmpeg and I have those informations: samples buffer, the size of the samples buffer,
First, you need to determine where on the screen each sample will end up.
int x = x0 + sample_number * (xn - x0) / number_of_samples;
Now, for all samples with the same x
, determine the min and the max separately for positive and negative values. Draw a vertical line, a dark one from negative max to positive max, then a light one from negative min to positive min over the top of it.
Edit: thinking about this a little more, you probably want to use an average instead of the min for the inner lines.