-
Notifications
You must be signed in to change notification settings - Fork 0
/
Song.java
110 lines (91 loc) · 2.14 KB
/
Song.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
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.*;
class Song implements Serializable {
int id;
String title;
List<Voice> voices;
Voice currentVoice;
int tempo = -1;
int velocity = -50;
Song(int id, String title, List<Voice> voices) {
this.id = id;
this.title = title;
this.voices = voices;
}
String displaySingers()
{
StringBuilder singers = new StringBuilder();
for ( int cpt = 0; cpt < voices.size(); cpt++)
{
if (cpt == 0)
{
singers.append(voices.get(cpt).name);
}
else
{
singers.append(" & ").append(voices.get(cpt).name);
}
}
return singers.toString();
}
void sendSingers(PrintWriter output) {
output.println("\nLes chanteurs sont : ");
for (Voice v : voices)
{
output.println(v.id + " : " + v.name);
output.flush();
}
}
Voice getVoice(int id)
{
for(Voice v : voices)
{
if (v.id == id)
{
return v;
}
}
return null;
}
String updateVoice(String message){
try{
if (message.contains("V1"))
{
this.currentVoice = this.getVoice(1);
message = message.split("&")[1];
}
else if (message.contains("V2"))
{
this.currentVoice = this.getVoice(2);
message = message.split("&")[1];
}
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return message;
}
void updateParameters()
{
setTempo(-1);
setVelocity(-50);
for(Voice v : voices)
{
v.setEnable(true);
}
}
int getTempo() {
return tempo;
}
void setTempo(int tempo) {
this.tempo = tempo;
}
int getVelocity() {
return velocity;
}
void setVelocity(int velocity) {
this.velocity = velocity;
}
}