-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmainwindow.cpp
55 lines (47 loc) · 1.4 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "spectrogram.h"
#include "qspectrogram.h"
#include "pulsethread.h"
#include <QDebug>
#include <QKeyEvent>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) {
spectrogram = new Spectrogram(44100, 44100 * 60, 256, 8192);
spectrogramWidget = new QSpectrogram(spectrogram, this);
setCentralWidget(spectrogramWidget);
resize(1024, 600);
QString device("alsa_output.pci-0000_00_1f.3.analog-stereo.monitor");
//device = "alsa_input.pci-0000_00_1f.3.analog-stereo";
pulseThread = new PulseThread(device, 44100, 1024);
pulseThread->start();
connect(pulseThread, SIGNAL(bufferFilled(float*,uint)),
spectrogramWidget, SLOT(processData(float*,uint)));
}
void
MainWindow::keyPressEvent(QKeyEvent *event) {
qDebug("keyPress %d", event->key());
switch (event->key()) {
case Qt::Key_F1:
spectrogramWidget->setMinAmpl(0.0001);
break;
case Qt::Key_F2:
spectrogramWidget->setMinAmpl(0.001);
break;
case Qt::Key_F3:
spectrogramWidget->setMinAmpl(0.01);
break;
case Qt::Key_F4:
spectrogramWidget->setMaxAmpl(0.1);
break;
case Qt::Key_F5:
spectrogramWidget->setMaxAmpl(1.0);
break;
case Qt::Key_F6:
spectrogramWidget->setMaxAmpl(10.0);
break;
}
}
MainWindow::~MainWindow() {
delete spectrogram;
spectrogram = 0;
}