Пример #1
0
        public static List <float> GetSamples(string fileName)
        {
            var res = new List <float>();

            using (var ms = new WaveFileReader(fileName))
            {
                if (ms.WaveFormat.SampleRate != 8000 || ms.WaveFormat.Channels != 1 || ms.WaveFormat.BitsPerSample != 16)
                {
                    throw new FormatException();
                }
                for (int i = 0; i < ms.Length / 4; i++)
                {
                    float sample;
                    if (ms.TryReadFloat(out sample))
                    {
                        res.Add(sample);
                    }
                }
            }
            return(res);
        }