How do I visualize audio data?

2020-02-25 23:36发布

I would like to have something that looks something like this. Two different colors are not nessesary.

audacity on mac
(source: sourceforge.net)

I already have the audio data (one sample/millisecond) from a stereo wav in two int arrays, one each for left and right channel. I have made a few attempts but they don't look anywhere near as clear as this, my attempts get to spikey or a compact lump.

Any good suggestions? I'm working in c# but psuedocode is ok.

Assume we have

  • a function DrawLine(color, x1, y1, x2, y2)
  • two int arrays with data right[] and left[] of lenght L
  • data values between 32767 and -32768

If you make any other assumptions just write them down in your answer.

for(i = 0; i < L - 1; i++) {
  // What magic goes here?
}

This is how it turned out when I applied the solution Han provided. (only one channel)
alt text http://www.imagechicken.com/uploads/1245877759099921200.jpg

0条回答
登录 后发表回答