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 // replays
if (isReplay) if (isReplay)
GameMod.loadModState(previousMods); GameMod.loadModState(previousMods);
// reset playback speed
MusicController.setPitch(1f);
} }
/** /**

View File

@ -216,6 +216,13 @@ public class GamePauseMenu extends BasicGameState {
backButton.resetHover(); 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. * Loads all game pause/fail menu images.
*/ */

View File

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

View File

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