-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
44 lines (37 loc) · 1.26 KB
/
Main.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
import javax.swing.*;
import java.awt.*;
import java.io.File;
public class Main extends JFrame
{
private AudioStream audio;
private Compute compute;
public Main(String p, int mode)
{
if(mode == Compute.FOURIER)
compute = new FPitchDetect(p);
if(mode == Compute.AUTOCORRELATION)
compute = new ACPitchDetect(p);
new Thread(compute).start();
add(compute, BorderLayout.CENTER);
add(compute.getButtonPanel(), BorderLayout.NORTH);
audio = new AudioStream(compute);
new Thread(audio).start();
pack();
setBackground(Color.DARK_GRAY);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String args[])
{
JButton fileBtn = new JButton();
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File("~"));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
String path = null;
if(fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
path = fc.getSelectedFile().getAbsolutePath();
else
System.exit(0);
Main main = new Main(path, Compute.AUTOCORRELATION);
}
}