private void MixS16_Stereo_NoLoop(float[] buffer, int numSamples, float leftVol, float rightVol) { float interStep = _freq * SoundMixer.SampleRateReciprocal; int bufPos = 0; do { if (CheckPause && IsPaused) { return; } Data.Stream.Position = _offset; int sampL = Data.Reader.ReadInt16(); int sampR = Data.Reader.ReadInt16(); _interPos += interStep; int posDelta = (int)_interPos; _interPos -= posDelta; posDelta *= sizeof(short) * 2; _offset += posDelta; buffer[bufPos] += SoundMixer.S16ToF32(sampL, leftVol); buffer[bufPos + 1] += SoundMixer.S16ToF32(sampR, rightVol); if (_offset >= Data.DataEnd) { SoundMixer.StopChannel(this); return; } bufPos += 2; } while (--numSamples > 0); }
private void MixS16_Mono_Loop(float[] buffer, int numSamples, float leftVol, float rightVol) { float interStep = _freq * SoundMixer.SampleRateReciprocal; int bufPos = 0; do { if (CheckPause && IsPaused) { return; } Data.Stream.Position = _offset; int samp = Data.Reader.ReadInt16(); _interPos += interStep; int posDelta = (int)_interPos; _interPos -= posDelta; posDelta *= sizeof(short); _offset += posDelta; // Add trail if (_trailOffset < Data.DataEnd) { Data.Stream.Position = _trailOffset; samp += Data.Reader.ReadInt16(); _trailOffset += posDelta; } buffer[bufPos] += SoundMixer.S16ToF32(samp, leftVol); buffer[bufPos + 1] += SoundMixer.S16ToF32(samp, rightVol); if (_offset >= Data.LoopEnd) { _offset = Data.LoopStart; _trailOffset = Data.LoopEnd; } bufPos += 2; } while (--numSamples > 0); }