NScumm.Core.Audio.PCSpeakerDriver.Output C# (CSharp) Method

Output() private method

private Output ( ushort output ) : void
output ushort
return void
        void Output(ushort output)
        {
            byte v1 = (byte)((output >> 7) & 0xFF);
            byte v2 = (byte)((output >> 2) & 0x1E);

            byte shift = _outputTable1[v1];
            var indexBase = _outputTable2[v1] << 5;
            var frequency = _frequencyTable[(indexBase + v2) / 2] >> shift;

            // Only output in case the active channel changed or the frequency changed.
            // This is not faithful to the original. Since our timings differ we would
            // get distorted sound otherwise though.
            if (_lastActiveChannel != _activeChannel || _lastActiveOut != output)
            {
                _pcSpk.Play(WaveForm.Square, 1193180 / frequency, -1);
                _lastActiveChannel = _activeChannel;
                _lastActiveOut = output;
            }
        }