예제 #1
0
        /// <summary>
        /// Process samples from byte array
        /// We process only one channel
        /// </summary>
        /// <param name="SampleData"></param>
        public short[] ConvertToShortArray(WavFormat Format, byte[] SampleData)
        {
            int Increment = Format.Channels * Format.BitsPerSample / 8;

            short[] Result = new short[(SampleData.Length + Increment - 1) / Increment];

            if (Format.BitsPerSample == 8)
            {
                for (int i = 0; i < Result.Length; i++)
                {
                    Result[i] = SampleData[i * Increment];
                }
            }
            else             // if 16
            {
                for (int i = 0; i < Result.Length; i++)
                {
                    Result[i] = (short)((SampleData[i * Increment + 1] << 8) + SampleData[i * Increment]);
                }
            }

            return(Result);
        }
예제 #2
0
 public WavStream(WavFormat Format, int InitStreamSize = 4096)
 {
     this.Format = Format;
     Stream      = new MemoryStream(InitStreamSize);
 }