title: Analyzing wav and drawing a graph
body: <p>I'm trying to print out an wave from a wav file,
  but I'm kinda lost on how the length I should take for an sample.</p>
  
  <p>this is what I would love to archieve (without the colors):
  <img src="https://i.stack.imgur.com/GvLQV.png" alt="Music wav"></p>
  
  <p>so for reading in my data I use the following code:</p>
  
  <pre><code>// first we need to read our wav file, so we can get our info:
  byte[] wav = File.ReadAllBytes(filename);
  
  // then we are going to get our file's info
  info.NumChannnels = wav[22];
  info.SampleRate = bytesToInt(wav[24], wav[25]);
  
  // nr of samples is the length - the 44 bytes that where needed for the offset
  int samples = (wav.Length - 44) / 2;
  
  // if there are 2 channels, we need to devide the nr of sample in 2
  if (info.NumChannnels == 2) samples /= 2;
  
  // create the array
  leftChannel = new List&lt;float&gt;();
  if (info.NumChannnels == 2) rightChannel = new List&lt;float&gt;();
  else rightChannel = null;
  
  int pos = 44; // start of data chunk
  for (int i = 0; i &lt; samples; i++) {
      leftChannel.Add(bytesToFloat(wav[pos], wav[pos + 1]));
      pos += 2;
      if (info.NumChannnels == 2) {
          rightChannel.Add(bytesToFloat(wav[pos], wav[pos + 1]));
          pos += 2;
      }
  }
  </code></pre>
  
  <p>BytesToFloat = Converts 2 bytes to an float between -1 and 1</p>
  
  <p>So now I have 2 lists of data, but now how do I how many numbers I should take for creating 1 line? </p>
  
  <p>what confuses me the most:
  when you play a song, you can see in most music players the following data, this is in my eyes the representation of 1 sample.
  <img src="https://i.stack.imgur.com/OdrTY.png" alt="enter image description here"></p>
  
  <p>but how do you know the value of each of those bars, and how many bars there are in a sample</p>