From fef594c82518a8fe4c96794852c1fc849c0ed3b3 Mon Sep 17 00:00:00 2001 From: Roland Stigge Date: Sun, 17 Feb 2019 12:55:13 +0100 Subject: Added tunerdemo --- tunerdemo.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tunerdemo.cpp (limited to 'tunerdemo.cpp') 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 +#include +#include + +using namespace std::chrono_literals; + +const int sampleFrequency = 44100; +const int fftSize = 4096; + +std::vector> sample() +{ + return std::vector>(fftSize, 0.0); +} + +int main(int argc, char* argv[]) { + RIT::Tuner tuner(fftSize, sampleFrequency); + + std::vector> 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; +} -- cgit v1.2.3