Example #1
0
        public AudioSample(string fileName)
        {
            _fileName = fileName;
            WaveFileReader reader = new WaveFileReader(fileName);

            //offsetStream = new WaveOffsetStream(reader);
            //channelStream = new WaveChannel32(offsetStream);
            channelStream = new WaveChannel32(reader);
            muted         = false;
            volume        = 1.0f;


            // Reverse the sample
            NAudioBufferReverse nbr = new NAudioBufferReverse();

            // Setup a byte array which will store the reversed sample, ready for playback
            reversedSample = new byte[(int)channelStream.Length];

            // Read the channelStream sample in to the reversedSample byte array
            channelStream.Read(reversedSample, 0, (int)channelStream.Length);

            // Calculate how many bytes are used per sample, whole samples are swaped in
            // positioning by the reverse class
            bytesPerSample = (channelStream.WaveFormat.BitsPerSample / 8) * channelStream.WaveFormat.Channels;

            // Pass in the byte array storing a copy of the sample, and save back to the
            // reversedSample byte array
            reversedSample = nbr.reverseSample(reversedSample, (int)channelStream.Length, bytesPerSample);
        }
Example #2
0
        public AudioSample(string fileName)
        {
            _fileName = fileName;
            WaveFileReader reader = new WaveFileReader(fileName);
            //offsetStream = new WaveOffsetStream(reader);
            //channelStream = new WaveChannel32(offsetStream);
            channelStream = new WaveChannel32(reader);
            muted = false;
            volume = 1.0f;



            #region ReverseStuff

            //Code to reverse
            NAudioBufferReverse nbr = new NAudioBufferReverse();
            reversedSample = new byte[(int)channelStream.Length];
            channelStream.Read(reversedSample, 0, (int)channelStream.Length);
            bytesPerSample = (channelStream.WaveFormat.BitsPerSample / 8) * channelStream.WaveFormat.Channels;
            reversedSample = nbr.reverseSample(reversedSample, (int)channelStream.Length, bytesPerSample);

            #endregion


        }