comparison ConstrainedHarmonicPeak.cpp @ 0:f559ab000b67

Initial skeleton
author Chris Cannam
date Fri, 07 Mar 2014 14:34:50 +0000
parents
children ab0b04e1c56b
comparison
equal deleted inserted replaced
-1:000000000000 0:f559ab000b67
1
2 #include "ConstrainedHarmonicPeak.h"
3
4 #include <cmath>
5 #include <cstdio>
6
7 using std::cerr;
8 using std::endl;
9 using std::vector;
10
11 ConstrainedHarmonicPeak::ConstrainedHarmonicPeak(float inputSampleRate) :
12 Plugin(inputSampleRate),
13 m_blockSize(0),
14 m_minFreq(0),
15 m_maxFreq(inputSampleRate/2)
16 {
17 }
18
19 ConstrainedHarmonicPeak::~ConstrainedHarmonicPeak()
20 {
21 }
22
23 string
24 ConstrainedHarmonicPeak::getIdentifier() const
25 {
26 return "constrainedharmonicpeak";
27 }
28
29 string
30 ConstrainedHarmonicPeak::getName() const
31 {
32 return "Frequency-Constrained Harmonic Peak";
33 }
34
35 string
36 ConstrainedHarmonicPeak::getDescription() const
37 {
38 //!!! Return something helpful here!
39 return "";
40 }
41
42 string
43 ConstrainedHarmonicPeak::getMaker() const
44 {
45 return "Queen Mary, University of London";
46 }
47
48 int
49 ConstrainedHarmonicPeak::getPluginVersion() const
50 {
51 return 1;
52 }
53
54 string
55 ConstrainedHarmonicPeak::getCopyright() const
56 {
57 return "GPL";
58 }
59
60 ConstrainedHarmonicPeak::InputDomain
61 ConstrainedHarmonicPeak::getInputDomain() const
62 {
63 return FrequencyDomain;
64 }
65
66 size_t
67 ConstrainedHarmonicPeak::getPreferredBlockSize() const
68 {
69 return 2048;
70 }
71
72 size_t
73 ConstrainedHarmonicPeak::getPreferredStepSize() const
74 {
75 return 512;
76 }
77
78 size_t
79 ConstrainedHarmonicPeak::getMinChannelCount() const
80 {
81 return 1;
82 }
83
84 size_t
85 ConstrainedHarmonicPeak::getMaxChannelCount() const
86 {
87 return 1;
88 }
89
90 ConstrainedHarmonicPeak::ParameterList
91 ConstrainedHarmonicPeak::getParameterDescriptors() const
92 {
93 ParameterList list;
94
95 ParameterDescriptor d;
96 d.identifier = "minfreq";
97 d.name = "Minimum frequency";
98 d.description = "";
99 d.unit = "Hz";
100 d.minValue = 0;
101 d.maxValue = m_inputSampleRate/2;
102 d.defaultValue = 0;
103 d.isQuantized = false;
104 list.push_back(d);
105
106 d.identifier = "maxfreq";
107 d.name = "Maximum frequency";
108 d.description = "";
109 d.unit = "Hz";
110 d.minValue = 0;
111 d.maxValue = m_inputSampleRate/2;
112 d.defaultValue = 0;
113 d.isQuantized = false;
114 list.push_back(d);
115
116 return list;
117 }
118
119 float
120 ConstrainedHarmonicPeak::getParameter(string identifier) const
121 {
122 if (identifier == "minfreq") {
123 return m_minFreq;
124 } else if (identifier == "maxfreq") {
125 return m_maxFreq;
126 }
127 return 0;
128 }
129
130 void
131 ConstrainedHarmonicPeak::setParameter(string identifier, float value)
132 {
133 if (identifier == "minfreq") {
134 m_minFreq = value;
135 } else if (identifier == "maxfreq") {
136 m_maxFreq = value;
137 }
138 }
139
140 ConstrainedHarmonicPeak::ProgramList
141 ConstrainedHarmonicPeak::getPrograms() const
142 {
143 ProgramList list;
144 return list;
145 }
146
147 string
148 ConstrainedHarmonicPeak::getCurrentProgram() const
149 {
150 return ""; // no programs
151 }
152
153 void
154 ConstrainedHarmonicPeak::selectProgram(string name)
155 {
156 }
157
158 ConstrainedHarmonicPeak::OutputList
159 ConstrainedHarmonicPeak::getOutputDescriptors() const
160 {
161 OutputList list;
162
163 OutputDescriptor d;
164 d.identifier = "peak";
165 d.name = "Peak frequency";
166 d.description = "";
167 d.unit = "Hz";
168 d.sampleType = OutputDescriptor::OneSamplePerStep;
169 d.hasDuration = false;
170 list.push_back(d);
171
172 return list;
173 }
174
175 bool
176 ConstrainedHarmonicPeak::initialise(size_t channels, size_t stepSize, size_t blockSize)
177 {
178 if (channels < getMinChannelCount() ||
179 channels > getMaxChannelCount()) {
180 cerr << "ConstrainedHarmonicPeak::initialise: ERROR: channels " << channels
181 << " out of acceptable range " << getMinChannelCount()
182 << " -> " << getMaxChannelCount() << endl;
183 return false;
184 }
185
186 m_blockSize = blockSize;
187
188 return true;
189 }
190
191 void
192 ConstrainedHarmonicPeak::reset()
193 {
194 }
195
196 ConstrainedHarmonicPeak::FeatureSet
197 ConstrainedHarmonicPeak::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
198 {
199 FeatureSet fs;
200
201 return fs;
202 }
203
204 ConstrainedHarmonicPeak::FeatureSet
205 ConstrainedHarmonicPeak::getRemainingFeatures()
206 {
207 FeatureSet fs;
208
209 return fs;
210 }
211