diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-24 21:28:16 +0000 |
commit | 526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch) | |
tree | 22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/src/x_acoustics.c | |
parent | 4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff) | |
download | rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip |
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/x_acoustics.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/x_acoustics.c | 193 |
1 files changed, 0 insertions, 193 deletions
diff --git a/apps/plugins/pdbox/PDa/src/x_acoustics.c b/apps/plugins/pdbox/PDa/src/x_acoustics.c index 8fc04f77d1..9c5cd07495 100644 --- a/apps/plugins/pdbox/PDa/src/x_acoustics.c +++ b/apps/plugins/pdbox/PDa/src/x_acoustics.c | |||
@@ -190,197 +190,4 @@ void x_acoustics_setup(void) | |||
190 | class_addfloat(dbtorms_class, (t_method)dbtorms_float); | 190 | class_addfloat(dbtorms_class, (t_method)dbtorms_float); |
191 | class_sethelpsymbol(dbtorms_class, s); | 191 | class_sethelpsymbol(dbtorms_class, s); |
192 | } | 192 | } |
193 | |||
194 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
195 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
196 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
197 | |||
198 | /* utility functions for signals | ||
199 | */ | ||
200 | |||
201 | #include "m_pd.h" | ||
202 | #include <math.h> | ||
203 | #define LOGTEN 2.302585092994 | ||
204 | |||
205 | float mtof(float f) | ||
206 | { | ||
207 | if (f <= -1500) return(0); | ||
208 | else if (f > 1499) return(mtof(1499)); | ||
209 | else return (8.17579891564 * exp(.0577622650 * f)); | ||
210 | } | ||
211 | |||
212 | float ftom(float f) | ||
213 | { | ||
214 | return (f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); | ||
215 | } | ||
216 | |||
217 | float powtodb(float f) | ||
218 | { | ||
219 | if (f <= 0) return (0); | ||
220 | else | ||
221 | { | ||
222 | float val = 100 + 10./LOGTEN * log(f); | ||
223 | return (val < 0 ? 0 : val); | ||
224 | } | ||
225 | } | ||
226 | |||
227 | float rmstodb(float f) | ||
228 | { | ||
229 | if (f <= 0) return (0); | ||
230 | else | ||
231 | { | ||
232 | float val = 100 + 20./LOGTEN * log(f); | ||
233 | return (val < 0 ? 0 : val); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | float dbtopow(float f) | ||
238 | { | ||
239 | if (f <= 0) | ||
240 | return(0); | ||
241 | else | ||
242 | { | ||
243 | if (f > 870) | ||
244 | f = 870; | ||
245 | return (exp((LOGTEN * 0.1) * (f-100.))); | ||
246 | } | ||
247 | } | ||
248 | |||
249 | float dbtorms(float f) | ||
250 | { | ||
251 | if (f <= 0) | ||
252 | return(0); | ||
253 | else | ||
254 | { | ||
255 | if (f > 485) | ||
256 | f = 485; | ||
257 | } | ||
258 | return (exp((LOGTEN * 0.05) * (f-100.))); | ||
259 | } | ||
260 | |||
261 | /* ------------- corresponding objects ----------------------- */ | ||
262 | |||
263 | static t_class *mtof_class; | ||
264 | |||
265 | static void *mtof_new(void) | ||
266 | { | ||
267 | t_object *x = (t_object *)pd_new(mtof_class); | ||
268 | outlet_new(x, &s_float); | ||
269 | return (x); | ||
270 | } | ||
271 | |||
272 | static void mtof_float(t_object *x, t_float f) | ||
273 | { | ||
274 | outlet_float(x->ob_outlet, mtof(f)); | ||
275 | } | ||
276 | |||
277 | |||
278 | static t_class *ftom_class; | ||
279 | |||
280 | static void *ftom_new(void) | ||
281 | { | ||
282 | t_object *x = (t_object *)pd_new(ftom_class); | ||
283 | outlet_new(x, &s_float); | ||
284 | return (x); | ||
285 | } | ||
286 | 193 | ||
287 | static void ftom_float(t_object *x, t_float f) | ||
288 | { | ||
289 | outlet_float(x->ob_outlet, ftom(f)); | ||
290 | } | ||
291 | |||
292 | |||
293 | static t_class *rmstodb_class; | ||
294 | |||
295 | static void *rmstodb_new(void) | ||
296 | { | ||
297 | t_object *x = (t_object *)pd_new(rmstodb_class); | ||
298 | outlet_new(x, &s_float); | ||
299 | return (x); | ||
300 | } | ||
301 | |||
302 | static void rmstodb_float(t_object *x, t_float f) | ||
303 | { | ||
304 | outlet_float(x->ob_outlet, rmstodb(f)); | ||
305 | } | ||
306 | |||
307 | |||
308 | static t_class *powtodb_class; | ||
309 | |||
310 | static void *powtodb_new(void) | ||
311 | { | ||
312 | t_object *x = (t_object *)pd_new(powtodb_class); | ||
313 | outlet_new(x, &s_float); | ||
314 | return (x); | ||
315 | } | ||
316 | |||
317 | static void powtodb_float(t_object *x, t_float f) | ||
318 | { | ||
319 | outlet_float(x->ob_outlet, powtodb(f)); | ||
320 | } | ||
321 | |||
322 | |||
323 | static t_class *dbtopow_class; | ||
324 | |||
325 | static void *dbtopow_new(void) | ||
326 | { | ||
327 | t_object *x = (t_object *)pd_new(dbtopow_class); | ||
328 | outlet_new(x, &s_float); | ||
329 | return (x); | ||
330 | } | ||
331 | |||
332 | static void dbtopow_float(t_object *x, t_float f) | ||
333 | { | ||
334 | outlet_float(x->ob_outlet, dbtopow(f)); | ||
335 | } | ||
336 | |||
337 | |||
338 | static t_class *dbtorms_class; | ||
339 | |||
340 | static void *dbtorms_new(void) | ||
341 | { | ||
342 | t_object *x = (t_object *)pd_new(dbtorms_class); | ||
343 | outlet_new(x, &s_float); | ||
344 | return (x); | ||
345 | } | ||
346 | |||
347 | static void dbtorms_float(t_object *x, t_float f) | ||
348 | { | ||
349 | outlet_float(x->ob_outlet, dbtorms(f)); | ||
350 | } | ||
351 | |||
352 | |||
353 | void x_acoustics_setup(void) | ||
354 | { | ||
355 | t_symbol *s = gensym("acoustics.pd"); | ||
356 | mtof_class = class_new(gensym("mtof"), mtof_new, 0, | ||
357 | sizeof(t_object), 0, 0); | ||
358 | class_addfloat(mtof_class, (t_method)mtof_float); | ||
359 | class_sethelpsymbol(mtof_class, s); | ||
360 | |||
361 | ftom_class = class_new(gensym("ftom"), ftom_new, 0, | ||
362 | sizeof(t_object), 0, 0); | ||
363 | class_addfloat(ftom_class, (t_method)ftom_float); | ||
364 | class_sethelpsymbol(ftom_class, s); | ||
365 | |||
366 | powtodb_class = class_new(gensym("powtodb"), powtodb_new, 0, | ||
367 | sizeof(t_object), 0, 0); | ||
368 | class_addfloat(powtodb_class, (t_method)powtodb_float); | ||
369 | class_sethelpsymbol(powtodb_class, s); | ||
370 | |||
371 | rmstodb_class = class_new(gensym("rmstodb"), rmstodb_new, 0, | ||
372 | sizeof(t_object), 0, 0); | ||
373 | class_addfloat(rmstodb_class, (t_method)rmstodb_float); | ||
374 | class_sethelpsymbol(rmstodb_class, s); | ||
375 | |||
376 | dbtopow_class = class_new(gensym("dbtopow"), dbtopow_new, 0, | ||
377 | sizeof(t_object), 0, 0); | ||
378 | class_addfloat(dbtopow_class, (t_method)dbtopow_float); | ||
379 | class_sethelpsymbol(dbtopow_class, s); | ||
380 | |||
381 | dbtorms_class = class_new(gensym("dbtorms"), dbtorms_new, 0, | ||
382 | sizeof(t_object), 0, 0); | ||
383 | class_addfloat(dbtorms_class, (t_method)dbtorms_float); | ||
384 | class_sethelpsymbol(dbtorms_class, s); | ||
385 | } | ||
386 | |||