changeset 1:3fd1a41b089b

* Now displaying some output. Needs testing to see if bugs are present.
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Wed, 09 Jul 2014 10:26:51 +0100
parents 31d2a7e07786
children 1d0b7dcea27f
files Makefile Tempogram.cpp Tempogram.h
diffstat 3 files changed, 40 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Mon Jul 07 10:08:14 2014 +0100
+++ b/Makefile	Wed Jul 09 10:26:51 2014 +0100
@@ -30,7 +30,7 @@
 # Edit this to the location of the Vamp plugin SDK, relative to your
 # project directory
 #
-VAMP_SDK_DIR := /usr/local/bin
+VAMP_SDK_DIR := /usr/local/include
 
 
 ## Uncomment these for an OS/X universal binary (32- and 64-bit Intel)
@@ -38,7 +38,7 @@
 ## Xcode 4 command-line tools.
 
 CXX := g++
-CXXFLAGS := -mmacosx-version-min=10.5 -arch x86_64 -I$(VAMP_SDK_DIR) -Wall -fPIC
+CXXFLAGS := -arch x86_64 -I$(VAMP_SDK_DIR) -Wall -fPIC
 PLUGIN_EXT := .dylib
 LDFLAGS := $(CXXFLAGS) -dynamiclib -install_name $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) /usr/local/lib/libvamp-sdk.a -exported_symbols_list vamp-plugin.list
 
@@ -96,6 +96,9 @@
 
 $(PLUGIN_OBJECTS): $(PLUGIN_HEADERS)
 
+install: $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT)
+	cp $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) /Library/Audio/Plug-Ins/Vamp
+
 clean:
 	rm -f *.o *.dylib
 
--- a/Tempogram.cpp	Mon Jul 07 10:08:14 2014 +0100
+++ b/Tempogram.cpp	Wed Jul 09 10:26:51 2014 +0100
@@ -17,6 +17,7 @@
 Tempogram::Tempogram(float inputSampleRate) :
     Plugin(inputSampleRate),
     m_blockSize(0),
+    m_stepSize(0),
     compressionConstant(1000), //make param
     previousY(NULL),
     currentY(NULL),
@@ -97,7 +98,6 @@
 size_t 
 Tempogram::getPreferredStepSize() const
 {
-    //23 ms?
     return 0; // 0 means "anything sensible"; in practice this
               // means the same as the block size for TimeDomain
               // plugins, or half of it for FrequencyDomain plugins
@@ -174,7 +174,7 @@
 Tempogram::setParameter(string identifier, float value) 
 {
     if (identifier == "C") {
-        compressionConstant = value;// set the actual value of your parameter
+        compressionConstant = value; // set the actual value of your parameter
     }
     if (identifier == "tN") {
         tN = value;
@@ -210,21 +210,36 @@
 
     // See OutputDescriptor documentation for the possibilities here.
     // Every plugin must have at least one output.
-
+    
     OutputDescriptor d;
-    d.identifier = "output";
+    d.identifier = "tempogram";
     d.name = "Cyclic Tempogram";
     d.description = "Cyclic Tempogram";
     d.unit = "";
-    d.hasFixedBinCount = false;
-    //d.binCount = 1;
+    d.hasFixedBinCount = true;
+    d.binCount = tN;
     d.hasKnownExtents = false;
     d.isQuantized = false;
-    d.sampleType = OutputDescriptor::VariableSampleRate;
-    d.sampleRate = 0.0;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    float d_sampleRate = m_inputSampleRate/(m_stepSize * thopSize);
+    d.sampleRate = d_sampleRate > 0.0 && !isnan(d_sampleRate) ? d_sampleRate : 0.0;
     d.hasDuration = false;
     list.push_back(d);
 
+    d.identifier = "nc";
+    d.name = "Novelty Curve";
+    d.description = "Novelty Curve";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d_sampleRate = m_inputSampleRate/m_stepSize;
+    d.sampleRate = d_sampleRate > 0 && !isnan(d_sampleRate) ? d_sampleRate : 0.0;
+    d.hasDuration = false;
+    list.push_back(d);
+    
     return list;
 }
 
@@ -236,6 +251,7 @@
 
     // Real initialisation work goes here!
     m_blockSize = blockSize;
+    m_stepSize = stepSize;
     currentY = new float[m_blockSize];
     previousY = new float[m_blockSize];
     
@@ -255,7 +271,6 @@
     
     FeatureSet featureSet;
     Feature feature;
-    feature.hasTimestamp = false;
     
     const float *in = inputBuffers[0];
     
@@ -312,6 +327,7 @@
 {
     //Make sure this is called at the beginning of the function
     initialiseForGRF();
+    FeatureSet featureSet;
     
     vector<float> noveltyCurveLocalAverage(ncLength);
     
@@ -322,23 +338,23 @@
     for(int i = 0; i < ncLength; i++){
         noveltyCurve[i] -= noveltyCurveLocalAverage[i];
         noveltyCurve[i] = noveltyCurve[i] >= 0 ? noveltyCurve[i] : 0;
+        Feature ncFeature;
+        ncFeature.values.push_back(noveltyCurve[i]);
+        featureSet[1].push_back(ncFeature);
     }
     
     int i=0;
     WindowFunction::hanning(hannWindowtN, tN);
     
     int index;
-    int start = floor(tN/2 + 0.5);
+    int frameBeginOffset = floor(tN/2 + 0.5);
     int timestampInc = floor((((float)ncTimestamps[1].nsec - ncTimestamps[0].nsec)/1e9)*(thopSize) + 0.5);
     //cout << timestampInc << endl;
     
-    FeatureSet featureSet;
-    
     while(i < ncLength){
         Feature feature;
-        Vamp::RealTime timestamp;
         
-        for (int n = start; n < tN; n++){
+        for (int n = frameBeginOffset; n < tN; n++){
             index = i + n - tN/2;
             assert (index >= 0);
             
@@ -351,26 +367,24 @@
             //cout << fftInput[n] << endl;
         }
         if (i+tN/2 > ncLength){
-            timestamp = Vamp::RealTime::fromSeconds(ncTimestamps[i].sec + timestampInc);
+            feature.timestamp = Vamp::RealTime::fromSeconds(ncTimestamps[i].sec + timestampInc);
         }
         else{
-            timestamp = ncTimestamps[i + tN/2];
+            feature.timestamp = ncTimestamps[i + tN/2];
         }
         
         FFT::forward(tN, fftInput, NULL, fftOutputReal, fftOutputImag);
         
         //TODO: sample at logarithmic spacing
         for(int k = 0; k < tN; k++){
-            double fftOutputPower = (fftOutputReal[k]*fftOutputReal[k] + fftOutputImag[k]*fftOutputImag[k]); //Magnitude or power?
-            assert (!isinf(fftOutputPower));
+            float fftOutputPower = (fftOutputReal[k]*fftOutputReal[k] + fftOutputImag[k]*fftOutputImag[k]); //Magnitude or power?
             
             feature.values.push_back(fftOutputPower);
         }
 
         i += thopSize;
-        start = 0;
+        frameBeginOffset = 0;
         
-        feature.timestamp = timestamp;
         feature.hasTimestamp = true;
         featureSet[0].push_back(feature);
     }
--- a/Tempogram.h	Mon Jul 07 10:08:14 2014 +0100
+++ b/Tempogram.h	Wed Jul 09 10:26:51 2014 +0100
@@ -55,6 +55,7 @@
 protected:
     // plugin-specific data and methods go here
     size_t m_blockSize;
+    size_t m_stepSize;
     float compressionConstant;
     float *previousY;
     float *currentY;