NAudio.Wave.WaveFormat.WaveFormat C# (CSharp) Method

WaveFormat() public method

Creates a new PCM format with the specified sample rate, bit depth and channels
public WaveFormat ( int rate, int bits, int channels ) : System
rate int
bits int
channels int
return System
        public WaveFormat(int rate, int bits, int channels)
        {
            if (channels < 1)
            {
                throw new ArgumentOutOfRangeException("Channels must be 1 or greater", "channels");
            }
            // minimum 16 bytes, sometimes 18 for PCM
            this.waveFormatTag = WaveFormatEncoding.Pcm;
            this.channels = (short)channels;
            this.sampleRate = rate;
            this.bitsPerSample = (short)bits;
            this.extraSize = 0;
                   
            this.blockAlign = (short)(channels * (bits / 8));
            this.averageBytesPerSecond = this.sampleRate * this.blockAlign;
        }

Same methods

WaveFormat::WaveFormat ( ) : System
WaveFormat::WaveFormat ( BinaryReader br ) : System
WaveFormat::WaveFormat ( int sampleRate, int channels ) : System