forked from martinmarinov/TempestSDR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
65 lines (50 loc) · 1.52 KB
/
Copy pathMain.java
File metadata and controls
65 lines (50 loc) · 1.52 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package martin.tempest;
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import martin.tempest.core.TSDRLibrary;
import martin.tempest.core.exceptions.TSDRException;
public class Main implements TSDRLibrary.FrameReadyCallback {
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private final ImageVisualizer viz = new ImageVisualizer();
private JFrame frame;
public static void main(String[] args) {
try {
new Main();
} catch(Exception e) {
System.err.println("Cannot load! Reason: "+e.getLocalizedMessage());
e.printStackTrace();
}
}
public Main() throws TSDRException {
frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(viz, BorderLayout.CENTER);
frame.setSize(WIDTH,HEIGHT);
frame.setVisible(true);
new Thread() {
public void run() {
try {
TSDRLibrary sdrlib = new TSDRLibrary(TSDRLibrary.getAllSources()[0], WIDTH, HEIGHT);
sdrlib.registerFrameReadyCallback(Main.this);
sdrlib.startAsync();
} catch (Throwable e) {e.printStackTrace();};
};
}.start();
}
@Override
public void onFrameReady(TSDRLibrary lib, BufferedImage frame) {
viz.drawImage(frame);
try { lib.setSampleRate(0); } catch (Exception e) {};
}
@Override
public void onException(TSDRLibrary lib, Exception e) {
e.printStackTrace();
}
@Override
public void onClosed(TSDRLibrary lib) {
System.out.println("Closed");
}
}