comparison base/AudioLevel.cpp @ 234:fd331fac5f38

...
author Chris Cannam
date Fri, 16 Feb 2007 15:04:23 +0000
parents 4b2ea82fd0ed
children 8133ae938704
comparison
equal deleted inserted replaced
233:0d943a3fcc77 234:fd331fac5f38
50 static const LevelList &getPreviewLevelCache(int levels); 50 static const LevelList &getPreviewLevelCache(int levels);
51 51
52 float 52 float
53 AudioLevel::multiplier_to_dB(float multiplier) 53 AudioLevel::multiplier_to_dB(float multiplier)
54 { 54 {
55 if (multiplier == 0.0) return DB_FLOOR; 55 if (multiplier == 0.f) return DB_FLOOR;
56 else if (multiplier < 0.f) return multiplier_to_dB(-multiplier);
56 float dB = 10 * log10f(multiplier); 57 float dB = 10 * log10f(multiplier);
57 return dB; 58 return dB;
58 } 59 }
59 60
60 float 61 float
229 230
230 int 231 int
231 AudioLevel::multiplier_to_preview(float m, int levels) 232 AudioLevel::multiplier_to_preview(float m, int levels)
232 { 233 {
233 assert(levels > 0); 234 assert(levels > 0);
235 return multiplier_to_fader(m, levels, PreviewLevel);
236
237 /* The original multiplier_to_preview which follows is not thread-safe.
238
234 if (m < 0.0) return -multiplier_to_preview(-m, levels); 239 if (m < 0.0) return -multiplier_to_preview(-m, levels);
235 240
236 const LevelList &ll = getPreviewLevelCache(levels); 241 const LevelList &ll = getPreviewLevelCache(levels);
237 int result = -1; 242 int result = -1;
238 243
257 lo = level; 262 lo = level;
258 } 263 }
259 } 264 }
260 265
261 return result; 266 return result;
267
268 */
262 } 269 }
263 270
264 float 271 float
265 AudioLevel::preview_to_multiplier(int level, int levels) 272 AudioLevel::preview_to_multiplier(int level, int levels)
266 { 273 {
267 assert(levels > 0); 274 assert(levels > 0);
275 return fader_to_multiplier(level, levels, PreviewLevel);
276 /*
268 if (level < 0) return -preview_to_multiplier(-level, levels); 277 if (level < 0) return -preview_to_multiplier(-level, levels);
269 const LevelList &ll = getPreviewLevelCache(levels); 278 const LevelList &ll = getPreviewLevelCache(levels);
270 return ll[level]; 279 return ll[level];
271 } 280 */
272 281 }
273 282
283