9
9
/**
10
10
* Provides static methods for playing game audio: background music and sound
11
11
* effects.
12
- *
12
+ *
13
13
* @author micycle1
14
14
*
15
15
*/
@@ -28,8 +28,7 @@ public final class Audio {
28
28
public enum BGM {
29
29
TEST0 ("first_theme.mp3" ), // TODO
30
30
TEST1 ("cyberSynthwave.mp3" ), // TODO
31
- TEST2 ("First_level_take_1.mp3" ),
32
- TEST3 ("Intro_Title_Pause_Screen_Take1_Loopable.mp3" );
31
+ TEST2 ("First_level_take_1.mp3" ), TEST3 ("Intro_Title_Pause_Screen_Take1_Loopable.mp3" );
33
32
34
33
private String filename ;
35
34
@@ -64,7 +63,7 @@ public String getPath() {
64
63
65
64
/**
66
65
* Call during setup to instantiate a connection to Minim (the audio backend).
67
- *
66
+ *
68
67
* @param s
69
68
*/
70
69
public static void assignApplet (SideScroller sideScroller ) {
@@ -73,17 +72,15 @@ public static void assignApplet(SideScroller sideScroller) {
73
72
AudioSample sample = minim .loadSample (sfx .getPath ());
74
73
if (sample != null ) {
75
74
SFX_MAP .put (sfx , sample );
76
- }
77
- else {
75
+ } else {
78
76
System .err .println (sfx .getPath () + " not found." );
79
77
}
80
78
}
81
79
for (BGM bgm : BGM .values ()) {
82
80
AudioPlayer audioPlayer = minim .loadFile (bgm .getPath ());
83
81
if (audioPlayer != null ) {
84
82
BGM_MAP .put (bgm , audioPlayer );
85
- }
86
- else {
83
+ } else {
87
84
System .err .println (bgm .getPath () + " not found." );
88
85
}
89
86
}
@@ -94,24 +91,23 @@ public static void assignApplet(SideScroller sideScroller) {
94
91
/**
95
92
* Play a sound effect once. Can be called again before the sound finishes
96
93
* playing.
97
- *
94
+ *
98
95
* @param sound sound effect name
99
96
* @see #play(SFX, float)
100
97
* @see ddf.minim.AudioSample#trigger()
101
98
*/
102
99
public static void play (SFX sound ) {
103
100
if (SFX_MAP .containsKey (sound )) {
104
101
SFX_MAP .get (sound ).trigger ();
105
- }
106
- else {
102
+ } else {
107
103
System .err .println (sound .getPath () + " not found." );
108
104
}
109
105
}
110
106
111
107
/**
112
108
* Plays a sound effect once (does not loop). Can be called again before the
113
109
* sound finishes playing. The sound effect gain is specified with this method.
114
- *
110
+ *
115
111
* @param sound sound effect name
116
112
* @param gain gain, in decibels (where negative is quieter). Default = 0.
117
113
* @see #play(SFX)
@@ -121,8 +117,7 @@ public static void play(SFX sound, float gain) {
121
117
if (SFX_MAP .containsKey (sound )) {
122
118
SFX_MAP .get (sound ).setGain (gain );
123
119
SFX_MAP .get (sound ).trigger ();
124
- }
125
- else {
120
+ } else {
126
121
System .err .println (sound .getPath () + " not found." );
127
122
}
128
123
}
@@ -131,7 +126,7 @@ public static void play(SFX sound, float gain) {
131
126
* Plays a background music track. Only one BGM track can play at once -- this
132
127
* method stops any existing BGM track if it is different. BGM tracks loop by
133
128
* default.
134
- *
129
+ *
135
130
* @param sound BGM track
136
131
* @see #play(BGM, float)
137
132
*/
@@ -148,8 +143,7 @@ public static void play(BGM sound) {
148
143
if (BGM_MAP .containsKey (sound )) {
149
144
BGM_MAP .get (sound ).setGain (gainBGM );
150
145
BGM_MAP .get (sound ).loop ();
151
- }
152
- else {
146
+ } else {
153
147
System .err .println (sound .getPath () + " not found." );
154
148
}
155
149
}
@@ -158,7 +152,7 @@ public static void play(BGM sound) {
158
152
* Plays a background music track at a specific gain (volume). Only one BGM
159
153
* track can play at once -- this method stops any existing BGM track. BGM
160
154
* tracks loop by default.
161
- *
155
+ *
162
156
* @param sound BGM track
163
157
* @param gain gain, in decibels (where negative is quieter). Default = 0.
164
158
* @see #play(BGM)
@@ -167,15 +161,14 @@ public static void play(BGM sound, float gain) {
167
161
if (BGM_MAP .containsKey (sound )) {
168
162
BGM_MAP .get (sound ).setGain (gain );
169
163
play (sound );
170
- }
171
- else {
164
+ } else {
172
165
System .err .println (sound .getPath () + " not found." );
173
166
}
174
167
}
175
168
176
169
/**
177
170
* Sets gain (volume) for background music.
178
- *
171
+ *
179
172
* @param gain gain, in decibels (where negative is quieter). Default = 0.
180
173
*/
181
174
public static void setGainBGM (float gain ) {
@@ -185,7 +178,7 @@ public static void setGainBGM(float gain) {
185
178
186
179
/**
187
180
* Sets gain (volume) for sound effects.
188
- *
181
+ *
189
182
* @param gain gain, in decibels (where negative is quieter). Default = 0.
190
183
*/
191
184
public static void setGainSFX (float gain ) {
@@ -212,7 +205,7 @@ public static void unMute() {
212
205
/**
213
206
* Stops Minim and releases all audio resources. Call when application is
214
207
* closed.
215
- *
208
+ *
216
209
* @see Minim#stop()
217
210
*/
218
211
public static void exit () {
0 commit comments