diff --git a/src/itdelatrisu/opsu/GameScore.java b/src/itdelatrisu/opsu/GameScore.java
index 14545d2f..b828b58a 100644
--- a/src/itdelatrisu/opsu/GameScore.java
+++ b/src/itdelatrisu/opsu/GameScore.java
@@ -18,6 +18,10 @@
package itdelatrisu.opsu;
+import itdelatrisu.opsu.audio.HitSound;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Options;
import java.io.File;
@@ -841,7 +845,7 @@ public class GameScore {
*/
private void resetComboStreak() {
if (combo >= 20)
- SoundController.playSound(SoundController.SOUND_COMBOBREAK);
+ SoundController.playSound(SoundEffect.COMBOBREAK);
combo = 0;
if (GameMod.SUDDEN_DEATH.isActive())
health = 0f;
@@ -867,7 +871,7 @@ public class GameScore {
case HIT_SLIDER10:
hitValue = 10;
incrementComboStreak();
- SoundController.playHitSound(SoundController.HIT_SLIDERTICK);
+ SoundController.playHitSound(HitSound.SLIDERTICK);
break;
case HIT_MISS:
resetComboStreak();
diff --git a/src/itdelatrisu/opsu/Opsu.java b/src/itdelatrisu/opsu/Opsu.java
index c3423552..fbeca11d 100644
--- a/src/itdelatrisu/opsu/Opsu.java
+++ b/src/itdelatrisu/opsu/Opsu.java
@@ -18,6 +18,7 @@
package itdelatrisu.opsu;
+import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.states.GamePauseMenu;
import itdelatrisu.opsu.states.GameRanking;
diff --git a/src/itdelatrisu/opsu/Utils.java b/src/itdelatrisu/opsu/Utils.java
index f116e76f..8ef4d455 100644
--- a/src/itdelatrisu/opsu/Utils.java
+++ b/src/itdelatrisu/opsu/Utils.java
@@ -18,6 +18,8 @@
package itdelatrisu.opsu;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Options;
import java.awt.Font;
@@ -476,7 +478,7 @@ public class Utils {
File file = new File(dir, String.format("screenshot_%s.%s",
date.format(new Date()), Options.getScreenshotFormat()));
- SoundController.playSound(SoundController.SOUND_SHUTTER);
+ SoundController.playSound(SoundEffect.SHUTTER);
// copy the screen
Image screen = new Image(container.getWidth(), container.getHeight());
diff --git a/src/itdelatrisu/opsu/audio/HitSound.java b/src/itdelatrisu/opsu/audio/HitSound.java
new file mode 100644
index 00000000..19c639ea
--- /dev/null
+++ b/src/itdelatrisu/opsu/audio/HitSound.java
@@ -0,0 +1,159 @@
+/*
+ * opsu! - an open-source osu! client
+ * Copyright (C) 2014 Jeffrey Han
+ *
+ * opsu! is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * opsu! is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with opsu!. If not, see .
+ */
+
+package itdelatrisu.opsu.audio;
+
+import java.util.HashMap;
+
+import javax.sound.sampled.Clip;
+
+/**
+ * Hit sounds.
+ */
+public enum HitSound implements SoundController.SoundComponent {
+ CLAP ("hitclap"),
+ FINISH ("hitfinish"),
+ NORMAL ("hitnormal"),
+ WHISTLE ("hitwhistle"),
+ SLIDERSLIDE ("sliderslide"),
+ SLIDERTICK ("slidertick"),
+ SLIDERWHISTLE ("sliderwhistle");
+
+ /**
+ * Sound sample sets.
+ */
+ public static enum SampleSet {
+ NORMAL ("normal", 1),
+ SOFT ("soft", 2),
+ DRUM ("drum", 3);
+// TAIKO ("taiko", 4);
+
+ /**
+ * The sample set name.
+ */
+ private String name;
+
+ /**
+ * The sample set index.
+ */
+ private int index;
+
+ /**
+ * Total number of sample sets.
+ */
+ public static final int SIZE = SampleSet.values().length;
+
+ /**
+ * Constructor.
+ * @param name the sample set name
+ */
+ SampleSet(String name, int index) {
+ this.name = name;
+ this.index = index;
+ }
+
+ /**
+ * Returns the sample set name.
+ * @return the name
+ */
+ public String getName() { return name; }
+
+ /**
+ * Returns the sample set index.
+ * @return the index
+ */
+ public int getIndex() { return index; }
+ }
+
+ /**
+ * Current sample set.
+ */
+ private static SampleSet currentSampleSet;
+
+ /**
+ * The file name.
+ */
+ private String filename;
+
+ /**
+ * The Clip associated with the hit sound.
+ */
+ private HashMap clips;
+
+ /**
+ * Total number of hit sounds.
+ */
+ public static final int SIZE = HitSound.values().length;
+
+ /**
+ * Constructor.
+ * @param filename the sound file name
+ */
+ HitSound(String filename) {
+ this.filename = filename;
+ this.clips = new HashMap();
+ }
+
+ /**
+ * Returns the file name.
+ * @return the file name
+ */
+ public String getFileName() { return filename; }
+
+ @Override
+ public Clip getClip() {
+ return (currentSampleSet != null) ? clips.get(currentSampleSet) : null;
+ }
+
+ /**
+ * Sets the hit sound Clip for the sample type.
+ * @param s the sample set
+ * @param clip the Clip
+ */
+ public void setClip(SampleSet s, Clip clip) {
+ clips.put(s, clip);
+ }
+
+ /**
+ * Sets the sample set to use when playing hit sounds.
+ * @param sampleSet the sample set ("None", "Normal", "Soft", "Drum")
+ */
+ public static void setSampleSet(String sampleSet) {
+ currentSampleSet = null;
+ for (SampleSet ss : SampleSet.values()) {
+ if (sampleSet.equalsIgnoreCase(ss.getName())) {
+ currentSampleSet = ss;
+ return;
+ }
+ }
+ }
+
+ /**
+ * Sets the sample set to use when playing hit sounds.
+ * @param sampleType the sample set (0:none, 1:normal, 2:soft, 3:drum)
+ */
+ public static void setSampleSet(byte sampleType) {
+ currentSampleSet = null;
+ for (SampleSet ss : SampleSet.values()) {
+ if (sampleType == ss.getIndex()) {
+ currentSampleSet = ss;
+ return;
+ }
+ }
+ }
+}
diff --git a/src/itdelatrisu/opsu/MusicController.java b/src/itdelatrisu/opsu/audio/MusicController.java
similarity index 98%
rename from src/itdelatrisu/opsu/MusicController.java
rename to src/itdelatrisu/opsu/audio/MusicController.java
index 4084c62a..cfe3bb60 100644
--- a/src/itdelatrisu/opsu/MusicController.java
+++ b/src/itdelatrisu/opsu/audio/MusicController.java
@@ -16,8 +16,10 @@
* along with opsu!. If not, see .
*/
-package itdelatrisu.opsu;
+package itdelatrisu.opsu.audio;
+import itdelatrisu.opsu.OsuFile;
+import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.states.Options;
import java.io.File;
diff --git a/src/itdelatrisu/opsu/SoundController.java b/src/itdelatrisu/opsu/audio/SoundController.java
similarity index 54%
rename from src/itdelatrisu/opsu/SoundController.java
rename to src/itdelatrisu/opsu/audio/SoundController.java
index 505d97db..95007128 100644
--- a/src/itdelatrisu/opsu/SoundController.java
+++ b/src/itdelatrisu/opsu/audio/SoundController.java
@@ -16,8 +16,10 @@
* along with opsu!. If not, see .
*/
-package itdelatrisu.opsu;
+package itdelatrisu.opsu.audio;
+import itdelatrisu.opsu.OsuHitObject;
+import itdelatrisu.opsu.audio.HitSound.SampleSet;
import itdelatrisu.opsu.states.Options;
import java.io.IOException;
@@ -36,108 +38,20 @@ import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;
/**
- * Controller for all sound effects.
+ * Controller for all (non-music) sound components.
* Note: Uses Java Sound because OpenAL lags too much for accurate hit sounds.
*/
public class SoundController {
/**
- * Sound effect constants.
+ * Interface for all (non-music) sound components.
*/
- public static final int
- SOUND_APPLAUSE = 0,
- SOUND_COMBOBREAK = 1,
-// SOUND_COUNT = , // ?
- SOUND_COUNT1 = 2,
- SOUND_COUNT2 = 3,
- SOUND_COUNT3 = 4,
- SOUND_FAIL = 5,
- SOUND_GO = 6,
- SOUND_MENUBACK = 7,
- SOUND_MENUCLICK = 8,
- SOUND_MENUHIT = 9,
- SOUND_READY = 10,
- SOUND_SECTIONFAIL = 11,
- SOUND_SECTIONPASS = 12,
- SOUND_SHUTTER = 13,
- SOUND_SPINNERBONUS = 14,
- SOUND_SPINNEROSU = 15,
- SOUND_SPINNERSPIN = 16,
- SOUND_MAX = 17; // not a sound
-
- /**
- * Sound effect names (indexed by SOUND_* constants).
- */
- private static final String[] soundNames = {
- "applause",
- "combobreak",
-// "count", // ?
- "count1s",
- "count2s",
- "count3s",
- "failsound",
- "gos",
- "menuback",
- "menuclick",
- "menuhit",
- "readys",
- "sectionfail",
- "sectionpass",
- "shutter",
- "spinnerbonus",
- "spinner-osu",
- "spinnerspin",
- };
-
- /**
- * Sound effects (indexed by SOUND_* constants).
- */
- private static Clip[] sounds = new Clip[SOUND_MAX];
-
- /**
- * Sound sample sets.
- */
- private static final String[] sampleSets = {
- "normal",
- "soft",
- "drum",
-// "taiko"
- };
-
- /**
- * Current sample set (index in sampleSet[] array).
- */
- private static int sampleSetIndex = -1;
-
- /**
- * Hit sound effects.
- */
- public static final int
- HIT_CLAP = 0,
- HIT_FINISH = 1,
- HIT_NORMAL = 2,
- HIT_WHISTLE = 3,
- HIT_SLIDERSLIDE = 4,
- HIT_SLIDERTICK = 5,
- HIT_SLIDERWHISTLE = 6,
- HIT_MAX = 7; // not a sound
-
- /**
- * Hit sound effect names (indexed by HIT_* constants).
- */
- private static final String[] hitSoundNames = {
- "hitclap",
- "hitfinish",
- "hitnormal",
- "hitwhistle",
- "sliderslide",
- "slidertick",
- "sliderwhistle"
- };
-
- /**
- * Hit sound effects (indexed by sampleSets[], HIT_* constants).
- */
- private static Clip[][] hitSounds = new Clip[sampleSets.length][HIT_MAX];
+ public interface SoundComponent {
+ /**
+ * Returns the Clip associated with the sound component.
+ * @return the Clip
+ */
+ public Clip getClip();
+ }
/**
* Sample volume multiplier, from timing points [0, 1].
@@ -175,7 +89,7 @@ public class SoundController {
clip.open(audioIn);
return clip;
- } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {
+ } catch (UnsupportedAudioFileException | IOException | LineUnavailableException | RuntimeException e) {
Log.error(String.format("Failed to load file '%s'.", ref), e);
}
return null;
@@ -192,45 +106,24 @@ public class SoundController {
currentFileIndex = 0;
// menu and game sounds
- for (int i = 0; i < SOUND_MAX; i++, currentFileIndex++) {
- currentFileName = String.format("%s.wav", soundNames[i]);
- sounds[i] = loadClip(currentFileName);
+ for (SoundEffect s : SoundEffect.values()) {
+ currentFileName = String.format("%s.wav", s.getFileName());
+ s.setClip(loadClip(currentFileName));
+ currentFileIndex++;
}
// hit sounds
- for (int i = 0; i < sampleSets.length; i++) {
- for (int j = 0; j < HIT_MAX; j++, currentFileIndex++) {
- currentFileName = String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]);
- hitSounds[i][j] = loadClip(currentFileName);
+ for (SampleSet ss : SampleSet.values()) {
+ for (HitSound s : HitSound.values()) {
+ currentFileName = String.format("%s-%s.wav", ss.getName(), s.getFileName());
+ s.setClip(ss, loadClip(currentFileName));
+ currentFileIndex++;
}
}
currentFileName = null;
currentFileIndex = -1;
}
-
- /**
- * Sets the sample set to use when playing hit sounds.
- * @param sampleSet the sample set ("None", "Normal", "Soft", "Drum")
- */
- public static void setSampleSet(String sampleSet) {
- sampleSetIndex = -1;
- for (int i = 0; i < sampleSets.length; i++) {
- if (sampleSet.equalsIgnoreCase(sampleSets[i])) {
- sampleSetIndex = i;
- return;
- }
- }
- }
-
- /**
- * Sets the sample set to use when playing hit sounds.
- * @param sampleType the sample set (0:none, 1:normal, 2:soft, 3:drum)
- */
- public static void setSampleSet(byte sampleType) {
- if (sampleType >= 0 && sampleType <= 3)
- sampleSetIndex = sampleType - 1;
- }
/**
* Sets the sample volume (modifies the global sample volume).
@@ -273,21 +166,18 @@ public class SoundController {
/**
* Plays a sound.
- * @param sound the sound (SOUND_* constant)
+ * @param s the sound effect
*/
- public static void playSound(int sound) {
- if (sound < 0 || sound >= SOUND_MAX)
- return;
-
- playClip(sounds[sound], Options.getEffectVolume());
+ public static void playSound(SoundComponent s) {
+ playClip(s.getClip(), Options.getEffectVolume());
}
/**
* Plays hit sound(s) using an OsuHitObject bitmask.
- * @param hitSound the sound (bitmask)
+ * @param hitSound the hit sound (bitmask)
*/
public static void playHitSound(byte hitSound) {
- if (sampleSetIndex < 0 || hitSound < 0)
+ if (hitSound < 0)
return;
float volume = Options.getHitSoundVolume() * sampleVolumeMultiplier;
@@ -296,27 +186,23 @@ public class SoundController {
// play all sounds
if (hitSound == OsuHitObject.SOUND_NORMAL)
- playClip(hitSounds[sampleSetIndex][HIT_NORMAL], volume);
+ playClip(HitSound.NORMAL.getClip(), volume);
else {
if ((hitSound & OsuHitObject.SOUND_WHISTLE) > 0)
- playClip(hitSounds[sampleSetIndex][HIT_WHISTLE], volume);
+ playClip(HitSound.WHISTLE.getClip(), volume);
if ((hitSound & OsuHitObject.SOUND_FINISH) > 0)
- playClip(hitSounds[sampleSetIndex][HIT_FINISH], volume);
+ playClip(HitSound.FINISH.getClip(), volume);
if ((hitSound & OsuHitObject.SOUND_CLAP) > 0)
- playClip(hitSounds[sampleSetIndex][HIT_CLAP], volume);
+ playClip(HitSound.CLAP.getClip(), volume);
}
}
/**
* Plays a hit sound.
- * @param sound (HIT_* constant)
+ * @param s the hit sound
*/
- public static void playHitSound(int sound) {
- if (sampleSetIndex < 0 || sound < 0 || sound > HIT_MAX)
- return;
-
- playClip(hitSounds[sampleSetIndex][sound],
- Options.getHitSoundVolume() * sampleVolumeMultiplier);
+ public static void playHitSound(SoundComponent s) {
+ playClip(s.getClip(), Options.getHitSoundVolume() * sampleVolumeMultiplier);
}
/**
@@ -334,6 +220,6 @@ public class SoundController {
if (currentFileIndex == -1)
return -1;
- return currentFileIndex * 100 / (SOUND_MAX + (sampleSets.length * HIT_MAX));
+ return currentFileIndex * 100 / (SoundEffect.SIZE + (HitSound.SIZE * SampleSet.SIZE));
}
}
diff --git a/src/itdelatrisu/opsu/audio/SoundEffect.java b/src/itdelatrisu/opsu/audio/SoundEffect.java
new file mode 100644
index 00000000..4969d9ef
--- /dev/null
+++ b/src/itdelatrisu/opsu/audio/SoundEffect.java
@@ -0,0 +1,83 @@
+/*
+ * opsu! - an open-source osu! client
+ * Copyright (C) 2014 Jeffrey Han
+ *
+ * opsu! is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * opsu! is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with opsu!. If not, see .
+ */
+
+package itdelatrisu.opsu.audio;
+
+import javax.sound.sampled.Clip;
+
+/**
+ * Sound effects.
+ */
+public enum SoundEffect implements SoundController.SoundComponent {
+ APPLAUSE ("applause"),
+ COMBOBREAK ("combobreak"),
+// COUNT ("count"), // ?
+ COUNT1 ("count1s"),
+ COUNT2 ("count2s"),
+ COUNT3 ("count3s"),
+ FAIL ("failsound"),
+ GO ("gos"),
+ MENUBACK ("menuback"),
+ MENUCLICK ("menuclick"),
+ MENUHIT ("menuhit"),
+ READY ("readys"),
+ SECTIONFAIL ("sectionfail"),
+ SECTIONPASS ("sectionpass"),
+ SHUTTER ("shutter"),
+ SPINNERBONUS ("spinnerbonus"),
+ SPINNEROSU ("spinner-osu"),
+ SPINNERSPIN ("spinnerspin");
+
+ /**
+ * The file name.
+ */
+ private String filename;
+
+ /**
+ * The Clip associated with the sound effect.
+ */
+ private Clip clip;
+
+ /**
+ * Total number of sound effects.
+ */
+ public static final int SIZE = SoundEffect.values().length;
+
+ /**
+ * Constructor.
+ * @param filename the sound file name
+ */
+ SoundEffect(String filename) {
+ this.filename = filename;
+ }
+
+ /**
+ * Returns the file name.
+ * @return the file name
+ */
+ public String getFileName() { return filename; }
+
+ @Override
+ public Clip getClip() { return clip; }
+
+ /**
+ * Sets the Clip for the sound.
+ * @param clip the clip
+ */
+ public void setClip(Clip clip) { this.clip = clip; }
+}
diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java
index 74dc36d2..f51ec849 100644
--- a/src/itdelatrisu/opsu/objects/Circle.java
+++ b/src/itdelatrisu/opsu/objects/Circle.java
@@ -21,9 +21,9 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game;
import org.newdawn.slick.Color;
diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java
index b8f861cb..14b86cdc 100644
--- a/src/itdelatrisu/opsu/objects/Slider.java
+++ b/src/itdelatrisu/opsu/objects/Slider.java
@@ -21,10 +21,10 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game;
import java.io.File;
diff --git a/src/itdelatrisu/opsu/objects/Spinner.java b/src/itdelatrisu/opsu/objects/Spinner.java
index 20a6c170..0b98d086 100644
--- a/src/itdelatrisu/opsu/objects/Spinner.java
+++ b/src/itdelatrisu/opsu/objects/Spinner.java
@@ -21,10 +21,11 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuHitObject;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Game;
import org.newdawn.slick.Color;
@@ -152,7 +153,7 @@ public class Spinner {
if (ratio >= 1.0f ||
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
result = GameScore.HIT_300;
- SoundController.playSound(SoundController.SOUND_SPINNEROSU);
+ SoundController.playSound(SoundEffect.SPINNEROSU);
} else if (ratio >= 0.8f)
result = GameScore.HIT_100;
else if (ratio >= 0.5f)
@@ -231,10 +232,10 @@ public class Spinner {
if (Math.floor(newRotations) > rotations) {
if (newRotations > rotationsNeeded) { // extra rotations
score.changeScore(1000);
- SoundController.playSound(SoundController.SOUND_SPINNERBONUS);
+ SoundController.playSound(SoundEffect.SPINNERBONUS);
} else {
score.changeScore(100);
- SoundController.playSound(SoundController.SOUND_SPINNERSPIN);
+ SoundController.playSound(SoundEffect.SPINNERSPIN);
}
}
diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java
index 6a25da3d..a3baf27c 100644
--- a/src/itdelatrisu/opsu/states/Game.java
+++ b/src/itdelatrisu/opsu/states/Game.java
@@ -18,17 +18,19 @@
package itdelatrisu.opsu.states;
-import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
-import itdelatrisu.opsu.MusicController;
+import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.OsuTimingPoint;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.HitSound;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.Spinner;
@@ -292,13 +294,13 @@ public class Game extends BasicGameState {
if (score.getHealth() >= 50) {
GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f);
if (!breakSound) {
- SoundController.playSound(SoundController.SOUND_SECTIONPASS);
+ SoundController.playSound(SoundEffect.SECTIONPASS);
breakSound = true;
}
} else {
GameImage.SECTION_FAIL.getImage().drawCentered(width / 2f, height / 2f);
if (!breakSound) {
- SoundController.playSound(SoundController.SOUND_SECTIONFAIL);
+ SoundController.playSound(SoundEffect.SECTIONFAIL);
breakSound = true;
}
}
@@ -359,28 +361,28 @@ public class Game extends BasicGameState {
if (timeDiff >= 1500) {
GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2);
if (!countdownReadySound) {
- SoundController.playSound(SoundController.SOUND_READY);
+ SoundController.playSound(SoundEffect.READY);
countdownReadySound = true;
}
}
if (timeDiff < 2000) {
GameImage.COUNTDOWN_3.getImage().draw(0, 0);
if (!countdown3Sound) {
- SoundController.playSound(SoundController.SOUND_COUNT3);
+ SoundController.playSound(SoundEffect.COUNT3);
countdown3Sound = true;
}
}
if (timeDiff < 1500) {
GameImage.COUNTDOWN_2.getImage().draw(width - GameImage.COUNTDOWN_2.getImage().getWidth(), 0);
if (!countdown2Sound) {
- SoundController.playSound(SoundController.SOUND_COUNT2);
+ SoundController.playSound(SoundEffect.COUNT2);
countdown2Sound = true;
}
}
if (timeDiff < 1000) {
GameImage.COUNTDOWN_1.getImage().drawCentered(width / 2, height / 2);
if (!countdown1Sound) {
- SoundController.playSound(SoundController.SOUND_COUNT1);
+ SoundController.playSound(SoundEffect.COUNT1);
countdown1Sound = true;
}
}
@@ -389,7 +391,7 @@ public class Game extends BasicGameState {
go.setAlpha((timeDiff < 0) ? 1 - (timeDiff / -1000f) : 1);
go.drawCentered(width / 2, height / 2);
if (!countdownGoSound) {
- SoundController.playSound(SoundController.SOUND_GO);
+ SoundController.playSound(SoundEffect.GO);
countdownGoSound = true;
}
}
@@ -510,7 +512,7 @@ public class Game extends BasicGameState {
beatLengthBase = beatLength = timingPoint.getBeatLength();
else
beatLength = beatLengthBase * timingPoint.getSliderMultiplier();
- SoundController.setSampleSet(timingPoint.getSampleType());
+ HitSound.setSampleSet(timingPoint.getSampleType());
SoundController.setSampleVolume(timingPoint.getSampleVolume());
timingPointIndex++;
}
@@ -650,7 +652,7 @@ public class Game extends BasicGameState {
int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000))
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
}
break;
case Input.KEY_L:
@@ -667,7 +669,7 @@ public class Game extends BasicGameState {
leadInTime = 0;
MusicController.resume();
}
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
// skip to checkpoint
MusicController.setPosition(checkpoint);
@@ -805,7 +807,7 @@ public class Game extends BasicGameState {
OsuTimingPoint timingPoint = osu.timingPoints.get(0);
if (!timingPoint.isInherited()) {
beatLengthBase = beatLength = timingPoint.getBeatLength();
- SoundController.setSampleSet(timingPoint.getSampleType());
+ HitSound.setSampleSet(timingPoint.getSampleType());
SoundController.setSampleVolume(timingPoint.getSampleVolume());
timingPointIndex++;
}
@@ -839,7 +841,7 @@ public class Game extends BasicGameState {
MusicController.resume();
}
MusicController.setPosition(firstObjectTime - SKIP_OFFSET);
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
return true;
}
return false;
diff --git a/src/itdelatrisu/opsu/states/GamePauseMenu.java b/src/itdelatrisu/opsu/states/GamePauseMenu.java
index a3a46795..24de29a7 100644
--- a/src/itdelatrisu/opsu/states/GamePauseMenu.java
+++ b/src/itdelatrisu/opsu/states/GamePauseMenu.java
@@ -18,12 +18,13 @@
package itdelatrisu.opsu.states;
-import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameImage;
-import itdelatrisu.opsu.MusicController;
+import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color;
@@ -126,10 +127,10 @@ public class GamePauseMenu extends BasicGameState {
if (Game.getRestart() == Game.RESTART_LOSE) {
MusicController.stop();
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
Game.setRestart(Game.RESTART_FALSE);
game.enterState(Opsu.STATE_GAME);
}
@@ -159,17 +160,17 @@ public class GamePauseMenu extends BasicGameState {
return;
if (continueButton.contains(x, y) && !loseState) {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
Game.setRestart(Game.RESTART_FALSE);
game.enterState(Opsu.STATE_GAME);
} else if (retryButton.contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
Game.setRestart(Game.RESTART_MANUAL);
game.enterState(Opsu.STATE_GAME);
} else if (backButton.contains(x, y)) {
MusicController.pause(); // lose state
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
}
@@ -180,7 +181,7 @@ public class GamePauseMenu extends BasicGameState {
pauseStartTime = System.currentTimeMillis();
if (Game.getRestart() == Game.RESTART_LOSE) {
MusicController.fadeOut(FADEOUT_TIME);
- SoundController.playSound(SoundController.SOUND_FAIL);
+ SoundController.playSound(SoundEffect.FAIL);
} else
MusicController.pause();
continueButton.setScale(1f);
diff --git a/src/itdelatrisu/opsu/states/GameRanking.java b/src/itdelatrisu/opsu/states/GameRanking.java
index 94566651..11fe35f3 100644
--- a/src/itdelatrisu/opsu/states/GameRanking.java
+++ b/src/itdelatrisu/opsu/states/GameRanking.java
@@ -18,14 +18,15 @@
package itdelatrisu.opsu.states;
-import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore;
-import itdelatrisu.opsu.MusicController;
+import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import org.lwjgl.opengl.Display;
import org.newdawn.slick.Color;
@@ -153,7 +154,7 @@ public class GameRanking extends BasicGameState {
case Input.KEY_ESCAPE:
MusicController.pause();
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
break;
case Input.KEY_F12:
@@ -172,16 +173,16 @@ public class GameRanking extends BasicGameState {
OsuFile osu = MusicController.getOsuFile();
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
Game.setRestart(Game.RESTART_MANUAL);
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (exitButton.contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (Utils.getBackButton().contains(x, y)) {
MusicController.pause();
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
}
@@ -191,6 +192,6 @@ public class GameRanking extends BasicGameState {
throws SlickException {
Display.setTitle(game.getTitle());
Utils.getBackButton().setScale(1f);
- SoundController.playSound(SoundController.SOUND_APPLAUSE);
+ SoundController.playSound(SoundEffect.APPLAUSE);
}
}
diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java
index bcfdd524..a6fb7851 100644
--- a/src/itdelatrisu/opsu/states/MainMenu.java
+++ b/src/itdelatrisu/opsu/states/MainMenu.java
@@ -19,12 +19,13 @@
package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupNode;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -355,14 +356,14 @@ public class MainMenu extends BasicGameState {
logoTimer = 0;
playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f);
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
}
}
// other button actions (if visible)
else if (logoClicked) {
if (logo.contains(x, y) || playButton.contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (exitButton.contains(x, y)) {
Options.saveOptions();
@@ -385,9 +386,9 @@ public class MainMenu extends BasicGameState {
logoTimer = 0;
playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f);
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
} else {
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
break;
diff --git a/src/itdelatrisu/opsu/states/Options.java b/src/itdelatrisu/opsu/states/Options.java
index 91cf0455..3debb39f 100644
--- a/src/itdelatrisu/opsu/states/Options.java
+++ b/src/itdelatrisu/opsu/states/Options.java
@@ -18,12 +18,13 @@
package itdelatrisu.opsu.states;
-import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameMod;
+import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -548,7 +549,7 @@ public class Options extends BasicGameState {
// back
if (Utils.getBackButton().contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
return;
}
@@ -558,7 +559,7 @@ public class Options extends BasicGameState {
if (optionTabs[i].contains(x, y)) {
if (i != currentTab) {
currentTab = i;
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
}
return;
}
@@ -570,7 +571,7 @@ public class Options extends BasicGameState {
boolean prevState = mod.isActive();
mod.toggle(true);
if (mod.isActive() != prevState)
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
return;
}
}
@@ -766,7 +767,7 @@ public class Options extends BasicGameState {
switch (key) {
case Input.KEY_ESCAPE:
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
break;
case Input.KEY_F12:
@@ -777,7 +778,7 @@ public class Options extends BasicGameState {
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
i = TAB_MAX - 1;
currentTab = (currentTab + i) % TAB_MAX;
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
break;
}
}
diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java
index 26cf0cd0..3094f582 100644
--- a/src/itdelatrisu/opsu/states/SongMenu.java
+++ b/src/itdelatrisu/opsu/states/SongMenu.java
@@ -19,14 +19,16 @@
package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.SongSort;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.HitSound;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
+import itdelatrisu.opsu.audio.SoundEffect;
import org.lwjgl.opengl.Display;
import org.newdawn.slick.Animation;
@@ -351,7 +353,7 @@ public class SongMenu extends BasicGameState {
// back
if (Utils.getBackButton().contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return;
@@ -359,7 +361,7 @@ public class SongMenu extends BasicGameState {
// options
if (optionsButton.contains(x, y)) {
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_OPTIONS, new EmptyTransition(), new FadeInTransition(Color.black));
return;
}
@@ -372,7 +374,7 @@ public class SongMenu extends BasicGameState {
if (sort.contains(x, y)) {
if (sort != SongSort.getSort()) {
SongSort.setSort(sort);
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
OsuGroupNode oldFocusBase = Opsu.groups.getBaseNode(focusNode.index);
int oldFocusFileIndex = focusNode.osuFileIndex;
focusNode = null;
@@ -400,7 +402,7 @@ public class SongMenu extends BasicGameState {
} else {
// focus the node
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(node, 0, false);
}
break;
@@ -408,7 +410,7 @@ public class SongMenu extends BasicGameState {
// clicked node is a new group
else {
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(node, -1, false);
break;
}
@@ -424,7 +426,7 @@ public class SongMenu extends BasicGameState {
search.setText("");
searchTimer = SEARCH_DELAY;
} else {
- SoundController.playSound(SoundController.SOUND_MENUBACK);
+ SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
@@ -453,7 +455,7 @@ public class SongMenu extends BasicGameState {
break;
OsuGroupNode next = focusNode.next;
if (next != null) {
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(next, 0, false);
}
break;
@@ -462,7 +464,7 @@ public class SongMenu extends BasicGameState {
break;
OsuGroupNode prev = focusNode.prev;
if (prev != null) {
- SoundController.playSound(SoundController.SOUND_MENUCLICK);
+ SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.osuFiles.size() - 1, false);
}
break;
@@ -621,11 +623,11 @@ public class SongMenu extends BasicGameState {
if (MusicController.isTrackLoading())
return;
- SoundController.playSound(SoundController.SOUND_MENUHIT);
+ SoundController.playSound(SoundEffect.MENUHIT);
OsuFile osu = MusicController.getOsuFile();
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
OsuParser.parseHitObjects(osu);
- SoundController.setSampleSet(osu.sampleSet);
+ HitSound.setSampleSet(osu.sampleSet);
Game.setRestart(Game.RESTART_NEW);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
}
diff --git a/src/itdelatrisu/opsu/states/Splash.java b/src/itdelatrisu/opsu/states/Splash.java
index b66ec1ff..7f4ba318 100644
--- a/src/itdelatrisu/opsu/states/Splash.java
+++ b/src/itdelatrisu/opsu/states/Splash.java
@@ -18,12 +18,12 @@
package itdelatrisu.opsu.states;
-import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
-import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils;
+import itdelatrisu.opsu.audio.MusicController;
+import itdelatrisu.opsu.audio.SoundController;
import java.io.File;