public void SetSoundTouchProfile(SoundTouchProfile soundTouchProfile) { if (_currentSoundTouchProfile != null && _playbackRate != 1.0f && soundTouchProfile.UseTempo != _currentSoundTouchProfile.UseTempo) { if (soundTouchProfile.UseTempo) { _soundTouch.SetRate(1.0f); _soundTouch.SetPitchOctaves(0f); _soundTouch.SetTempo(_playbackRate); } else { _soundTouch.SetTempo(1.0f); _soundTouch.SetRate(_playbackRate); } } _currentSoundTouchProfile = soundTouchProfile; _soundTouch.SetUseAntiAliasing(soundTouchProfile.UseAntiAliasing); _soundTouch.SetUseQuickSeek(soundTouchProfile.UseQuickSeek); }
public VarispeedProvider(ISampleProvider sourceProvider, int readDurationMilliseconds, SoundTouchProfile soundTouchProfile) { _soundTouch = new SoundTouch(); SetSoundTouchProfile(soundTouchProfile); _sourceProvider = sourceProvider; _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 }