blob: 716bd8e8bde6f82e491a30d9af6482315d1773b9 (
plain)
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
|
#include "tuner.h"
#include <chrono>
#include <iostream>
#include <thread>
using namespace std::chrono_literals;
const int sampleFrequency = 44100;
const int fftSize = 4096;
std::vector<std::complex<double>> sample()
{
return std::vector<std::complex<double>>(fftSize, 0.0);
}
int main(int argc, char* argv[]) {
RIT::Tuner tuner(fftSize, sampleFrequency);
std::vector<std::complex<double>> dataIn = sample();
while (true) {
auto start = std::chrono::high_resolution_clock::now();
RIT::Pitch pitch = tuner(dataIn);
auto end = std::chrono::high_resolution_clock::now();
std::cout << "Detected Note: " << pitch.name
<< " Deviation: " << pitch.deviation
<< " Frequency: " << pitch.f
<< ", took " << std::chrono::nanoseconds(end - start).count() * 0.000001 << "ms"
<< std::endl;
std::this_thread::sleep_until(start + 100ms);
}
return 0;
}
|