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

ConvertLatencyToByteSize() public method

Gets the size of a wave buffer equivalent to the latency in milliseconds.
public ConvertLatencyToByteSize ( int milliseconds ) : int
milliseconds int The milliseconds.
return int
        public int ConvertLatencyToByteSize(int milliseconds)
        {
            int bytes = (int) ((AverageBytesPerSecond/1000.0)*milliseconds);
            if ((bytes%BlockAlign) != 0)
            {
                // Return the upper BlockAligned
                bytes = bytes + BlockAlign - (bytes % BlockAlign);
            }
            return bytes;
        }

Usage Example

Beispiel #1
0
        public WaveData(double seconds)
        {
            var length = Format.ConvertLatencyToByteSize((int)(seconds * 1000));

            Samples   = new short[length / BytesPerSample];
            ByteArray = new byte[length];
        }