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