enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / ardour / transient_detector.cc
index 51678286916c79885097ce3aa3f48feaf0398056..6eed8369a777c9c0ea4c19a8d2685f37999bb301 100644 (file)
@@ -22,7 +22,7 @@
 #include "ardour/readable.h"
 #include "ardour/transient_detector.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace Vamp;
 using namespace ARDOUR;
@@ -30,19 +30,11 @@ using namespace std;
 
 /* need a static initializer function for this */
 
-string TransientDetector::_op_id = X_("libardourvampplugins:qm-onsetdetector:2");
+string TransientDetector::_op_id = X_("qm-onset");
 
 TransientDetector::TransientDetector (float sr)
        : AudioAnalyser (sr, X_("libardourvampplugins:qm-onsetdetector"))
 {
-       /* update the op_id */
-
-       _op_id = X_("libardourvampplugins:qm-onsetdetector");
-
-       // XXX this should load the above-named plugin and get the current version
-
-       _op_id += ":2";
-
        threshold = 0.00;
 }
 
@@ -94,11 +86,15 @@ TransientDetector::set_threshold (float val)
 }
 
 void
-TransientDetector::set_sensitivity (float val)
+TransientDetector::set_sensitivity (uint32_t mode, float val)
 {
        if (plugin) {
-               plugin->selectProgram ("Percussive onsets");
-               plugin->setParameter ("sensitivity", val);
+               // see libs/vamp-plugins/OnsetDetect.cpp
+               //plugin->selectProgram ("General purpose"); // dftype = 3, sensitivity = 50, whiten = 0 (default)
+               //plugin->selectProgram ("Percussive onsets"); // dftype = 4, sensitivity = 40, whiten = 0
+               plugin->setParameter ("dftype", mode);
+               plugin->setParameter ("sensitivity", std::min (100.f, std::max (0.f, val)));
+               plugin->setParameter ("whiten", 0);
        }
 }
 
@@ -127,7 +123,7 @@ TransientDetector::cleanup_transients (AnalysisFeatureList& t, float sr, float g
 
                // move f until we find a new value that is far enough away
 
-               while ((f != t.end()) && (((*f) - (*i)) < gap_frames)) {
+               while ((f != t.end()) && gap_frames > 0 && (((*f) - (*i)) < gap_frames)) {
                        ++f;
                }