Esempio n. 1
0
        private void ReadAudio(AudioFileReader stream)
        {
            // TODO: could add resampling in here if required
            WaveFormat = stream.WaveFormat;
            var wholeFile  = new List <float>((int)(stream.Length / 4));
            var readBuffer = new float[stream.WaveFormat.SampleRate * stream.WaveFormat.Channels];
            int samplesRead;

            while ((samplesRead = stream.Read(readBuffer, 0, readBuffer.Length)) > 0)
            {
                wholeFile.AddRange(readBuffer.Take(samplesRead));
            }
            AudioData = wholeFile.ToArray();
        }
Esempio n. 2
0
        public int Read(float[] buffer, int offset, int count)
        {
            if (isDisposed)
            {
                return(0);
            }
            int read = reader.Read(buffer, offset, count);

            if (read == 0)
            {
                reader.Dispose();
                isDisposed = true;
            }
            return(read);
        }