changeset 301:00fab71b80ec livemode

More tweaking of frequencies
author Chris Cannam
date Mon, 01 Dec 2014 17:12:19 +0000
parents ba5f3b084466
children cac0be04c43c
files Makefile.linux src/LiveInstruments.cpp src/Silvet.cpp
diffstat 3 files changed, 37 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.linux	Fri Nov 28 18:15:44 2014 +0000
+++ b/Makefile.linux	Mon Dec 01 17:12:19 2014 +0000
@@ -1,12 +1,12 @@
 
-CFLAGS := -Wall -O3 -fopenmp -ffast-math -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC -I../vamp-plugin-sdk/ -DUSE_PTHREADS
+CFLAGS := -Wall -O3 -ffast-math -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC -I../vamp-plugin-sdk/ -DUSE_PTHREADS
 
 #CFLAGS := -g -fPIC -I../vamp-plugin-sdk
 
 CXXFLAGS := $(CFLAGS)
 
 VAMPSDK_DIR := ../vamp-plugin-sdk
-PLUGIN_LDFLAGS := -lgomp -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map -lpthread
+PLUGIN_LDFLAGS := -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map -lpthread
 
 PLUGIN_EXT := .so
 
--- a/src/LiveInstruments.cpp	Fri Nov 28 18:15:44 2014 +0000
+++ b/src/LiveInstruments.cpp	Mon Dec 01 17:12:19 2014 +0000
@@ -17,6 +17,8 @@
 
 #include "data/include/templates.h"
 
+#include <iostream>
+
 using namespace std;
 
 InstrumentPack
@@ -24,6 +26,8 @@
 {
     vector<InstrumentPack::Templates> templates;
 
+            cerr << "LiveAdapter: reduced template height is " << SILVET_TEMPLATE_HEIGHT/5 << endl;
+            
     for (vector<InstrumentPack::Templates>::const_iterator i =
 	     original.templates.begin();
 	 i != original.templates.end(); ++i) {
@@ -34,12 +38,22 @@
 	t.data.resize(i->data.size());
 
 	for (int j = 0; j < int(i->data.size()); ++j) {
+
 	    t.data[j].resize(SILVET_TEMPLATE_HEIGHT/5);
+
             float sum = 0.f;
+
 	    for (int k = 0; k < SILVET_TEMPLATE_HEIGHT/5; ++k) {
-		t.data[j][k] = i->data[j][k * 5 + 2 - SILVET_TEMPLATE_MAX_SHIFT];
+
+                t.data[j][k] = 0.f;
+
+                for (int m = 0; m < 5; ++m) {
+                    t.data[j][k] += i->data[j][k * 5 + m + 2];
+                }
+                
                 sum += t.data[j][k];
 	    }
+            
 	    // re-normalise
 	    for (int k = 0; k < (int)t.data[j].size(); ++k) {
                 t.data[j][k] *= 1.f / sum;
--- a/src/Silvet.cpp	Fri Nov 28 18:15:44 2014 +0000
+++ b/src/Silvet.cpp	Mon Dec 01 17:12:19 2014 +0000
@@ -351,7 +351,12 @@
             float((shiftCount - shift) - int(shiftCount / 2) - 1) / shiftCount;
     }
 
-    return float(27.5 * pow(2.0, (note + pshift) / 12.0));
+    float freq = float(27.5 * pow(2.0, (note + pshift) / 12.0));
+
+    cerr << "note = " << note << ", shift = " << shift << ", shiftCount = "
+         << shiftCount << ", obtained freq = " << freq << endl;
+    
+    return freq;
 }
 
 bool
@@ -402,6 +407,17 @@
     m_flattener = new FlattenDynamics(m_inputSampleRate); // before resampling
     m_flattener->reset();
 
+    // this happens to be processingSampleRate / 3, and is the top
+    // freq used for the EM templates:
+    double maxFreq = 14700;
+
+    if (m_mode == LiveMode) {
+        // We only have 12 bpo rather than 60, so we need the top bin
+        // to be the middle one of the top 5, i.e. 2/5 of a semitone
+        // lower than 14700
+        maxFreq *= powf(2.0, -1.0 / 30.0);
+    }
+    
     double minFreq = 27.5;
 
     if (m_mode != HighQualityMode) {
@@ -412,7 +428,7 @@
 
     int bpo = 12 *
         (m_mode == LiveMode ? binsPerSemitoneLive : binsPerSemitoneNormal);
-        
+
     CQParameters params(processingSampleRate,
                         minFreq, 
                         processingSampleRate / 3,
@@ -429,7 +445,8 @@
 
     m_cq = new CQSpectrogram(params, CQSpectrogram::InterpolateLinear);
 
-    cerr << "cq latency = " << m_cq->getLatency() << endl;
+    cerr << "CQ bins = " << m_cq->getTotalBins() << endl;
+    cerr << "CQ min freq = " << m_cq->getMinFrequency() << " (and for confirmation, freq of bin 0 = " << m_cq->getBinFrequency(0) << ")" << endl;
     
     m_colsPerSec = (m_mode == DraftMode ? 25 : 50);