summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--audioio.cpp8
-rw-r--r--testsuite.cpp3
-rw-r--r--tuner.cpp3
-rw-r--r--tunerdemo.cpp4
-rw-r--r--util.cpp2
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<std::complex<double>> 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 <algorithm>
#include <cmath>
+#include <iostream>
using namespace RIT;
@@ -49,8 +50,10 @@ RIT::Pitch RIT::Tuner::operator() (const std::vector<std::complex<double>> &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<std::complex<double>> dataIn = audioIO.sample();
-
while (true) {
+ std::vector<std::complex<double>> 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 <algorithm>
+
bool RIT::is_power_of_two(unsigned int n) {
return n != 0 && (n & (n - 1)) == 0;
}