-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprecisetuner.cpp
More file actions
45 lines (34 loc) · 1.19 KB
/
precisetuner.cpp
File metadata and controls
45 lines (34 loc) · 1.19 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
#include "precisetuner.h"
#include "fft.h"
#include <math.h>
PreciseTuner::PreciseTuner()
{
recorder = new MicrophoneRec();
recorder->create_sound();
recorder->start_capturing();
autocorel = new AutoCorrelation();
QVBoxLayout *tunerLayout = new QVBoxLayout;
graph = new GraphFFT(this);
graph_wave = new GraphWave(this);
freqLabel = new QLabel("xD",this);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateGraph()));
timer->start(10); //rysuj co sekunde
updateGraph();
tunerLayout->addWidget(graph);
tunerLayout->addWidget(graph_wave);
tunerLayout->addWidget(freqLabel);
setLayout(tunerLayout);
setWindowTitle("Tuner");
resize(800, 650);
}
void PreciseTuner::updateGraph()
{
std::array<float, bufferSize> bufor = recorder->get_waveData();
graph->setData(bufor);
graph_wave->setData(bufor);
if(bufor[0] != 0 && bufor[2] != 0) //first loop makes array null o_O
autocorel->analyse(bufor, ceil(sampleRate/graph->baseFreq())/2 ); //TODO: ogranicznik FFT
//freqLabel->setText(QString::number(graph->baseFreq()));
freqLabel->setText(QString::number(autocorel->getFrequency()));
}