A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/* Copyright (c) 1997-1999 Miller Puckette.
2* For information on usage and redistribution, and for a DISCLAIMER OF ALL
3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4
5/* arithmetic: binops ala C language. The 4 functions and relationals are
6done on floats; the logical and bitwise binops convert their
7inputs to int and their outputs back to float. */
8
9#ifdef ROCKBOX
10#include "plugin.h"
11#include "../../pdbox.h"
12#endif
13
14#include "m_pd.h"
15#include "../../math.h"
16
17
18/* MSW and OSX don't appear to have single-precision ANSI math */
19
20#define sinf sin
21#define cosf cos
22#define atanf atan
23#define atan2f atan2
24#define sqrtf sqrt
25#define logf log
26#define expf exp
27#define fabsf fabs
28#define powf pow
29
30
31typedef struct _binop
32{
33 t_object x_obj;
34 t_float x_f1;
35 t_float x_f2;
36} t_binop;
37
38/* ------------------ binop1: +, -, *, / ----------------------------- */
39
40static void *binop1_new(t_class *floatclass, t_floatarg f)
41{
42 t_binop *x = (t_binop *)pd_new(floatclass);
43 outlet_new(&x->x_obj, &s_float);
44 floatinlet_new(&x->x_obj, &x->x_f2);
45 x->x_f1 = 0;
46 x->x_f2 = f;
47 return (x);
48}
49
50/* --------------------- addition ------------------------------- */
51
52static t_class *binop1_plus_class;
53
54static void *binop1_plus_new(t_floatarg f)
55{
56 return (binop1_new(binop1_plus_class, f));
57}
58
59static void binop1_plus_bang(t_binop *x)
60{
61 outlet_float(x->x_obj.ob_outlet, x->x_f1 + x->x_f2);
62}
63
64static void binop1_plus_float(t_binop *x, t_float f)
65{
66 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) + x->x_f2);
67}
68
69/* --------------------- subtraction ------------------------------- */
70
71static t_class *binop1_minus_class;
72
73static void *binop1_minus_new(t_floatarg f)
74{
75 return (binop1_new(binop1_minus_class, f));
76}
77
78static void binop1_minus_bang(t_binop *x)
79{
80 outlet_float(x->x_obj.ob_outlet, x->x_f1 - x->x_f2);
81}
82
83static void binop1_minus_float(t_binop *x, t_float f)
84{
85 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) - x->x_f2);
86}
87
88/* --------------------- multiplication ------------------------------- */
89
90static t_class *binop1_times_class;
91
92static void *binop1_times_new(t_floatarg f)
93{
94 return (binop1_new(binop1_times_class, f));
95}
96
97static void binop1_times_bang(t_binop *x)
98{
99 outlet_float(x->x_obj.ob_outlet, x->x_f1 * x->x_f2);
100}
101
102static void binop1_times_float(t_binop *x, t_float f)
103{
104 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) * x->x_f2);
105}
106
107/* --------------------- division ------------------------------- */
108
109static t_class *binop1_div_class;
110
111static void *binop1_div_new(t_floatarg f)
112{
113 return (binop1_new(binop1_div_class, f));
114}
115
116static void binop1_div_bang(t_binop *x)
117{
118 outlet_float(x->x_obj.ob_outlet,
119 (x->x_f2 != 0 ? x->x_f1 / x->x_f2 : 0));
120}
121
122static void binop1_div_float(t_binop *x, t_float f)
123{
124 x->x_f1 = f;
125 outlet_float(x->x_obj.ob_outlet,
126 (x->x_f2 != 0 ? x->x_f1 / x->x_f2 : 0));
127}
128
129/* ------------------------ pow -------------------------------- */
130
131static t_class *binop1_pow_class;
132
133static void *binop1_pow_new(t_floatarg f)
134{
135 return (binop1_new(binop1_pow_class, f));
136}
137
138static void binop1_pow_bang(t_binop *x)
139{
140 outlet_float(x->x_obj.ob_outlet,
141 (x->x_f1 > 0 ? powf(x->x_f1, x->x_f2) : 0));
142}
143
144static void binop1_pow_float(t_binop *x, t_float f)
145{
146 x->x_f1 = f;
147 outlet_float(x->x_obj.ob_outlet,
148 (x->x_f1 > 0 ? powf(x->x_f1, x->x_f2) : 0));
149}
150
151/* ------------------------ max -------------------------------- */
152
153static t_class *binop1_max_class;
154
155static void *binop1_max_new(t_floatarg f)
156{
157 return (binop1_new(binop1_max_class, f));
158}
159
160static void binop1_max_bang(t_binop *x)
161{
162 outlet_float(x->x_obj.ob_outlet,
163 (x->x_f1 > x->x_f2 ? x->x_f1 : x->x_f2));
164}
165
166static void binop1_max_float(t_binop *x, t_float f)
167{
168 x->x_f1 = f;
169 outlet_float(x->x_obj.ob_outlet,
170 (x->x_f1 > x->x_f2 ? x->x_f1 : x->x_f2));
171}
172
173/* ------------------------ min -------------------------------- */
174
175static t_class *binop1_min_class;
176
177static void *binop1_min_new(t_floatarg f)
178{
179 return (binop1_new(binop1_min_class, f));
180}
181
182static void binop1_min_bang(t_binop *x)
183{
184 outlet_float(x->x_obj.ob_outlet,
185 (x->x_f1 < x->x_f2 ? x->x_f1 : x->x_f2));
186}
187
188static void binop1_min_float(t_binop *x, t_float f)
189{
190 x->x_f1 = f;
191 outlet_float(x->x_obj.ob_outlet,
192 (x->x_f1 < x->x_f2 ? x->x_f1 : x->x_f2));
193}
194
195/* ------------------ binop2: ==, !=, >, <, >=, <=. -------------------- */
196
197static void *binop2_new(t_class *floatclass, t_floatarg f)
198{
199 t_binop *x = (t_binop *)pd_new(floatclass);
200 outlet_new(&x->x_obj, &s_float);
201 floatinlet_new(&x->x_obj, &x->x_f2);
202 x->x_f1 = 0;
203 x->x_f2 = f;
204 return (x);
205}
206
207/* --------------------- == ------------------------------- */
208
209static t_class *binop2_ee_class;
210
211static void *binop2_ee_new(t_floatarg f)
212{
213 return (binop2_new(binop2_ee_class, f));
214}
215
216static void binop2_ee_bang(t_binop *x)
217{
218 outlet_float(x->x_obj.ob_outlet, x->x_f1 == x->x_f2);
219}
220
221static void binop2_ee_float(t_binop *x, t_float f)
222{
223 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) == x->x_f2);
224}
225
226/* --------------------- != ------------------------------- */
227
228static t_class *binop2_ne_class;
229
230static void *binop2_ne_new(t_floatarg f)
231{
232 return (binop2_new(binop2_ne_class, f));
233}
234
235static void binop2_ne_bang(t_binop *x)
236{
237 outlet_float(x->x_obj.ob_outlet, x->x_f1 != x->x_f2);
238}
239
240static void binop2_ne_float(t_binop *x, t_float f)
241{
242 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) != x->x_f2);
243}
244
245/* --------------------- > ------------------------------- */
246
247static t_class *binop2_gt_class;
248
249static void *binop2_gt_new(t_floatarg f)
250{
251 return (binop2_new(binop2_gt_class, f));
252}
253
254static void binop2_gt_bang(t_binop *x)
255{
256 outlet_float(x->x_obj.ob_outlet, x->x_f1 > x->x_f2);
257}
258
259static void binop2_gt_float(t_binop *x, t_float f)
260{
261 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) > x->x_f2);
262}
263
264/* --------------------- < ------------------------------- */
265
266static t_class *binop2_lt_class;
267
268static void *binop2_lt_new(t_floatarg f)
269{
270 return (binop2_new(binop2_lt_class, f));
271}
272
273static void binop2_lt_bang(t_binop *x)
274{
275 outlet_float(x->x_obj.ob_outlet, x->x_f1 < x->x_f2);
276}
277
278static void binop2_lt_float(t_binop *x, t_float f)
279{
280 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) < x->x_f2);
281}
282
283/* --------------------- >= ------------------------------- */
284
285static t_class *binop2_ge_class;
286
287static void *binop2_ge_new(t_floatarg f)
288{
289 return (binop2_new(binop2_ge_class, f));
290}
291
292static void binop2_ge_bang(t_binop *x)
293{
294 outlet_float(x->x_obj.ob_outlet, x->x_f1 >= x->x_f2);
295}
296
297static void binop2_ge_float(t_binop *x, t_float f)
298{
299 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) >= x->x_f2);
300}
301
302/* --------------------- <= ------------------------------- */
303
304static t_class *binop2_le_class;
305
306static void *binop2_le_new(t_floatarg f)
307{
308 return (binop2_new(binop2_le_class, f));
309}
310
311static void binop2_le_bang(t_binop *x)
312{
313 outlet_float(x->x_obj.ob_outlet, x->x_f1 <= x->x_f2);
314}
315
316static void binop2_le_float(t_binop *x, t_float f)
317{
318 outlet_float(x->x_obj.ob_outlet, (x->x_f1 = f) <= x->x_f2);
319}
320
321/* ------------- binop3: &, |, &&, ||, <<, >>, %, mod, div ------------------ */
322
323static void *binop3_new(t_class *fixclass, t_floatarg f)
324{
325 t_binop *x = (t_binop *)pd_new(fixclass);
326 outlet_new(&x->x_obj, &s_float);
327 floatinlet_new(&x->x_obj, &x->x_f2);
328 x->x_f1 = 0;
329 x->x_f2 = f;
330 return (x);
331}
332
333/* --------------------------- & ---------------------------- */
334
335static t_class *binop3_ba_class;
336
337static void *binop3_ba_new(t_floatarg f)
338{
339 return (binop3_new(binop3_ba_class, f));
340}
341
342static void binop2_ba_bang(t_binop *x)
343{
344 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) & (int)(x->x_f2));
345}
346
347static void binop2_ba_float(t_binop *x, t_float f)
348{
349 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) & (int)(x->x_f2));
350}
351
352/* --------------------------- && ---------------------------- */
353
354static t_class *binop3_la_class;
355
356static void *binop3_la_new(t_floatarg f)
357{
358 return (binop3_new(binop3_la_class, f));
359}
360
361static void binop2_la_bang(t_binop *x)
362{
363 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) && (int)(x->x_f2));
364}
365
366static void binop2_la_float(t_binop *x, t_float f)
367{
368 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) && (int)(x->x_f2));
369}
370
371/* --------------------------- | ---------------------------- */
372
373static t_class *binop3_bo_class;
374
375static void *binop3_bo_new(t_floatarg f)
376{
377 return (binop3_new(binop3_bo_class, f));
378}
379
380static void binop2_bo_bang(t_binop *x)
381{
382 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) | (int)(x->x_f2));
383}
384
385static void binop2_bo_float(t_binop *x, t_float f)
386{
387 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) | (int)(x->x_f2));
388}
389
390/* --------------------------- || ---------------------------- */
391
392static t_class *binop3_lo_class;
393
394static void *binop3_lo_new(t_floatarg f)
395{
396 return (binop3_new(binop3_lo_class, f));
397}
398
399static void binop2_lo_bang(t_binop *x)
400{
401 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) || (int)(x->x_f2));
402}
403
404static void binop2_lo_float(t_binop *x, t_float f)
405{
406 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) || (int)(x->x_f2));
407}
408
409/* --------------------------- << ---------------------------- */
410
411static t_class *binop3_ls_class;
412
413static void *binop3_ls_new(t_floatarg f)
414{
415 return (binop3_new(binop3_ls_class, f));
416}
417
418static void binop2_ls_bang(t_binop *x)
419{
420 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) << (int)(x->x_f2));
421}
422
423static void binop2_ls_float(t_binop *x, t_float f)
424{
425 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) << (int)(x->x_f2));
426}
427
428/* --------------------------- >> ---------------------------- */
429
430static t_class *binop3_rs_class;
431
432static void *binop3_rs_new(t_floatarg f)
433{
434 return (binop3_new(binop3_rs_class, f));
435}
436
437static void binop2_rs_bang(t_binop *x)
438{
439 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) >> (int)(x->x_f2));
440}
441
442static void binop2_rs_float(t_binop *x, t_float f)
443{
444 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) >> (int)(x->x_f2));
445}
446
447/* --------------------------- % ---------------------------- */
448
449static t_class *binop3_pc_class;
450
451static void *binop3_pc_new(t_floatarg f)
452{
453 return (binop3_new(binop3_pc_class, f));
454}
455
456static void binop2_pc_bang(t_binop *x)
457{
458 int n2 = x->x_f2;
459 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1)) % (n2 ? n2 : 1));
460}
461
462static void binop2_pc_float(t_binop *x, t_float f)
463{
464 int n2 = x->x_f2;
465 outlet_float(x->x_obj.ob_outlet, ((int)(x->x_f1 = f)) % (n2 ? n2 : 1));
466}
467
468/* --------------------------- mod ---------------------------- */
469
470static t_class *binop3_mod_class;
471
472static void *binop3_mod_new(t_floatarg f)
473{
474 return (binop3_new(binop3_mod_class, f));
475}
476
477static void binop3_mod_bang(t_binop *x)
478{
479 int n2 = x->x_f2, result;
480 if (n2 < 0) n2 = -n2;
481 else if (!n2) n2 = 1;
482 result = ((int)(x->x_f1)) % n2;
483 if (result < 0) result += n2;
484 outlet_float(x->x_obj.ob_outlet, (t_float)result);
485}
486
487static void binop3_mod_float(t_binop *x, t_float f)
488{
489 x->x_f1 = f;
490 binop3_mod_bang(x);
491}
492
493/* --------------------------- div ---------------------------- */
494
495static t_class *binop3_div_class;
496
497static void *binop3_div_new(t_floatarg f)
498{
499 return (binop3_new(binop3_div_class, f));
500}
501
502static void binop3_div_bang(t_binop *x)
503{
504 int n1 = x->x_f1, n2 = x->x_f2, result;
505 if (n2 < 0) n2 = -n2;
506 else if (!n2) n2 = 1;
507 if (n1 < 0) n1 -= (n2-1);
508 result = n1 / n2;
509 outlet_float(x->x_obj.ob_outlet, (t_float)result);
510}
511
512static void binop3_div_float(t_binop *x, t_float f)
513{
514 x->x_f1 = f;
515 binop3_div_bang(x);
516}
517
518/* -------------------- mathematical functions ------------------ */
519
520static t_class *sin_class; /* ----------- sin --------------- */
521
522static void *sin_new(void)
523{
524 t_object *x = (t_object *)pd_new(sin_class);
525 outlet_new(x, &s_float);
526 return (x);
527}
528
529static void sin_float(t_object *x, t_float f)
530{
531 outlet_float(x->ob_outlet, sinf(f));
532}
533
534static t_class *cos_class; /* ----------- cos --------------- */
535
536static void *cos_new(void)
537{
538 t_object *x = (t_object *)pd_new(cos_class);
539 outlet_new(x, &s_float);
540 return (x);
541}
542
543static void cos_float(t_object *x, t_float f)
544{
545 outlet_float(x->ob_outlet, cosf(f));
546}
547
548static t_class *tan_class; /* ----------- tan --------------- */
549
550static void *tan_new(void)
551{
552 t_object *x = (t_object *)pd_new(tan_class);
553 outlet_new(x, &s_float);
554 return (x);
555}
556
557static void tan_float(t_object *x, t_float f)
558{
559 float c = cosf(f);
560 float t = (c == 0 ? 0 : sinf(f)/c);
561 outlet_float(x->ob_outlet, t);
562}
563
564static t_class *atan_class; /* ----------- atan --------------- */
565
566static void *atan_new(void)
567{
568 t_object *x = (t_object *)pd_new(atan_class);
569 outlet_new(x, &s_float);
570 return (x);
571}
572
573static void atan_float(t_object *x, t_float f)
574{
575 outlet_float(x->ob_outlet, atanf(f));
576}
577
578static t_class *atan2_class; /* ----------- atan2 --------------- */
579
580typedef struct _atan2
581{
582 t_object x_ob;
583 float x_y;
584} t_atan2;
585
586static void *atan2_new(void)
587{
588 t_atan2 *x = (t_atan2 *)pd_new(atan2_class);
589 floatinlet_new(&x->x_ob, &x->x_y);
590 outlet_new(&x->x_ob, &s_float);
591 return (x);
592}
593
594static void atan2_float(t_atan2 *x, t_float f)
595{
596 float r = (f == 0 && x->x_y == 0 ? 0 : atan2f(x->x_y, f));
597 outlet_float(x->x_ob.ob_outlet, r);
598}
599
600static t_class *sqrt_class; /* ----------- sqrt --------------- */
601
602static void *sqrt_new(void)
603{
604 t_object *x = (t_object *)pd_new(sqrt_class);
605 outlet_new(x, &s_float);
606 return (x);
607}
608
609static void sqrt_float(t_object *x, t_float f)
610{
611 float r = (f > 0 ? sqrtf(f) : 0);
612 outlet_float(x->ob_outlet, r);
613}
614
615static t_class *log_class; /* ----------- log --------------- */
616
617static void *log_new(void)
618{
619 t_object *x = (t_object *)pd_new(log_class);
620 outlet_new(x, &s_float);
621 return (x);
622}
623
624static void log_float(t_object *x, t_float f)
625{
626 float r = (f > 0 ? logf(f) : -1000);
627 outlet_float(x->ob_outlet, r);
628}
629
630
631static t_class *exp_class; /* ----------- exp --------------- */
632
633static void *exp_new(void)
634{
635 t_object *x = (t_object *)pd_new(exp_class);
636 outlet_new(x, &s_float);
637 return (x);
638}
639
640#define MAXLOG 87.3365
641static void exp_float(t_object *x, t_float f)
642{
643 float g;
644#ifdef MSW
645 char buf[10];
646#endif
647 if (f > MAXLOG) f = MAXLOG;
648 g = expf(f);
649 outlet_float(x->ob_outlet, g);
650}
651
652static t_class *abs_class; /* ----------- abs --------------- */
653
654static void *abs_new(void)
655{
656 t_object *x = (t_object *)pd_new(abs_class);
657 outlet_new(x, &s_float);
658 return (x);
659}
660
661static void abs_float(t_object *x, t_float f)
662{
663 outlet_float(x->ob_outlet, fabsf(f));
664}
665
666/* ------------------------ misc ------------------------ */
667
668static t_class *clip_class;
669
670typedef struct _clip
671{
672 t_object x_ob;
673 float x_f1;
674 float x_f2;
675} t_clip;
676
677static void *clip_new(t_floatarg f1, t_floatarg f2)
678{
679 t_clip *x = (t_clip *)pd_new(clip_class);
680 floatinlet_new(&x->x_ob, &x->x_f1);
681 floatinlet_new(&x->x_ob, &x->x_f2);
682 outlet_new(&x->x_ob, &s_float);
683 x->x_f1 = f1;
684 x->x_f2 = f2;
685 return (x);
686}
687
688static void clip_float(t_clip *x, t_float f)
689{
690 outlet_float(x->x_ob.ob_outlet, (f < x->x_f1 ? x->x_f1 : (
691 f > x->x_f2 ? x->x_f2 : f)));
692}
693
694static void clip_setup(void)
695{
696 clip_class = class_new(gensym("clip"), (t_newmethod)clip_new, 0,
697 sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0);
698 class_addfloat(clip_class, clip_float);
699}
700
701void x_arithmetic_setup(void)
702{
703 t_symbol *binop1_sym = gensym("operators");
704 t_symbol *binop23_sym = gensym("otherbinops");
705 t_symbol *math_sym = gensym("math");
706
707 binop1_plus_class = class_new(gensym("+"), (t_newmethod)binop1_plus_new, 0,
708 sizeof(t_binop), 0, A_DEFFLOAT, 0);
709 class_addbang(binop1_plus_class, binop1_plus_bang);
710 class_addfloat(binop1_plus_class, (t_method)binop1_plus_float);
711 class_sethelpsymbol(binop1_plus_class, binop1_sym);
712
713 binop1_minus_class = class_new(gensym("-"),
714 (t_newmethod)binop1_minus_new, 0,
715 sizeof(t_binop), 0, A_DEFFLOAT, 0);
716 class_addbang(binop1_minus_class, binop1_minus_bang);
717 class_addfloat(binop1_minus_class, (t_method)binop1_minus_float);
718 class_sethelpsymbol(binop1_minus_class, binop1_sym);
719
720 binop1_times_class = class_new(gensym("*"),
721 (t_newmethod)binop1_times_new, 0,
722 sizeof(t_binop), 0, A_DEFFLOAT, 0);
723 class_addbang(binop1_times_class, binop1_times_bang);
724 class_addfloat(binop1_times_class, (t_method)binop1_times_float);
725 class_sethelpsymbol(binop1_times_class, binop1_sym);
726
727 binop1_div_class = class_new(gensym("/"),
728 (t_newmethod)binop1_div_new, 0,
729 sizeof(t_binop), 0, A_DEFFLOAT, 0);
730 class_addbang(binop1_div_class, binop1_div_bang);
731 class_addfloat(binop1_div_class, (t_method)binop1_div_float);
732 class_sethelpsymbol(binop1_div_class, binop1_sym);
733
734 binop1_pow_class = class_new(gensym("pow"),
735 (t_newmethod)binop1_pow_new, 0,
736 sizeof(t_binop), 0, A_DEFFLOAT, 0);
737 class_addbang(binop1_pow_class, binop1_pow_bang);
738 class_addfloat(binop1_pow_class, (t_method)binop1_pow_float);
739 class_sethelpsymbol(binop1_pow_class, binop1_sym);
740
741 binop1_max_class = class_new(gensym("max"),
742 (t_newmethod)binop1_max_new, 0,
743 sizeof(t_binop), 0, A_DEFFLOAT, 0);
744 class_addbang(binop1_max_class, binop1_max_bang);
745 class_addfloat(binop1_max_class, (t_method)binop1_max_float);
746 class_sethelpsymbol(binop1_max_class, binop1_sym);
747
748 binop1_min_class = class_new(gensym("min"),
749 (t_newmethod)binop1_min_new, 0,
750 sizeof(t_binop), 0, A_DEFFLOAT, 0);
751 class_addbang(binop1_min_class, binop1_min_bang);
752 class_addfloat(binop1_min_class, (t_method)binop1_min_float);
753 class_sethelpsymbol(binop1_min_class, binop1_sym);
754
755 /* ------------------ binop2 ----------------------- */
756
757 binop2_ee_class = class_new(gensym("=="), (t_newmethod)binop2_ee_new, 0,
758 sizeof(t_binop), 0, A_DEFFLOAT, 0);
759 class_addbang(binop2_ee_class, binop2_ee_bang);
760 class_addfloat(binop2_ee_class, (t_method)binop2_ee_float);
761 class_sethelpsymbol(binop2_ee_class, binop23_sym);
762
763 binop2_ne_class = class_new(gensym("!="), (t_newmethod)binop2_ne_new, 0,
764 sizeof(t_binop), 0, A_DEFFLOAT, 0);
765 class_addbang(binop2_ne_class, binop2_ne_bang);
766 class_addfloat(binop2_ne_class, (t_method)binop2_ne_float);
767 class_sethelpsymbol(binop2_ne_class, binop23_sym);
768
769 binop2_gt_class = class_new(gensym(">"), (t_newmethod)binop2_gt_new, 0,
770 sizeof(t_binop), 0, A_DEFFLOAT, 0);
771 class_addbang(binop2_gt_class, binop2_gt_bang);
772 class_addfloat(binop2_gt_class, (t_method)binop2_gt_float);
773 class_sethelpsymbol(binop2_gt_class, binop23_sym);
774
775 binop2_lt_class = class_new(gensym("<"), (t_newmethod)binop2_lt_new, 0,
776 sizeof(t_binop), 0, A_DEFFLOAT, 0);
777 class_addbang(binop2_lt_class, binop2_lt_bang);
778 class_addfloat(binop2_lt_class, (t_method)binop2_lt_float);
779 class_sethelpsymbol(binop2_lt_class, binop23_sym);
780
781 binop2_ge_class = class_new(gensym(">="), (t_newmethod)binop2_ge_new, 0,
782 sizeof(t_binop), 0, A_DEFFLOAT, 0);
783 class_addbang(binop2_ge_class, binop2_ge_bang);
784 class_addfloat(binop2_ge_class, (t_method)binop2_ge_float);
785 class_sethelpsymbol(binop2_ge_class, binop23_sym);
786
787 binop2_le_class = class_new(gensym("<="), (t_newmethod)binop2_le_new, 0,
788 sizeof(t_binop), 0, A_DEFFLOAT, 0);
789 class_addbang(binop2_le_class, binop2_le_bang);
790 class_addfloat(binop2_le_class, (t_method)binop2_le_float);
791 class_sethelpsymbol(binop2_le_class, binop23_sym);
792
793 /* ------------------ binop3 ----------------------- */
794
795 binop3_ba_class = class_new(gensym("&"), (t_newmethod)binop3_ba_new, 0,
796 sizeof(t_binop), 0, A_DEFFLOAT, 0);
797 class_addbang(binop3_ba_class, binop2_ba_bang);
798 class_addfloat(binop3_ba_class, (t_method)binop2_ba_float);
799 class_sethelpsymbol(binop3_ba_class, binop23_sym);
800
801 binop3_la_class = class_new(gensym("&&"), (t_newmethod)binop3_la_new, 0,
802 sizeof(t_binop), 0, A_DEFFLOAT, 0);
803 class_addbang(binop3_la_class, binop2_la_bang);
804 class_addfloat(binop3_la_class, (t_method)binop2_la_float);
805 class_sethelpsymbol(binop3_la_class, binop23_sym);
806
807 binop3_bo_class = class_new(gensym("|"), (t_newmethod)binop3_bo_new, 0,
808 sizeof(t_binop), 0, A_DEFFLOAT, 0);
809 class_addbang(binop3_bo_class, binop2_bo_bang);
810 class_addfloat(binop3_bo_class, (t_method)binop2_bo_float);
811 class_sethelpsymbol(binop3_bo_class, binop23_sym);
812
813 binop3_lo_class = class_new(gensym("||"), (t_newmethod)binop3_lo_new, 0,
814 sizeof(t_binop), 0, A_DEFFLOAT, 0);
815 class_addbang(binop3_lo_class, binop2_lo_bang);
816 class_addfloat(binop3_lo_class, (t_method)binop2_lo_float);
817 class_sethelpsymbol(binop3_lo_class, binop23_sym);
818
819 binop3_ls_class = class_new(gensym("<<"), (t_newmethod)binop3_ls_new, 0,
820 sizeof(t_binop), 0, A_DEFFLOAT, 0);
821 class_addbang(binop3_ls_class, binop2_ls_bang);
822 class_addfloat(binop3_ls_class, (t_method)binop2_ls_float);
823 class_sethelpsymbol(binop3_ls_class, binop23_sym);
824
825 binop3_rs_class = class_new(gensym(">>"), (t_newmethod)binop3_rs_new, 0,
826 sizeof(t_binop), 0, A_DEFFLOAT, 0);
827 class_addbang(binop3_rs_class, binop2_rs_bang);
828 class_addfloat(binop3_rs_class, (t_method)binop2_rs_float);
829 class_sethelpsymbol(binop3_rs_class, binop23_sym);
830
831 binop3_pc_class = class_new(gensym("%"), (t_newmethod)binop3_pc_new, 0,
832 sizeof(t_binop), 0, A_DEFFLOAT, 0);
833 class_addbang(binop3_pc_class, binop2_pc_bang);
834 class_addfloat(binop3_pc_class, (t_method)binop2_pc_float);
835 class_sethelpsymbol(binop3_pc_class, binop23_sym);
836
837 binop3_mod_class = class_new(gensym("mod"), (t_newmethod)binop3_mod_new, 0,
838 sizeof(t_binop), 0, A_DEFFLOAT, 0);
839 class_addbang(binop3_mod_class, binop3_mod_bang);
840 class_addfloat(binop3_mod_class, (t_method)binop3_mod_float);
841 class_sethelpsymbol(binop3_mod_class, binop23_sym);
842
843 binop3_div_class = class_new(gensym("div"), (t_newmethod)binop3_div_new, 0,
844 sizeof(t_binop), 0, A_DEFFLOAT, 0);
845 class_addbang(binop3_div_class, binop3_div_bang);
846 class_addfloat(binop3_div_class, (t_method)binop3_div_float);
847 class_sethelpsymbol(binop3_div_class, binop23_sym);
848
849 /* ------------------- math functions --------------- */
850
851 sin_class = class_new(gensym("sin"), sin_new, 0,
852 sizeof(t_object), 0, 0);
853 class_addfloat(sin_class, (t_method)sin_float);
854 class_sethelpsymbol(sin_class, math_sym);
855
856 cos_class = class_new(gensym("cos"), cos_new, 0,
857 sizeof(t_object), 0, 0);
858 class_addfloat(cos_class, (t_method)cos_float);
859 class_sethelpsymbol(cos_class, math_sym);
860
861 tan_class = class_new(gensym("tan"), tan_new, 0,
862 sizeof(t_object), 0, 0);
863 class_addfloat(tan_class, (t_method)tan_float);
864 class_sethelpsymbol(tan_class, math_sym);
865
866 atan_class = class_new(gensym("atan"), atan_new, 0,
867 sizeof(t_object), 0, 0);
868 class_addfloat(atan_class, (t_method)atan_float);
869 class_sethelpsymbol(atan_class, math_sym);
870
871 atan2_class = class_new(gensym("atan2"), atan2_new, 0,
872 sizeof(t_atan2), 0, 0);
873 class_addfloat(atan2_class, (t_method)atan2_float);
874 class_sethelpsymbol(atan2_class, math_sym);
875
876 sqrt_class = class_new(gensym("sqrt"), sqrt_new, 0,
877 sizeof(t_object), 0, 0);
878 class_addfloat(sqrt_class, (t_method)sqrt_float);
879 class_sethelpsymbol(sqrt_class, math_sym);
880
881 log_class = class_new(gensym("log"), log_new, 0,
882 sizeof(t_object), 0, 0);
883 class_addfloat(log_class, (t_method)log_float);
884 class_sethelpsymbol(log_class, math_sym);
885
886 exp_class = class_new(gensym("exp"), exp_new, 0,
887 sizeof(t_object), 0, 0);
888 class_addfloat(exp_class, (t_method)exp_float);
889 class_sethelpsymbol(exp_class, math_sym);
890
891 abs_class = class_new(gensym("abs"), abs_new, 0,
892 sizeof(t_object), 0, 0);
893 class_addfloat(abs_class, (t_method)abs_float);
894 class_sethelpsymbol(abs_class, math_sym);
895
896/* ------------------------ misc ------------------------ */
897
898 clip_setup();
899}
900