lots of small fixes related to the rythmic rodent
[ardour.git] / libs / ardour / transient_detector.cc
1 #include <ardour/transient_detector.h>
2
3 #include "i18n.h"
4
5 using namespace Vamp;
6 using namespace ARDOUR;
7 using namespace std;
8
9 TransientDetector::TransientDetector (float sr)
10         : AudioAnalyser (sr, X_("ardour-vamp-plugins:percussiononsets"))
11 {
12 }
13
14 TransientDetector::~TransientDetector()
15 {
16 }
17
18 int
19 TransientDetector::run (const std::string& path, boost::shared_ptr<Readable> src, uint32_t channel, vector<nframes64_t>& results)
20 {
21         current_results = &results;
22         int ret = analyse (path, src, channel);
23         current_results = 0;
24         return ret;
25 }
26
27 int
28 TransientDetector::use_features (Plugin::FeatureSet& features, ostream* out)
29 {
30         const Plugin::FeatureList& fl (features[0]);
31
32         for (Plugin::FeatureList::const_iterator f = fl.begin(); f != fl.end(); ++f) {
33                 
34                 if ((*f).hasTimestamp) {
35
36                         if (out) {
37                                 (*out) << (*f).timestamp.toString() << endl;
38                         } 
39
40                         current_results->push_back (RealTime::realTime2Frame ((*f).timestamp, sample_rate));
41                 }
42         }
43
44         return 0;
45 }
46
47 void
48 TransientDetector::set_threshold (float val)
49 {
50         if (plugin) {
51                 plugin->setParameter ("threshold", val);
52         }
53 }
54
55 void
56 TransientDetector::set_sensitivity (float val)
57 {
58         if (plugin) {
59                 plugin->setParameter ("sensitivity", val);
60         }
61 }