-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundTester.java
More file actions
42 lines (36 loc) · 1.09 KB
/
Copy pathSoundTester.java
File metadata and controls
42 lines (36 loc) · 1.09 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
import javax.sound.midi.*;
/**
*
* @author togden
*/
public class SoundTester {
public static SoundSynthesizer audioSource;
private enum Direction { Down, Up };
public static void main(String[] args) {
playChordTab(-9999,7,9,9,8,7);
waitForMilliseconds(1000);
audioSource.closeSynthesizer();
}
/*
Doing this method without a for loop to make it easier for python to
pass the parameters in.
*/
public static void playChordTab(int e_, int a, int d, int g, int b, int e) {
if(audioSource==null) {
audioSource = new SoundSynthesizer();
}
int[] notes = new int[]{0,e,b,g,d,a,e_};
for(int i = 6; i>0; i--) {
if(notes[i]!=-9999) {
audioSource.playNote(Notes.openStrings[i] + notes[i], 80, 50);
}
}
waitForMilliseconds(1000);
}
public static void initSynthesizer() {
audioSource = new SoundSynthesizer();
}
public static void waitForMilliseconds(int time) {
audioSource.waitForMilliseconds(time);
}
}