AudioSynthesis.Synthesis.Synthesizer.ConvertWorkingBuffer C# (CSharp) Method

ConvertWorkingBuffer() private method

private ConvertWorkingBuffer ( byte to, float from ) : void
to byte
from float
return void
        private void ConvertWorkingBuffer(byte[] to, float[] from)
        {
            if (littleEndian)
            {
                for (int x = 0, i = 0; x < from.Length; x++, i += 2)
                {
                    short sample = (short)SynthHelper.Clamp(from[x] * mainVolume * 32768f, -32768f, 32767f);
                    to[i] = (byte)sample;
                    to[i + 1] = (byte)(sample >> 8);
                }
            }
            else
            {
                for (int x = 0, i = 0; x < from.Length; x++, i += 2)
                {
                    short sample = (short)SynthHelper.Clamp(from[x] * mainVolume * 32768f, -32768f, 32767f);
                    to[i] = (byte)(sample >> 8);
                    to[i + 1] = (byte)sample;
                }
            }
        }
        #endregion