Fix pitch changes (hopefully)

This commit is contained in:
MatteoS 2015-11-16 21:21:28 +01:00
parent 13e0bdb81e
commit d0069c20e5
4 changed files with 17 additions and 12 deletions

View File

@ -1262,9 +1262,6 @@ public class Game extends BasicGameState {
// replays
if (isReplay)
GameMod.loadModState(previousMods);
// reset playback speed
MusicController.setPitch(1f);
}
/**

View File

@ -216,6 +216,13 @@ public class GamePauseMenu extends BasicGameState {
backButton.resetHover();
}
@Override
public void leave(GameContainer container, StateBasedGame game)
throws SlickException {
// reset pitch fade out
MusicController.pitchFadeOut(0);
}
/**
* Loads all game pause/fail menu images.
*/

View File

@ -1118,6 +1118,7 @@ public class SongMenu extends BasicGameState {
else if (resetTrack) {
MusicController.pause();
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
MusicController.setPitch(1.0f);
resetTrack = false;
}

View File

@ -325,6 +325,7 @@ public class Music {
currentMusic = this;
sound.playAsMusic(pitch, volume, loop);
setVolume(volume);
setPitch(pitch);
if (requiredPosition != -1) {
setPosition(requiredPosition);
}
@ -444,6 +445,14 @@ public class Music {
return;
}
if (pitchTime > 0) {
pitchTime -= delta;
if (pitchTime < 0) {
pitchTime = 0;
}
float offset = (pitchEnd - pitchStart) * (1 - (pitchTime / (float)pitchDuration));
setPitch(pitchStart + offset);
}
if (fadeTime > 0) {
fadeTime -= delta;
if (fadeTime < 0) {
@ -457,15 +466,6 @@ public class Music {
float offset = (fadeEndGain - fadeStartGain) * (1 - (fadeTime / (float)fadeDuration));
setVolume(fadeStartGain + offset);
}
if (pitchTime > 0) {
pitchTime -= delta;
if (pitchTime < 0) {
pitchTime = 0;
}
float offset = (pitchEnd - pitchStart) * (1 - (pitchTime / (float)pitchDuration));
setPitch(pitchStart + offset);
}
}
/**