Example #1
0
        public AudioClip(System.IO.Stream stream, string file) : base(typeof(AudioClip))
        {
            audioData = new AudioFileReader(file);
            IWaveProvider sampler;

            Bps = audioData.WaveFormat.BitsPerSample;
            //read data to pointer
            SampleRate = audioData.WaveFormat.SampleRate;

            if (audioData.WaveFormat.BitsPerSample > 16)
            {
                sampler    = audioData.ToWaveProvider16();
                ByteBuffer = new byte[audioData.Length * audioData.WaveFormat.BitsPerSample / 16];
                sampler.Read(ByteBuffer, 0, ByteBuffer.Length);
                Bps = 16;
            }
            else
            {
                ByteBuffer = new byte[audioData.Length];
                audioData.Read(ByteBuffer, 0, ByteBuffer.Length);
            }
        }