title: How to get float array of samples from audio file
body: <p>I’m developing a UWP application ( for Windows 10) which works with audio data. It receives samples buffer at the start in the form of a float array of samples, which items are changing from -1f to 1f.
  Earlier I used NAudio.dll 1.8.0 that gives all necessary functionality.
  Worked with WaveFileReader, waveBuffer.FloatBuffer, WaveFileWriter classes.
  However, when I finished this app and tried to build Release version, got this error:
  ILT0042: Arrays of pointer types are not currently supported: 'System.Int32*[]'.</p>
  <p>I’ve tried to solve it:</p>
  <ol>
  <li><a href="https://forums.xamarin.com/discussion/73169/uwp-10-build-fail-arrays-of-pointer-types-error" rel="nofollow noreferrer">https://forums.xamarin.com/discussion/73169/uwp-10-build-fail-arrays-of-pointer-types-error</a></li>
  </ol>
  <p>There is advice to remove the link to .dll, but I need it.</p>
  <ol start="2">
  <li><p>I’ve tried to install NAudio the same version using Manage NuGet Packages, but WaveFileReader, WaveFileWriter is not available.</p>
  </li>
  <li><p>In NAudio developer’s answer (<a href="https://stackoverflow.com/questions/39474257/how-to-store-a-wav-file-in-windows-10-with-naudio">How to store a .wav file in Windows 10 with NAudio</a>) I’ve read about using AudioGraph, but I can build float array of samples only in the realtime playback, but I need get the full samples to pack right after the audio file uploading. Example of getting samples during the recording process or playback:
  <a href="https://docs.microsoft.com/ru-ru/windows/uwp/audio-video-camera/audio-graphs" rel="nofollow noreferrer">https://docs.microsoft.com/ru-ru/windows/uwp/audio-video-camera/audio-graphs</a></p>
  </li>
  </ol>
  <p>That’s why I need help: how to get FloatBuffer for working with samples after audio file uploading? For example, for building audio waves or calculation for audio effects applying.</p>
  <p>Thank you in advance.</p>
  <hr />
  <ol start="2">
  <li><p>I’ve tried to use FileStream and BitConverter.ToSingle(), however, I had a different result compared to NAudio.
  In other words, I’m still looking for a solution.</p>
  <pre><code> private float[] GetBufferArray()
   {
       string _path = ApplicationData.Current.LocalFolder.Path.ToString() + &quot;/track_1.mp3&quot;;
       FileStream _stream = new FileStream(_path, FileMode.Open);
       BinaryReader _binaryReader = new BinaryReader(_stream);
       int _dataSize = _binaryReader.ReadInt32();
       byte[] _byteBuffer = _binaryReader.ReadBytes(_dataSize);
  
       int _sizeFloat = sizeof(float);
       float[] _floatBuffer = new float[_byteBuffer.Length / _sizeFloat];
       for (int i = 0, j = 0; i &lt; _byteBuffer.Length - _sizeFloat; i += _sizeFloat, j++)
       {
           _floatBuffer[j] = BitConverter.ToSingle(_byteBuffer, i);
       }
       return _floatBuffer;
   }
  </code></pre>
  </li>
  </ol>