-
Notifications
You must be signed in to change notification settings - Fork 1
/
Guituner.java
212 lines (187 loc) · 5.85 KB
/
Guituner.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import java.awt.EventQueue;
import javax.sound.sampled.LineUnavailableException;
import javax.swing.JFrame;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JTextPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import be.tarsos.dsp.AudioDispatcher;
import be.tarsos.dsp.AudioEvent;
//import be.tarsos.dsp.io.TarsosDSPAudioFormat;
import be.tarsos.dsp.io.jvm.AudioDispatcherFactory;
import be.tarsos.dsp.pitch.*;
import be.tarsos.dsp.pitch.PitchProcessor.PitchEstimationAlgorithm;
public class Guituner {
static float G4= (float) 391.9954;//4
static float C4= (float) 261.6256;//1
static float E4= (float) 329.6279;//2
static float A4= (float) 440.0000;//3
static float E2= (float) 82.4069;
static float A2= (float) 110.000;
static float D3= (float) 146.8324;
static float G3= (float) 195.9977;
static float B3= (float) 246.9417;
JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Guituner window = new Guituner();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
* @throws LineUnavailableException
*/
public Guituner() throws LineUnavailableException {
initialize();
frame.setVisible(true);
}
/**
* Initialize the contents of the frame.
*/
private void initialize() throws LineUnavailableException{
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
final JTextPane txtpnTestText = new JTextPane();
txtpnTestText.setText("");
txtpnTestText.setBounds(206, 99, 201, 47);
frame.getContentPane().add(txtpnTestText);
JButton btnTuneLowE = new JButton("Low E");
btnTuneLowE.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
tuneLowE window2 = new tuneLowE();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning low E");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnTuneLowE.setBounds(12, 13, 97, 25);
frame.getContentPane().add(btnTuneLowE);
JButton btnA = new JButton("A");
btnA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
TuneA window2 = new TuneA();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning A");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnA.setBounds(12, 51, 97, 25);
frame.getContentPane().add(btnA);
JButton btnD = new JButton("D");
btnD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
TuneD window2 = new TuneD();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning D");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnD.setBounds(12, 89, 97, 25);
frame.getContentPane().add(btnD);
JButton btnG = new JButton("G");
btnG.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
TuneG window2= new TuneG();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning G");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnG.setBounds(12, 126, 97, 25);
frame.getContentPane().add(btnG);
JButton btnB = new JButton("B");
btnB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
TuneB window2 = new TuneB();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning low B");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnB.setBounds(12, 164, 97, 25);
frame.getContentPane().add(btnB);
JButton btnHighE = new JButton("High e");
btnHighE.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
frame.dispose();
TuneHighE window2 = new TuneHighE();
window2.NewScreen();
frame.dispose();
//window2.frame.setVisible(true);
txtpnTestText.setText("tuning High E");
//driver.tuneLowE(txtpnTestText);
} catch (/*LineUnavailableException*/ Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
btnHighE.setBounds(12, 202, 97, 25);
frame.getContentPane().add(btnHighE);
JButton btnReturn = new JButton("Return");
btnReturn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frame.dispose();
MainMenu window = new MainMenu();
window.frame.setVisible(true);
frame.dispose();
}
});
btnReturn.setBounds(323, 215, 97, 25);
frame.getContentPane().add(btnReturn);
}
}