Accord.Audio.Formats.WaveDecoder.Decode C# (CSharp) Method

Decode() public method

Decodes the Wave stream into a Signal object.
public Decode ( ) : Signal
return Accord.Audio.Signal
        public Signal Decode()
        {
            // Reads the entire stream into a signal
            return Decode(0, Frames);
        }

Same methods

WaveDecoder::Decode ( int frames ) : Signal
WaveDecoder::Decode ( int index, int frames ) : Signal

Usage Example

        /// <summary>
        /// Open the given audio file and return an "AudioSignal" with the following info:
        ///     1. data[]: array of audio samples
        ///     2. sample rate
        ///     3. signal length in milli sec
        /// </summary>
        /// <param name="filePath">audio file path</param>
        /// <returns>AudioSignal containing its data, sample rate and length in ms</returns>
        public static AudioSignal OpenAudioFile(string filePath)
        {
            WaveDecoder waveDecoder = new WaveDecoder(filePath);

            AudioSignal signal = new AudioSignal();

            signal.sampleRate = waveDecoder.SampleRate;
            signal.signalLengthInMilliSec = waveDecoder.Duration;
            Signal tempSignal = waveDecoder.Decode(waveDecoder.Frames);
            signal.data = new double[waveDecoder.Frames];
            tempSignal.CopyTo(signal.data);
            return signal;
        }
All Usage Examples Of Accord.Audio.Formats.WaveDecoder::Decode