-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.java
executable file
·177 lines (147 loc) · 5.69 KB
/
Controller.java
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import javax.sound.midi.Sequence;
import java.io.*;
public class Controller {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Loading sound bank...");
//!!!!!!!!!!!!!! CHANGE THIS PATH !!!!!!!!!!!!!!!//
//LoadSoundBank.load("C:\\Documents and Settings\\Jeff\\workspace\\musicAI\\MusicAI\\soundbank-deluxe.gm"); //THIS NEEDS TO BE THE PATH WHERE THE MUSIC AI FILES ARE LOCATED
LoadSoundBank.load("/Users/jeff/AIMusic/soundbank-deluxe.gm"); //THIS NEEDS TO BE THE PATH WHERE THE MUSIC AI FILES ARE LOCATED
//!!!!!!!!!!!!!! CHANGE THIS PATH !!!!!!!!!!!!!!!//
// 1. Create an InputStreamReader using the standard input stream.
InputStreamReader isr = new InputStreamReader( System.in );
// 2. Create a BufferedReader using the InputStreamReader created.
BufferedReader stdin = new BufferedReader( isr );
Player myPlayer = new Player(true);
Sequence seq1 = null;
String choiceName="";
// System.out.println("Choose an algorithm to play: ");
// System.out.println("\t1. Random");
// System.out.println("\t2. Score");
// System.out.println("\t3. Score Multiple Agents");
// System.out.println("\t4. Second Score Multiple Agents");
// System.out.println("\t5. Second Score Multiple Agents With Chords");
// System.out.println("\t6. Second Score Multiple Agents With Beats");
System.out.println("\t7. Final");
// System.out.println("\t8. Modal");
// System.out.println("\t9. Beats");
// System.out.println("\t10. Agent");
// System.out.println("\t11. JonMoid");
// System.out.println("\t12. JonMoid2");
// System.out.println("\t13. Trance");
try{
// String temp = stdin.readLine();
// int choice = Integer.parseInt(temp);
int choice = 7;
// int numAgents = 1;
int numAgents = 6;
int numTicks = 4;
// choice = choice-48;
System.out.println("choice:" + choice);
// switch(choice){
// case 1:
// choiceName = "Random";
// break;
// case 2:
// choiceName ="Score";
// break;
// case 3:
// choiceName ="Score Multiple Agents";
// System.out.println("Enter the number of agents to use:");
// temp = stdin.readLine();
// numAgents = Integer.parseInt(temp);
// System.out.println("Enter the number of Ticks Per Measure (PPQ):");
// temp = stdin.readLine();
// numTicks = Integer.parseInt(temp);
// break;
// case 4:
// choiceName ="Second Score Multiple Agents";
// System.out.println("Enter the number of agents to use:");
// temp = stdin.readLine();
// numAgents = Integer.parseInt(temp);
// System.out.println("Enter the number of Ticks Per Measure (PPQ):");
// temp = stdin.readLine();
// numTicks = Integer.parseInt(temp);
// break;
// case 5:
// choiceName ="Second Score Multiple Agents With Chords";
// System.out.println("Enter the number of agents to use:");
// temp = stdin.readLine();
// numAgents = Integer.parseInt(temp);
// System.out.println("Enter the number of Ticks Per Measure (PPQ):");
// temp = stdin.readLine();
// numTicks = Integer.parseInt(temp);
// break;
// case 6:
// choiceName ="Second Score Multiple Agents With Beats";
// System.out.println("Enter the number of agents to use (at least 5):");
// temp = stdin.readLine();
// numAgents = Integer.parseInt(temp);
// System.out.println("Enter the number of Ticks Per Measure (PPQ):");
// temp = stdin.readLine();
// numTicks = Integer.parseInt(temp);
// break;
// case 7:
choiceName ="Final";
// System.out.println("Enter the number of agents to use:");
// temp = stdin.readLine();
// numAgents = Integer.parseInt(temp);
System.out.println("Enter the number of Ticks Per Measure (PPQ):");
String temp = stdin.readLine();
numTicks = Integer.parseInt(temp);
// break;
// case 8:
// choiceName ="Modal";
// break;
// case 9:
// choiceName ="Beats";
// System.out.println("Enter the number of Ticks Per Measure (PPQ):");
// temp = stdin.readLine();
// numTicks = Integer.parseInt(temp);
// break;
// case 10:
// choiceName ="Multiple Agents";
// break;
// case 11:
// choiceName ="JonMoid";
// break;
// case 12:
// choiceName ="JonMoid2";
// break;
// case 13:
// choiceName ="Trance";
// break;
//}
System.out.println(choiceName + " " + numAgents + " " + numTicks);
CreateSequence seqGetter = new CreateSequence(numAgents, numTicks);
seqGetter.run(choiceName); //start seqGetter //CHANGE IT BELOW TOO!
seq1 = seqGetter.getMySequence();
myPlayer.run(seq1);
// Seems to hang waiting for myPlayer to return, we don't want to wait for it
System.out.println("running seq");
// I NEED TO ADD TO THE TRACK CREATED WHEN THE SEQUENCE IS FIRST CREATED IN CREATE SEQUENCE, THE BBELOW WONT WORK
if(choice < 10 ){
for(int i=0; i<5; i++){ //play 50 sequences
System.out.println("Computing Next Sequence " + i);
try{
seqGetter.run(choiceName); //start seqGetter
System.out.println("Computing Next Sequence " + i);
seqGetter.join();
seq1 = seqGetter.getMySequence();
// Sequence t = myPlayer.sm_sequencer.getSequence().getTra
// myPlayer.sm_sequencer.getSequence().createTrack(seq1);
myPlayer.join();
myPlayer.run(seq1);
}catch(Exception e){
System.out.println("Thread Exception\n"+e.toString());
}
}//end for
}//end if
}
catch(Exception e){
System.out.println(e.toString());
}
}
}