public void IncreaseDecreasePitch(float pitchValue) { currentPitch += pitchValue; if (currentPitch > 20f) { currentPitch = 20f; } if (currentPitch < -20f) { currentPitch = -20f; } if (IsMusicPlaying()) { soundTouch.SetPitchSemiTones(currentPitch); } }
private void SetSoundTouchSettings(SoundTouch soundTouch, AudioFileReader audioFileReader, bool preventReset = false) { soundTouch.SetSampleRate(audioFileReader.WaveFormat.SampleRate); soundTouch.SetChannels(audioFileReader.WaveFormat.Channels); if (ResetMusicRates && !preventReset) { currentPitch = 0.0f; currentTempo = 1.0f; currentSpeed = 1.0f; } soundTouch.SetPitchSemiTones(currentPitch); soundTouch.SetTempo(currentTempo); soundTouch.SetRate(currentSpeed); soundTouch.SetUseAntiAliasing(true); }