-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSound.java
More file actions
49 lines (38 loc) · 1.12 KB
/
Sound.java
File metadata and controls
49 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//import javax.sound.sampled.*;
import java.applet.Applet;
import java.applet.AudioClip;
import java.text.DecimalFormat;
public class Sound {
public static final int SONG_DEFAULT = 0;
public static final int SONG_WALZER = 1;
private static AudioClip song_default, sound_honk;
private static AudioClip[] sound_bump = new AudioClip[20];
public static void init(Applet applet) {
song_default = applet.getAudioClip(applet.getCodeBase(), "sounds/music.wav");
sound_honk = applet.getAudioClip(applet.getCodeBase(), "sounds/honk.wav");
DecimalFormat df = new DecimalFormat("00");
for (int i=0; i<=19; i++) {
sound_bump[i] = applet.getAudioClip(applet.getCodeBase(), "sounds/bump"+df.format(i)+".wav");
}
}
public static void start_music() {
song_default.loop();
}
public static void start_motor() {
}
public static void stop_motor() {
}
public static void change_song(int new_song) {
//if (new_song==SONG_WALZER) {
//}
}
public static void countdown() {
}
public static void bounce() {
int n = (int)(Math.random() * 20);
sound_bump[n].play();
}
public static void honk() {
sound_honk.play();
}
}