Skip to content

Commit

Permalink
source cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
micycle1 committed Dec 27, 2024
1 parent 2697397 commit c0556d8
Show file tree
Hide file tree
Showing 69 changed files with 942 additions and 959 deletions.
39 changes: 16 additions & 23 deletions src/main/java/project_16x16/Audio.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Provides static methods for playing game audio: background music and sound
* effects.
*
*
* @author micycle1
*
*/
Expand All @@ -28,8 +28,7 @@ public final class Audio {
public enum BGM {
TEST0("first_theme.mp3"), // TODO
TEST1("cyberSynthwave.mp3"), // TODO
TEST2("First_level_take_1.mp3"),
TEST3("Intro_Title_Pause_Screen_Take1_Loopable.mp3");
TEST2("First_level_take_1.mp3"), TEST3("Intro_Title_Pause_Screen_Take1_Loopable.mp3");

private String filename;

Expand Down Expand Up @@ -64,7 +63,7 @@ public String getPath() {

/**
* Call during setup to instantiate a connection to Minim (the audio backend).
*
*
* @param s
*/
public static void assignApplet(SideScroller sideScroller) {
Expand All @@ -73,17 +72,15 @@ public static void assignApplet(SideScroller sideScroller) {
AudioSample sample = minim.loadSample(sfx.getPath());
if (sample != null) {
SFX_MAP.put(sfx, sample);
}
else {
} else {
System.err.println(sfx.getPath() + " not found.");
}
}
for (BGM bgm : BGM.values()) {
AudioPlayer audioPlayer = minim.loadFile(bgm.getPath());
if (audioPlayer != null) {
BGM_MAP.put(bgm, audioPlayer);
}
else {
} else {
System.err.println(bgm.getPath() + " not found.");
}
}
Expand All @@ -94,24 +91,23 @@ public static void assignApplet(SideScroller sideScroller) {
/**
* Play a sound effect once. Can be called again before the sound finishes
* playing.
*
*
* @param sound sound effect name
* @see #play(SFX, float)
* @see ddf.minim.AudioSample#trigger()
*/
public static void play(SFX sound) {
if (SFX_MAP.containsKey(sound)) {
SFX_MAP.get(sound).trigger();
}
else {
} else {
System.err.println(sound.getPath() + " not found.");
}
}

/**
* Plays a sound effect once (does not loop). Can be called again before the
* sound finishes playing. The sound effect gain is specified with this method.
*
*
* @param sound sound effect name
* @param gain gain, in decibels (where negative is quieter). Default = 0.
* @see #play(SFX)
Expand All @@ -121,8 +117,7 @@ public static void play(SFX sound, float gain) {
if (SFX_MAP.containsKey(sound)) {
SFX_MAP.get(sound).setGain(gain);
SFX_MAP.get(sound).trigger();
}
else {
} else {
System.err.println(sound.getPath() + " not found.");
}
}
Expand All @@ -131,7 +126,7 @@ public static void play(SFX sound, float gain) {
* Plays a background music track. Only one BGM track can play at once -- this
* method stops any existing BGM track if it is different. BGM tracks loop by
* default.
*
*
* @param sound BGM track
* @see #play(BGM, float)
*/
Expand All @@ -148,8 +143,7 @@ public static void play(BGM sound) {
if (BGM_MAP.containsKey(sound)) {
BGM_MAP.get(sound).setGain(gainBGM);
BGM_MAP.get(sound).loop();
}
else {
} else {
System.err.println(sound.getPath() + " not found.");
}
}
Expand All @@ -158,7 +152,7 @@ public static void play(BGM sound) {
* Plays a background music track at a specific gain (volume). Only one BGM
* track can play at once -- this method stops any existing BGM track. BGM
* tracks loop by default.
*
*
* @param sound BGM track
* @param gain gain, in decibels (where negative is quieter). Default = 0.
* @see #play(BGM)
Expand All @@ -167,15 +161,14 @@ public static void play(BGM sound, float gain) {
if (BGM_MAP.containsKey(sound)) {
BGM_MAP.get(sound).setGain(gain);
play(sound);
}
else {
} else {
System.err.println(sound.getPath() + " not found.");
}
}

/**
* Sets gain (volume) for background music.
*
*
* @param gain gain, in decibels (where negative is quieter). Default = 0.
*/
public static void setGainBGM(float gain) {
Expand All @@ -185,7 +178,7 @@ public static void setGainBGM(float gain) {

/**
* Sets gain (volume) for sound effects.
*
*
* @param gain gain, in decibels (where negative is quieter). Default = 0.
*/
public static void setGainSFX(float gain) {
Expand All @@ -212,7 +205,7 @@ public static void unMute() {
/**
* Stops Minim and releases all audio resources. Call when application is
* closed.
*
*
* @see Minim#stop()
*/
public static void exit() {
Expand Down
Loading

0 comments on commit c0556d8

Please sign in to comment.