private void UpdatePlaybackRate(float value) { if (value != 0) { soundTouch.SetTempo(value); soundTouch.SetPitchOctaves(value - 1); } }
public NAudionSoundComponent(ISampleProvider sourceProvider) { this.sourceProvider = sourceProvider; soundTouch = new SoundTouch(); // Settings soundTouch.SetRate(1.0f); soundTouch.SetPitchOctaves(playbackRate / 10); soundTouch.SetTempo(playbackRate); soundTouch.SetUseAntiAliasing(false); soundTouch.SetUseQuickSeek(false); soundTouch.SetSampleRate(WaveFormat.SampleRate); channelCount = WaveFormat.Channels; soundTouch.SetChannels(channelCount); sourceReadBuffer = new float[(WaveFormat.SampleRate * channelCount * (long)readDurationMilliseconds) / 1000]; soundTouchReadBuffer = new float[sourceReadBuffer.Length * 10]; // support down to 0.1 speed endNotified = false; }