summaryrefslogtreecommitdiffhomepage
path: root/tunerdemo.cpp
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2019-02-17 12:55:13 +0100
committerRoland Stigge <stigge@antcom.de>2019-02-17 12:55:13 +0100
commitfef594c82518a8fe4c96794852c1fc849c0ed3b3 (patch)
tree2efbedc8b126a77d91633ce8b9201dc4a7db764c /tunerdemo.cpp
parent1a219839034e9b11a4771fb84c90d4a2667365ce (diff)
Added tunerdemo
Diffstat (limited to 'tunerdemo.cpp')
-rw-r--r--tunerdemo.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tunerdemo.cpp b/tunerdemo.cpp
new file mode 100644
index 0000000..716bd8e
--- /dev/null
+++ b/tunerdemo.cpp
@@ -0,0 +1,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;
+}