Click here to Skip to main content
15,799,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I get samples through audio files and in using library NAudio so and put it in a matrix and whether we get the samples so as to be of type double, and how?

NAudio.Wave.WaveChannel32 wave =  new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(openFileDialog1.FileName));

Int32 x = Convert.ToInt32(wave.Length);
byte[] buffer = new byte[wave.Length];
float[] data = new float[wave.Length / 4];
int read = wave.Read(buffer, 0, x);

for (int i = 0; i < read / 4; i++)
    data[i] = BitConverter.ToSingle(buffer, i * 4)

This program that returns the value multiplied by 4 means the repeat samples so that if I have a 1000 sample due 4000 and that the entry be Mono means one channel, what do you advise.

i want to get the sample if it mono i will take mono or stereo i will take stereo .the problem of this program return the sample 32 bit as it mono or stereo what is the result u think ??


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900