comparison plugin/LADSPAPluginFactory.cpp @ 383:94fc0591ea43 1.2-stable

* merge from trunk (1.2 ended up being tracked from trunk, but we may want this branch for fixes later)
author Chris Cannam
date Wed, 27 Feb 2008 10:32:45 +0000
parents d4a33cdca86f
children
comparison
equal deleted inserted replaced
349:f39d33b0b265 383:94fc0591ea43
159 159
160 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { 160 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
161 minimum *= m_sampleRate; 161 minimum *= m_sampleRate;
162 } 162 }
163 163
164 if (LADSPA_IS_HINT_LOGARITHMIC(d)) {
165 if (minimum == 0.f) minimum = 1.f;
166 }
167
164 return minimum; 168 return minimum;
165 } 169 }
166 170
167 float 171 float
168 LADSPAPluginFactory::getPortMaximum(const LADSPA_Descriptor *descriptor, int port) 172 LADSPAPluginFactory::getPortMaximum(const LADSPA_Descriptor *descriptor, int port)
209 LADSPA_PortRangeHintDescriptor d = 213 LADSPA_PortRangeHintDescriptor d =
210 descriptor->PortRangeHints[port].HintDescriptor; 214 descriptor->PortRangeHints[port].HintDescriptor;
211 215
212 bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC(d); 216 bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC(d);
213 217
218 float logmin = 0, logmax = 0;
219 if (logarithmic) {
220 float thresh = powf(10, -10);
221 if (minimum < thresh) logmin = -10;
222 else logmin = log10f(minimum);
223 if (maximum < thresh) logmax = -10;
224 else logmax = log10f(maximum);
225 }
226
227 // std::cerr << "LADSPAPluginFactory::getPortDefault: hint = " << d << std::endl;
228
214 if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) { 229 if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) {
215 230
216 deft = minimum; 231 deft = minimum;
217 232
218 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(d)) { 233 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(d)) {
220 deft = minimum; 235 deft = minimum;
221 236
222 } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) { 237 } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) {
223 238
224 if (logarithmic) { 239 if (logarithmic) {
225 deft = powf(10, log10(minimum) * 0.75 + 240 deft = powf(10, logmin * 0.75 + logmax * 0.25);
226 log10(maximum) * 0.25);
227 } else { 241 } else {
228 deft = minimum * 0.75 + maximum * 0.25; 242 deft = minimum * 0.75 + maximum * 0.25;
229 } 243 }
230 244
231 } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) { 245 } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) {
232 246
233 if (logarithmic) { 247 if (logarithmic) {
234 deft = powf(10, log10(minimum) * 0.5 + 248 deft = powf(10, logmin * 0.5 + logmax * 0.5);
235 log10(maximum) * 0.5);
236 } else { 249 } else {
237 deft = minimum * 0.5 + maximum * 0.5; 250 deft = minimum * 0.5 + maximum * 0.5;
238 } 251 }
239 252
240 } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) { 253 } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) {
241 254
242 if (logarithmic) { 255 if (logarithmic) {
243 deft = powf(10, log10(minimum) * 0.25 + 256 deft = powf(10, logmin * 0.25 + logmax * 0.75);
244 log10(maximum) * 0.75);
245 } else { 257 } else {
246 deft = minimum * 0.25 + maximum * 0.75; 258 deft = minimum * 0.25 + maximum * 0.75;
247 } 259 }
248 260
249 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) { 261 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) {
269 281
270 } else { 282 } else {
271 283
272 deft = minimum; 284 deft = minimum;
273 } 285 }
274 286
275 if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { 287 //!!! No -- the min and max have already been multiplied by the rate,
276 deft *= m_sampleRate; 288 //so it would happen twice if we did it here -- and e.g. DEFAULT_440
277 } 289 //doesn't want to be multiplied by the rate either
290
291 // if (LADSPA_IS_HINT_SAMPLE_RATE(d)) {
292 // deft *= m_sampleRate;
293 // }
278 294
279 return deft; 295 return deft;
280 } 296 }
281 297
282 float 298 float