From 5bbc247ade4f6fc705269e3b0a8a8cae13eeef12 Mon Sep 17 00:00:00 2001 From: Roland Stigge Date: Mon, 18 Feb 2019 22:26:31 +0100 Subject: Bugfix --- TODO | 2 ++ audioio.cpp | 8 +++++--- testsuite.cpp | 3 +++ tuner.cpp | 3 +++ tunerdemo.cpp | 4 ++-- util.cpp | 2 ++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index dff5398..01fb917 100644 --- a/TODO +++ b/TODO @@ -7,3 +7,5 @@ debian tuner android + +pa_ringbuffer: better integration of debian SO diff --git a/audioio.cpp b/audioio.cpp index 31fa1cd..f24a0fd 100644 --- a/audioio.cpp +++ b/audioio.cpp @@ -24,10 +24,12 @@ class Callback: public portaudio::CallbackInterface { const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags ) override { - std::cout << "Callback" << std::endl; - float* buf = (float*)inputBuffer; + std::cout << "Callback " << std::endl; + for (int i = 0; i < framesPerBuffer; i++) { + //if (buf[i] > 0.1) + // std::cout << "DEBUG: " << buf[i] << std::endl; mBuffer[i] = buf[i]; } return 0; @@ -113,7 +115,7 @@ RIT::AudioIO::~AudioIO() std::vector> RIT::AudioIO::sample() { - return mImpl->mCallback.mBuffer; // TODO: thread synchronization! Ringbuffer? PaUtilRingBuffer? + return mImpl->mCallback.mBuffer; // TODO: thread synchronization! Ringbuffer } int RIT::AudioIO::size() const diff --git a/testsuite.cpp b/testsuite.cpp index f925b7e..09ac565 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -282,3 +282,6 @@ int main(int argc, char* argv[]) { return 0; } + +// TODO: +// -0.5 <= deviation <= 0.5 diff --git a/tuner.cpp b/tuner.cpp index 9e1f4b5..8276e90 100644 --- a/tuner.cpp +++ b/tuner.cpp @@ -6,6 +6,7 @@ #include #include +#include using namespace RIT; @@ -49,8 +50,10 @@ RIT::Pitch RIT::Tuner::operator() (const std::vector> &v) int index = maxElement - std::begin(autoCorrelation); + //std::cout << "DEBUG" << std::endl; if (autoCorrelation[index] > autoCorrelation[index - 1] && autoCorrelation[index] > autoCorrelation[index + 1]) { double f = double(mImpl->m_f_sample) / index; + //std::cout << "DEBUG f = " << f << std::endl; return getPitch(f); } diff --git a/tunerdemo.cpp b/tunerdemo.cpp index 9a1f70b..622fb02 100644 --- a/tunerdemo.cpp +++ b/tunerdemo.cpp @@ -15,9 +15,9 @@ int main(int argc, char* argv[]) { std::cout << "Tuner range: " << tuner.fMin() << " ... " << tuner.fMax() << " Hz" << std::endl; - std::vector> dataIn = audioIO.sample(); - while (true) { + std::vector> dataIn = audioIO.sample(); + auto start = std::chrono::high_resolution_clock::now(); RIT::Pitch pitch = tuner(dataIn); auto end = std::chrono::high_resolution_clock::now(); diff --git a/util.cpp b/util.cpp index 2a81823..d4616cf 100644 --- a/util.cpp +++ b/util.cpp @@ -1,5 +1,7 @@ #include "util.h" +#include + bool RIT::is_power_of_two(unsigned int n) { return n != 0 && (n & (n - 1)) == 0; } -- cgit v1.2.3