title: NAudio Asio and IeeeFloat format
body: <p>i have tried to get the <a href="http://mark-dot-net.blogspot.com/2009/10/playback-of-sine-wave-in-naudio.html" rel="nofollow">sine wave example</a> running on an AsioOut, but it sounds more like a distorted square wave. is it possible that the AsioOut only supports PCM formats? the asio .wav file playback works just fine...</p>
  
  <p>If so, how can i fill my buffers with Ieee floats and convert to PCM? or whats the best way to palyback Ieee on ASIO? i would love to avoid unnecessary sample conversions..</p>
  
  <p>in my code so far, i have tried to generate a sine wave which fits the buffer size, to make sure that i have continuous values, i initialize it with sample rate 44100 and 1 channel. then i pass an instance of the class to the Init() of my AsioOut:</p>
  
  <pre><code>public class SineWaveProvider32 : IWaveProvider
  {
      private WaveFormat waveFormat;
      public WaveFormat WaveFormat
      {
          get
          {
              return this.waveFormat;
          }
      }
  
      public SineWaveProvider32() : this(44100, 1)
      {
      }
  
      public SineWaveProvider32(int sampleRate, int channels)
      {
          this.SetWaveFormat(sampleRate, channels);
      }
  
      public void SetWaveFormat(int sampleRate, int channels)
      {
          this.waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channels);
      }
  
              public unsafe int Read(byte[] buffer, int offset, int count)
      {
          var samples = count/4;
          fixed(byte* buff = buffer)
          {
              for (int n = 0; n &lt; samples; n++)
              {
                  var num = (float)(Math.Sin( (2 * Math.PI * n)/ samples ));
                  ((float*)buff)[n] = num;
              }
          }
  
          return count;
      }
  }
  </code></pre>