This commit is contained in:
yugecin 2016-10-11 18:36:28 +02:00
parent a755ff4484
commit d8aaa3e5a4
3 changed files with 23 additions and 18 deletions

View File

@ -236,13 +236,18 @@ public class MultiClip {
extraClips = 0; extraClips = 0;
} }
/** /**
* Mute the Clip (because destroying it, won't stop it) * Mute the Clip (because destroying it, won't stop it)
*/ */
public void mute() { public void mute() {
try { try {
((FloatControl) getClip().getControl(FloatControl.Type.MASTER_GAIN)).setValue((float) (Math.log(Float.MIN_VALUE) / Math.log(10.0) * 20.0)); Clip c = getClip();
} catch (Exception e) { if (c == null) {
} return;
} }
((FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN)).setValue((float) (Math.log(Float.MIN_VALUE) / Math.log(10.0) * 20.0));
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}
} }

View File

@ -57,8 +57,8 @@ public class SoundController {
/** The current track being played, if any. */ /** The current track being played, if any. */
private static MultiClip currentTrack; private static MultiClip currentTrack;
/** The current SoundComponent being played, if any */ /** The current SoundComponent being played, if any */
private static MultiClip currentSoundComponent; private static MultiClip currentSoundComponent;
/** Sample volume multiplier, from timing points [0, 1]. */ /** Sample volume multiplier, from timing points [0, 1]. */
private static float sampleVolumeMultiplier = 1f; private static float sampleVolumeMultiplier = 1f;
@ -385,10 +385,10 @@ public class SoundController {
} }
} }
public static void muteSoundComponent() { public static void muteSoundComponent() {
if (currentSoundComponent != null) { if (currentSoundComponent != null) {
currentSoundComponent.mute(); currentSoundComponent.mute();
currentSoundComponent = null; currentSoundComponent = null;
} }
} }
} }

View File

@ -240,7 +240,7 @@ public class GameRanking extends BasicGameState {
* Returns to the song menu. * Returns to the song menu.
*/ */
private void returnToSongMenu() { private void returnToSongMenu() {
SoundController.muteSoundComponent(); SoundController.muteSoundComponent();
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
if (data.isGameplay()) if (data.isGameplay())