public AudioStreamModifier(ISampleProvider sample, double rateMult, int pitchDelta) { _sample = sample; WaveFormat = _sample.WaveFormat; _soundTouch = new SoundTouch<float, double>(); channelCount = sample.WaveFormat.Channels; _soundTouch.SetSampleRate(sample.WaveFormat.SampleRate); _soundTouch.SetChannels(channelCount); rateMult = (rateMult - 1) * 100; _soundTouch.SetTempoChange(rateMult); _soundTouch.SetPitchSemiTones(pitchDelta*0.25f); _soundTouch.SetRateChange(1.0f); _soundTouch.SetSetting(SettingId.UseQuickseek, 1); _soundTouch.SetSetting(SettingId.UseAntiAliasFilter, 1); _soundTouch.SetSetting(SettingId.SequenceDurationMs, 40); _soundTouch.SetSetting(SettingId.SeekwindowDurationMs, 15); _soundTouch.SetSetting(SettingId.OverlapDurationMs, 8); sourceReadBuffer = new float[(WaveFormat.SampleRate * channelCount * readDurationMilliseconds) / 1000]; soundTouchReadBuffer = new float[sourceReadBuffer.Length * 10]; // support down to 0.1 speed }