Mercurial > hg > beatroot-vamp
comparison BeatRootVampPlugin.cpp @ 23:633ec097fa56
Expose the processing parameters Simon suggests
author | Chris Cannam |
---|---|
date | Tue, 03 Sep 2013 17:32:09 +0100 |
parents | 6afcb5edd7ab |
children | b9c2f444cdaa |
comparison
equal
deleted
inserted
replaced
22:6afcb5edd7ab | 23:633ec097fa56 |
---|---|
22 #include <vamp-sdk/PluginAdapter.h> | 22 #include <vamp-sdk/PluginAdapter.h> |
23 | 23 |
24 BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) : | 24 BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) : |
25 Plugin(inputSampleRate) | 25 Plugin(inputSampleRate) |
26 { | 26 { |
27 m_processor = new BeatRootProcessor(inputSampleRate); | 27 m_processor = new BeatRootProcessor(inputSampleRate, AgentParameters()); |
28 } | 28 } |
29 | 29 |
30 BeatRootVampPlugin::~BeatRootVampPlugin() | 30 BeatRootVampPlugin::~BeatRootVampPlugin() |
31 { | 31 { |
32 delete m_processor; | 32 delete m_processor; |
102 | 102 |
103 BeatRootVampPlugin::ParameterList | 103 BeatRootVampPlugin::ParameterList |
104 BeatRootVampPlugin::getParameterDescriptors() const | 104 BeatRootVampPlugin::getParameterDescriptors() const |
105 { | 105 { |
106 ParameterList list; | 106 ParameterList list; |
107 | |
108 ParameterDescriptor desc; | |
109 | |
110 double postMarginFactor; | |
111 | |
112 /** The maximum amount by which a beat can be earlier than the | |
113 * predicted beat time, expressed as a fraction of the beat | |
114 * period. */ | |
115 double preMarginFactor; | |
116 | |
117 /** The maximum allowed deviation from the initial tempo, | |
118 * expressed as a fraction of the initial beat period. */ | |
119 double maxChange; | |
120 | |
121 /** The default value of expiryTime, which is the time (in | |
122 * seconds) after which an Agent that has no Event matching its | |
123 * beat predictions will be destroyed. */ | |
124 | |
125 desc.identifier = "preMarginFactor"; | |
126 desc.name = "Pre-Margin Factor"; | |
127 desc.description = "The maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period."; | |
128 desc.minValue = 0; | |
129 desc.maxValue = 1; | |
130 desc.defaultValue = AgentParameters::DEFAULT_PRE_MARGIN_FACTOR; | |
131 desc.isQuantized = false; | |
132 list.push_back(desc); | |
133 | |
134 desc.identifier = "postMarginFactor"; | |
135 desc.name = "Post-Margin Factor"; | |
136 desc.description = "The maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period."; | |
137 desc.minValue = 0; | |
138 desc.maxValue = 1; | |
139 desc.defaultValue = AgentParameters::DEFAULT_POST_MARGIN_FACTOR; | |
140 desc.isQuantized = false; | |
141 list.push_back(desc); | |
142 | |
143 desc.identifier = "maxChange"; | |
144 desc.name = "Maximum Change"; | |
145 desc.description = "The maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period."; | |
146 desc.minValue = 0; | |
147 desc.maxValue = 1; | |
148 desc.defaultValue = AgentParameters::DEFAULT_MAX_CHANGE; | |
149 desc.isQuantized = false; | |
150 list.push_back(desc); | |
151 | |
152 desc.identifier = "expiryTime"; | |
153 desc.name = "Expiry Time"; | |
154 desc.description = "The default value of expiryTime, which is the time (in seconds) after which an Agent that has no Event matching its beat predictions will be destroyed."; | |
155 desc.minValue = 2; | |
156 desc.maxValue = 120; | |
157 desc.defaultValue = AgentParameters::DEFAULT_EXPIRY_TIME; | |
158 desc.isQuantized = false; | |
159 list.push_back(desc); | |
160 | |
161 // Simon says... | |
162 | |
163 // These are the parameters that should be exposed (Agent.cpp): | |
164 | |
165 // If Pop, both margins should be lower (0.1). If classical | |
166 // music, post margin can be increased | |
167 // | |
168 // double Agent::POST_MARGIN_FACTOR = 0.3; | |
169 // double Agent::PRE_MARGIN_FACTOR = 0.15; | |
170 // | |
171 // Max Change tells us how much tempo can change - so for | |
172 // classical we should make it higher | |
173 // | |
174 // double Agent::MAX_CHANGE = 0.2; | |
175 // | |
176 // The EXPIRY TIME default should be defaulted to 100 (usual cause | |
177 // of agents dying....) it should also be exposed in order to | |
178 // troubleshoot eventual problems in songs with big silences in | |
179 // the beggining/end. | |
180 // | |
181 // const double Agent::DEFAULT_EXPIRY_TIME = 10.0; | |
182 | |
107 return list; | 183 return list; |
108 } | 184 } |
109 | 185 |
110 float | 186 float |
111 BeatRootVampPlugin::getParameter(string identifier) const | 187 BeatRootVampPlugin::getParameter(string identifier) const |
112 { | 188 { |
189 if (identifier == "preMarginFactor") { | |
190 return m_parameters.preMarginFactor; | |
191 } else if (identifier == "postMarginFactor") { | |
192 return m_parameters.postMarginFactor; | |
193 } else if (identifier == "maxChange") { | |
194 return m_parameters.maxChange; | |
195 } else if (identifier == "expiryTime") { | |
196 return m_parameters.expiryTime; | |
197 } | |
198 | |
113 return 0; | 199 return 0; |
114 } | 200 } |
115 | 201 |
116 void | 202 void |
117 BeatRootVampPlugin::setParameter(string identifier, float value) | 203 BeatRootVampPlugin::setParameter(string identifier, float value) |
118 { | 204 { |
205 if (identifier == "preMarginFactor") { | |
206 m_parameters.preMarginFactor = value; | |
207 } else if (identifier == "postMarginFactor") { | |
208 m_parameters.postMarginFactor = value; | |
209 } else if (identifier == "maxChange") { | |
210 m_parameters.maxChange = value; | |
211 } else if (identifier == "expiryTime") { | |
212 m_parameters.expiryTime = value; | |
213 } | |
119 } | 214 } |
120 | 215 |
121 BeatRootVampPlugin::ProgramList | 216 BeatRootVampPlugin::ProgramList |
122 BeatRootVampPlugin::getPrograms() const | 217 BeatRootVampPlugin::getPrograms() const |
123 { | 218 { |
185 << getPreferredBlockSize() << " for rate " << m_inputSampleRate | 280 << getPreferredBlockSize() << " for rate " << m_inputSampleRate |
186 << ")" << std::endl; | 281 << ")" << std::endl; |
187 return false; | 282 return false; |
188 } | 283 } |
189 | 284 |
190 m_processor->reset(); | 285 // Delete the processor that was created with default parameters |
286 // and used to determine the expected step and block size; replace | |
287 // with one using the actual parameters we have | |
288 delete m_processor; | |
289 m_processor = new BeatRootProcessor(m_inputSampleRate, m_parameters); | |
191 | 290 |
192 return true; | 291 return true; |
193 } | 292 } |
194 | 293 |
195 void | 294 void |