Use XMLNode::get/set_property API in ARDOUR::MidiModel class
[ardour.git] / libs / ardour / transient_detector.cc
index 41bb51f710275bbdeac69c74c7422eca3ffa7d93..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;
@@ -86,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);
        }
 }
 
@@ -119,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;
                }