From d6b088044e161a27d49df537bbb6d998a8d0e50d Mon Sep 17 00:00:00 2001 From: musil Date: Sat, 9 Dec 2006 02:00:52 +0000 Subject: // class_sethelpsymbol(); changed help-*.pd to *-help.pd chanded file structure to standard 1st step remove old svn path=/trunk/externals/iemlib/; revision=6756 --- iemlib1/FIR~-help.pd | 67 ++++ iemlib1/db2v-help.pd | 17 + iemlib1/f2note-help.pd | 24 ++ iemlib1/for++-help.pd | 74 ++++ iemlib1/gate-help.pd | 35 ++ iemlib1/hml_shelf~-help.pd | 99 +++++ iemlib1/lp1.wav | Bin 0 -> 556 bytes iemlib1/lp1_t~-help.pd | 59 +++ iemlib1/lp2.wav | Bin 0 -> 556 bytes iemlib1/lp3.wav | Bin 0 -> 556 bytes iemlib1/para_bp2~-help.pd | 67 ++++ iemlib1/peakenv~-help.pd | 38 ++ iemlib1/prvu~-help.pd | 138 +++++++ iemlib1/pvu~-help.pd | 120 ++++++ iemlib1/rvu~-help.pd | 112 ++++++ iemlib1/sin_phase~-help.pd | 64 ++++ iemlib1/soundfile_info-help.pd | 36 ++ iemlib1/split-help.pd | 31 ++ iemlib1/src/FIR~.c | 169 +++++++++ iemlib1/src/biquad_freq_resp.c | 86 +++++ iemlib1/src/db2v.c | 38 ++ iemlib1/src/f2note.c | 183 ++++++++++ iemlib1/src/filter~.c | 813 +++++++++++++++++++++++++++++++++++++++++ iemlib1/src/for++.c | 185 ++++++++++ iemlib1/src/gate.c | 78 ++++ iemlib1/src/hml_shelf~.c | 548 +++++++++++++++++++++++++++ iemlib1/src/iem_cot4~.c | 168 +++++++++ iemlib1/src/iem_delay~.c | 201 ++++++++++ iemlib1/src/iem_pow4~.c | 78 ++++ iemlib1/src/iem_sqrt4~.c | 108 ++++++ iemlib1/src/iemlib.h | 108 ++++++ iemlib1/src/iemlib1.c | 78 ++++ iemlib1/src/iemlib1.dsp | 85 +++++ iemlib1/src/iemlib1.dsw | 29 ++ iemlib1/src/lp1_t~.c | 210 +++++++++++ iemlib1/src/makefile | 4 + iemlib1/src/makefile.darwin | 73 ++++ iemlib1/src/makefile_linux | 69 ++++ iemlib1/src/makefile_win | 55 +++ iemlib1/src/mov_avrg_kern~.c | 135 +++++++ iemlib1/src/para_bp2~.c | 418 +++++++++++++++++++++ iemlib1/src/peakenv~.c | 95 +++++ iemlib1/src/prvu~.c | 274 ++++++++++++++ iemlib1/src/pvu~.c | 198 ++++++++++ iemlib1/src/rvu~.c | 178 +++++++++ iemlib1/src/sin_phase~.c | 121 ++++++ iemlib1/src/soundfile_info.c | 256 +++++++++++++ iemlib1/src/split.c | 47 +++ iemlib1/src/v2db.c | 39 ++ iemlib1/src/vcf_filter~.c | 327 +++++++++++++++++ iemlib1/v2db-help.pd | 17 + 51 files changed, 6452 insertions(+) create mode 100644 iemlib1/FIR~-help.pd create mode 100644 iemlib1/db2v-help.pd create mode 100644 iemlib1/f2note-help.pd create mode 100644 iemlib1/for++-help.pd create mode 100644 iemlib1/gate-help.pd create mode 100644 iemlib1/hml_shelf~-help.pd create mode 100644 iemlib1/lp1.wav create mode 100644 iemlib1/lp1_t~-help.pd create mode 100644 iemlib1/lp2.wav create mode 100644 iemlib1/lp3.wav create mode 100644 iemlib1/para_bp2~-help.pd create mode 100644 iemlib1/peakenv~-help.pd create mode 100644 iemlib1/prvu~-help.pd create mode 100644 iemlib1/pvu~-help.pd create mode 100644 iemlib1/rvu~-help.pd create mode 100644 iemlib1/sin_phase~-help.pd create mode 100644 iemlib1/soundfile_info-help.pd create mode 100644 iemlib1/split-help.pd create mode 100644 iemlib1/src/FIR~.c create mode 100644 iemlib1/src/biquad_freq_resp.c create mode 100644 iemlib1/src/db2v.c create mode 100644 iemlib1/src/f2note.c create mode 100644 iemlib1/src/filter~.c create mode 100644 iemlib1/src/for++.c create mode 100644 iemlib1/src/gate.c create mode 100644 iemlib1/src/hml_shelf~.c create mode 100644 iemlib1/src/iem_cot4~.c create mode 100644 iemlib1/src/iem_delay~.c create mode 100644 iemlib1/src/iem_pow4~.c create mode 100644 iemlib1/src/iem_sqrt4~.c create mode 100644 iemlib1/src/iemlib.h create mode 100644 iemlib1/src/iemlib1.c create mode 100644 iemlib1/src/iemlib1.dsp create mode 100644 iemlib1/src/iemlib1.dsw create mode 100644 iemlib1/src/lp1_t~.c create mode 100644 iemlib1/src/makefile create mode 100644 iemlib1/src/makefile.darwin create mode 100644 iemlib1/src/makefile_linux create mode 100644 iemlib1/src/makefile_win create mode 100644 iemlib1/src/mov_avrg_kern~.c create mode 100644 iemlib1/src/para_bp2~.c create mode 100644 iemlib1/src/peakenv~.c create mode 100644 iemlib1/src/prvu~.c create mode 100644 iemlib1/src/pvu~.c create mode 100644 iemlib1/src/rvu~.c create mode 100644 iemlib1/src/sin_phase~.c create mode 100644 iemlib1/src/soundfile_info.c create mode 100644 iemlib1/src/split.c create mode 100644 iemlib1/src/v2db.c create mode 100644 iemlib1/src/vcf_filter~.c create mode 100644 iemlib1/v2db-help.pd (limited to 'iemlib1') diff --git a/iemlib1/FIR~-help.pd b/iemlib1/FIR~-help.pd new file mode 100644 index 0000000..7153aa4 --- /dev/null +++ b/iemlib1/FIR~-help.pd @@ -0,0 +1,67 @@ +#N canvas 345 25 523 623 10; +#N canvas 0 0 450 300 graph1 0; +#X array fir_coeff 256 float 0; +#X coords 0 1 255 -1 256 140 1; +#X restore 63 195 graph; +#X obj 109 154 soundfiler; +#X floatatom 4 133 5 0 0 0 - - -; +#X text 32 96 % cpu; +#X obj 4 93 dsp; +#X obj 4 73 tgl 15 0 empty empty dsp_ON/OFF 2 -8 0 10 -225271 -42246 +-90881 0 1; +#X floatatom 413 444 7 0 0 0 - - -; +#X obj 342 323 dac~; +#X obj 342 297 gainvu~ 300; +#X obj 404 319 vu 15 120 empty empty 8 -8 0 10 -66577 -1 1 0; +#X obj 471 166 vsl 15 128 0 127 0 1 empty empty gain -7 -8 0 10 -225271 +-42246 -90881 6000 1; +#X obj 343 75 noise~; +#X floatatom 403 462 7 0 0 0 - - -; +#X obj 109 71 bng 15 250 50 1 empty empty loadbang 0 -8 0 10 -225271 +-24198 -90881; +#X msg 109 91 read -resize lp1.wav fir_coeff; +#X msg 114 112 read -resize lp2.wav fir_coeff; +#X msg 121 132 read -resize lp3.wav fir_coeff; +#X obj 19 406 soundfiler; +#N canvas 0 0 450 300 graph1 0; +#X array fir_coeff2 256 float 0; +#X coords 0 1 255 -1 256 140 1; +#X restore 70 452 graph; +#X msg 20 385 read -resize lp3.wav fir_coeff2; +#X obj 20 365 bng 15 250 50 1 empty empty loadbang 0 -8 0 10 -225271 +-24198 -90881; +#X msg 359 105 set fir_coeff 256; +#X msg 373 127 set fir_coeff2 256; +#X floatatom 17 113 5 0 0 0 - - -; +#X obj 343 155 FIR~ fir_coeff 256; +#X text 398 517 IEM KUG; +#X text 382 505 musil; +#X text 412 505 @; +#X text 418 505 iem.at; +#X text 333 494 (c) Thomas Musil 2000 - 2005; +#X text 381 527 Graz \, Austria; +#X text 15 13 FIR~; +#X text 50 12 convolve a signal with an array; +#X text 276 5 1.arg: array-name; +#X text 276 15 2.arg: convolution-length; +#X floatatom 372 273 5 0 0 0 - - -; +#X connect 4 0 2 0; +#X connect 4 1 23 0; +#X connect 5 0 4 0; +#X connect 8 0 7 0; +#X connect 8 0 7 1; +#X connect 8 1 35 0; +#X connect 8 2 9 0; +#X connect 9 0 12 0; +#X connect 9 1 6 0; +#X connect 10 0 8 1; +#X connect 11 0 24 0; +#X connect 13 0 14 0; +#X connect 14 0 1 0; +#X connect 15 0 1 0; +#X connect 16 0 1 0; +#X connect 19 0 17 0; +#X connect 20 0 19 0; +#X connect 21 0 24 0; +#X connect 22 0 24 0; +#X connect 24 0 8 0; diff --git a/iemlib1/db2v-help.pd b/iemlib1/db2v-help.pd new file mode 100644 index 0000000..e3407fc --- /dev/null +++ b/iemlib1/db2v-help.pd @@ -0,0 +1,17 @@ +#N canvas 512 284 283 224 10; +#X floatatom 23 99 9 0 0 0 - - -; +#X text 57 75 no arg; +#X obj 23 76 db2v; +#X floatatom 23 52 9 0 0 0 - - -; +#X text 85 53 input_level [dB]; +#X text 24 11 db2v; +#X text 104 12 dB to value converter; +#X text 87 102 output_value [-]; +#X text 114 184 IEM KUG; +#X text 98 172 musil; +#X text 128 172 @; +#X text 134 172 iem.at; +#X text 49 161 (c) Thomas Musil 2000 - 2005; +#X text 97 194 Graz \, Austria; +#X connect 2 0 0 0; +#X connect 3 0 2 0; diff --git a/iemlib1/f2note-help.pd b/iemlib1/f2note-help.pd new file mode 100644 index 0000000..fc014a9 --- /dev/null +++ b/iemlib1/f2note-help.pd @@ -0,0 +1,24 @@ +#N canvas 320 113 341 260 10; +#X floatatom 19 138 9 0 0 0 - - -; +#X floatatom 19 36 9 8 24000 0 - - -; +#X floatatom 84 91 6 0 0 0 - - -; +#X obj 19 67 f2note 440; +#X msg 51 114 g1; +#X text 146 37 input frequency; +#X text 92 36 Hz; +#X text 105 66 1.arg: reference-frequency a1; +#X text 132 92 cents; +#X text 76 114 note; +#X text 91 140 midi; +#X text 4 2 f2note; +#X text 58 1 converts frequency to notes + cents; +#X text 184 204 IEM KUG; +#X text 168 192 musil; +#X text 198 192 @; +#X text 204 192 iem.at; +#X text 119 181 (c) Thomas Musil 2000 - 2005; +#X text 167 214 Graz \, Austria; +#X connect 1 0 3 0; +#X connect 3 0 0 0; +#X connect 3 1 4 0; +#X connect 3 2 2 0; diff --git a/iemlib1/for++-help.pd b/iemlib1/for++-help.pd new file mode 100644 index 0000000..63d1efa --- /dev/null +++ b/iemlib1/for++-help.pd @@ -0,0 +1,74 @@ +#N canvas 324 220 748 404 10; +#X obj 25 52 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X obj 65 186 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X floatatom 65 61 4 0 0 0 - - -; +#X floatatom 115 88 4 0 0 0 - - -; +#X floatatom 65 163 4 0 0 0 - - -; +#X floatatom 165 110 4 0 0 0 - - -; +#X text 7 8 for++; +#X obj 65 132 for++ 10 20 200; +#X obj 111 166 print; +#X msg 25 71 start; +#X msg 25 91 stop; +#X text 64 47 first number; +#X text 115 72 last number; +#X obj 237 213 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X floatatom 237 190 4 0 0 0 - - -; +#X obj 280 186 print; +#X obj 237 143 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X text 343 48 2.arg: last number; +#X text 343 36 1.arg: first number; +#X obj 237 162 for++ 50 40 100; +#X obj 165 166 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X obj 337 193 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X text 163 181 finished; +#X text 336 208 finished; +#X obj 237 264 print finished; +#X obj 509 141 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X obj 629 184 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 +-1 -1; +#X text 628 199 finished; +#X obj 509 208 timer; +#X obj 509 183 sel 0 1000; +#X floatatom 509 231 5 0 0 0 - - -; +#X obj 509 160 for++ 0 1000 1.234; +#X text 343 60 3.arg: increment-delay in ms; +#X text 159 92 increment-delay in ms; +#X text 85 20 increment-step-size is allways 1 or -1; +#X text 78 257 IEM KUG; +#X text 62 245 musil; +#X text 92 245 @; +#X text 98 245 iem.at; +#X text 13 234 (c) Thomas Musil 2000 - 2005; +#X text 61 267 Graz \, Austria; +#X text 67 9 counter with its own interval-timer; +#X connect 0 0 7 0; +#X connect 2 0 7 0; +#X connect 3 0 7 1; +#X connect 4 0 1 0; +#X connect 5 0 7 2; +#X connect 7 0 4 0; +#X connect 7 0 8 0; +#X connect 7 1 20 0; +#X connect 9 0 7 0; +#X connect 10 0 7 0; +#X connect 14 0 13 0; +#X connect 16 0 19 0; +#X connect 19 0 14 0; +#X connect 19 0 15 0; +#X connect 19 1 21 0; +#X connect 20 0 24 0; +#X connect 21 0 24 0; +#X connect 25 0 31 0; +#X connect 28 0 30 0; +#X connect 29 0 28 0; +#X connect 29 1 28 1; +#X connect 31 0 29 0; +#X connect 31 1 26 0; diff --git a/iemlib1/gate-help.pd b/iemlib1/gate-help.pd new file mode 100644 index 0000000..f042e3d --- /dev/null +++ b/iemlib1/gate-help.pd @@ -0,0 +1,35 @@ +#N canvas 400 182 410 349 10; +#X obj 9 37 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X msg 34 36 33; +#X msg 51 58 -3.14; +#X msg 74 100 11 22 33.33; +#X msg 64 78 open xxx; +#X msg 94 122 funny; +#X text 7 8 gate; +#X obj 95 176 tgl 15 0 empty empty empty 8 -8 0 10 -262144 -1 -1 0 +1; +#X obj 9 237 print; +#X text 112 236 the original object spigot; +#X obj 55 229 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X text 118 246 (c) miller puckette; +#X text 44 8 interrupt or continue a stream of messages; +#X text 116 172 gate: ON / OFF; +#X obj 9 206 gate 1; +#X text 63 206 1.arg: control-state of gate [0/1] (opt.); +#X text 154 297 IEM KUG; +#X text 138 285 musil; +#X text 168 285 @; +#X text 174 285 iem.at; +#X text 89 274 (c) Thomas Musil 2000 - 2005; +#X text 137 307 Graz \, Austria; +#X connect 0 0 14 0; +#X connect 1 0 14 0; +#X connect 2 0 14 0; +#X connect 3 0 14 0; +#X connect 4 0 14 0; +#X connect 5 0 14 0; +#X connect 7 0 14 1; +#X connect 14 0 8 0; +#X connect 14 0 10 0; diff --git a/iemlib1/hml_shelf~-help.pd b/iemlib1/hml_shelf~-help.pd new file mode 100644 index 0000000..b2250d3 --- /dev/null +++ b/iemlib1/hml_shelf~-help.pd @@ -0,0 +1,99 @@ +#N canvas 105 49 635 570 10; +#X text 29 39 dsp ON/OFF; +#X floatatom 435 513 7 0 0 0 - - -; +#X text 491 514 dB; +#X floatatom 120 158 9 0 22000 0 - - -; +#X text 190 160 Hz; +#X floatatom 47 110 3 15 133 0 - - -; +#X floatatom 12 79 5 0 0 0 - - -; +#X text 52 80 % cpu; +#X floatatom 261 304 5 2 9999 0 - - -; +#X text 303 304 ms; +#X obj 12 59 dsp; +#X obj 12 39 tgl 15 0 empty empty empty 8 -8 0 10 -262144 -1 -1 0 1 +; +#X obj 47 393 dac~; +#X obj 47 368 gainvu~ 300; +#X obj 426 387 vu 15 120 empty empty 8 -8 0 8 -66577 -1 1 0; +#X obj 530 237 vsl 15 128 0 127 0 1 empty empty empty 8 -8 0 10 -262144 +-1 -1 7000 1; +#X obj 47 132 testtone~ 200; +#X obj 114 93 init 69; +#X text 74 111 midi; +#X text 200 144 6.arg: interpolation_time [ms]; +#X text 200 91 1.arg: low_level [dB]; +#X text 200 101 2.arg: low_freq. [Hz]; +#X text 200 112 3.arg: medium_level [dB]; +#X text 200 122 4.arg: high_freq. [Hz]; +#X text 200 133 5.arg: high_level [dB]; +#X obj 47 328 hml_shelf~ 6 100 0 4000 -6 200; +#X obj 328 213 vsl 15 49 27.5 440 1 1 empty empty low_freq. -8 -8 0 +8 -262144 -1 -1 1200 1; +#X obj 81 216 vsl 15 81 -40 40 0 1 empty empty low_level -18 -8 0 8 +-262144 -1 -1 3000 1; +#X obj 149 215 vsl 15 81 -40 40 0 1 empty empty mid_level -10 -8 0 +8 -262144 -1 -1 4000 1; +#X obj 217 214 vsl 15 81 -40 40 0 1 empty empty high_level 0 -8 0 8 +-262144 -1 -1 3000 1; +#X text 345 207 -440Hz; +#X text 345 255 -27.5Hz; +#X text 345 231 -110Hz; +#X obj 399 213 vsl 15 49 880 14080 1 1 empty empty high_freq. -8 -8 +0 8 -262144 -1 -1 3800 1; +#X text 416 207 -14080Hz; +#X text 416 255 -880Hz; +#X text 416 231 -3520Hz; +#X floatatom 530 385 7 0 0 0 - - -; +#X text 588 387 dB; +#X floatatom 81 305 4 0 0 0 - - -; +#X floatatom 149 304 4 0 0 0 - - -; +#X floatatom 217 303 4 0 0 0 - - -; +#X floatatom 328 305 8 0 0 0 - - -; +#X floatatom 399 305 8 0 0 0 - - -; +#X text 157 8 high-middle-low-shelving-filter; +#X text 4 311 signal_in~; +#X text 97 211 +40; +#X text 99 250 0; +#X text 97 290 -40; +#X text 167 249 0; +#X text 165 289 -40; +#X text 165 210 +40; +#X text 233 209 +40; +#X text 235 248 0; +#X text 233 288 -40; +#X text 80 188 dB; +#X text 147 186 dB; +#X text 216 186 dB; +#X text 54 346 signal_out~; +#X obj 12 13 cnv 8 1 1 empty empty hml_shelf~ 1 2 1 18 -262144 -1109 +0; +#X text 78 467 IEM KUG; +#X text 62 455 musil; +#X text 92 455 @; +#X text 98 455 iem.at; +#X text 13 444 (c) Thomas Musil 2000 - 2005; +#X text 61 477 Graz \, Austria; +#X connect 5 0 16 0; +#X connect 8 0 25 6; +#X connect 10 0 6 0; +#X connect 11 0 10 0; +#X connect 13 0 12 0; +#X connect 13 0 12 1; +#X connect 13 1 37 0; +#X connect 13 2 14 0; +#X connect 14 1 1 0; +#X connect 15 0 13 1; +#X connect 16 0 25 0; +#X connect 16 1 3 0; +#X connect 17 0 5 0; +#X connect 25 0 13 0; +#X connect 26 0 42 0; +#X connect 27 0 39 0; +#X connect 28 0 40 0; +#X connect 29 0 41 0; +#X connect 33 0 43 0; +#X connect 39 0 25 1; +#X connect 40 0 25 3; +#X connect 41 0 25 5; +#X connect 42 0 25 2; +#X connect 43 0 25 4; diff --git a/iemlib1/lp1.wav b/iemlib1/lp1.wav new file mode 100644 index 0000000..4c4c97d Binary files /dev/null and b/iemlib1/lp1.wav differ diff --git a/iemlib1/lp1_t~-help.pd b/iemlib1/lp1_t~-help.pd new file mode 100644 index 0000000..118d27e --- /dev/null +++ b/iemlib1/lp1_t~-help.pd @@ -0,0 +1,59 @@ +#N canvas 152 8 565 552 10; +#X text 109 239 ~signal_in~; +#X text 38 33 dsp ON/OFF; +#X floatatom 191 175 5 0 1005 0 - - -; +#X text 172 273 ~signal_out~; +#X floatatom 21 73 5 0 0 0 - - -; +#X text 60 74 % cpu; +#X floatatom 231 225 5 2 9999 0 - - -; +#X text 273 226 ms; +#X obj 21 53 dsp; +#X obj 21 33 tgl 15 0 empty empty empty 8 -8 0 10 -262144 -1 -1 0 1 +; +#X text 292 265 2.arg: interpolation_time [ms]; +#X text 234 174 ms; +#X obj 152 255 lp1_t~ 0.5 200; +#X text 234 210 interpolation_time [ms]; +#X text 230 159 time_constant [ms]; +#X text 292 254 1.arg: time_constant [ms]; +#X obj 152 100 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X obj 74 197 t b; +#X obj 152 153 sig~; +#N canvas 0 0 450 300 graph1 0; +#X array scope 400 float 0; +#X coords 0 1 399 0 400 80 1; +#X restore 39 349 graph; +#X obj 74 306 tabwrite~ scope; +#X msg 217 115 0.2; +#X msg 248 115 0.5; +#X msg 278 116 1.5; +#X msg 270 503 \; scope xticks 0 22 2; +#X obj 270 482 loadbang; +#X text 79 431 1; +#X text 123 431 2; +#X text 168 431 3 ms; +#X floatatom 162 130 5 0 0 0 - - -; +#X obj 13 13 cnv 8 1 1 empty empty lp1_t~ 1 2 1 18 -262144 -1109 0 +; +#X text 102 8 lowpass 1.order with time_constant-inlet; +#X text 106 495 IEM KUG; +#X text 90 483 musil; +#X text 120 483 @; +#X text 126 483 iem.at; +#X text 41 472 (c) Thomas Musil 2000 - 2005; +#X text 89 505 Graz \, Austria; +#X connect 2 0 12 1; +#X connect 6 0 12 2; +#X connect 8 0 4 0; +#X connect 9 0 8 0; +#X connect 12 0 20 0; +#X connect 16 0 17 0; +#X connect 16 0 18 0; +#X connect 16 0 29 0; +#X connect 17 0 20 0; +#X connect 18 0 12 0; +#X connect 21 0 2 0; +#X connect 22 0 2 0; +#X connect 23 0 2 0; +#X connect 25 0 24 0; diff --git a/iemlib1/lp2.wav b/iemlib1/lp2.wav new file mode 100644 index 0000000..1e3fe72 Binary files /dev/null and b/iemlib1/lp2.wav differ diff --git a/iemlib1/lp3.wav b/iemlib1/lp3.wav new file mode 100644 index 0000000..defc6b1 Binary files /dev/null and b/iemlib1/lp3.wav differ diff --git a/iemlib1/para_bp2~-help.pd b/iemlib1/para_bp2~-help.pd new file mode 100644 index 0000000..739eb21 --- /dev/null +++ b/iemlib1/para_bp2~-help.pd @@ -0,0 +1,67 @@ +#N canvas 280 47 585 480 10; +#X text 5 265 ~signal_in~; +#X text 30 44 dsp ON/OFF; +#X floatatom 81 161 3 15 133 0 - - -; +#X obj 81 180 mtof; +#X floatatom 81 199 9 0 22000 0 - - -; +#X text 145 200 Hz; +#X text 60 294 ~signal_out~; +#X floatatom 207 279 7 0 0 0 - - -; +#X text 258 280 dB; +#X floatatom 121 154 9 0 22000 0 - - -; +#X text 185 155 Hz; +#X floatatom 48 115 3 15 133 0 - - -; +#X floatatom 13 84 5 0 0 0 - - -; +#X text 53 85 % cpu; +#X floatatom 181 256 5 2 9999 0 - - -; +#X text 222 257 ms; +#X obj 13 64 dsp; +#X floatatom 114 218 4 0.01 1000 0 - - -; +#X text 150 218 Q; +#X text 95 351 2.arg: Q [-]; +#X text 95 341 1.arg: center_freq. [Hz]; +#X obj 13 44 tgl 15 0 empty empty empty 8 -8 0 10 -262144 -1 -1 0 1 +; +#X obj 48 347 dac~; +#X obj 48 322 gainvu~ 300; +#X obj 253 157 vu 15 120 empty empty 8 -8 0 10 -66577 -1 1 0; +#X obj 315 191 vsl 15 128 0 127 0 1 empty empty empty 8 -8 0 10 -262144 +-1 -1 8000 1; +#X obj 48 134 testtone~ 200; +#X obj 112 98 init 69; +#X text 75 116 midi; +#X text 95 371 4.arg: interpolation_time [ms]; +#X text 95 361 3.arg: level [dB]; +#X obj 48 280 para_bp2~ 440 2 -12 200; +#X floatatom 147 237 6 -40 40 0 - - -; +#X text 191 238 dB; +#X floatatom 302 339 7 0 0 0 - - -; +#X text 353 340 dB; +#X text 137 2 parametric bandpass 2.order; +#X obj 7 7 cnv 8 1 1 empty empty para_bp2~ 1 2 1 18 -262144 -1109 0 +; +#X text 115 428 IEM KUG; +#X text 99 416 musil; +#X text 129 416 @; +#X text 135 416 iem.at; +#X text 50 405 (c) Thomas Musil 2000 - 2005; +#X text 98 438 Graz \, Austria; +#X connect 2 0 3 0; +#X connect 3 0 4 0; +#X connect 4 0 31 1; +#X connect 11 0 26 0; +#X connect 14 0 31 4; +#X connect 16 0 12 0; +#X connect 17 0 31 2; +#X connect 21 0 16 0; +#X connect 23 0 22 0; +#X connect 23 0 22 1; +#X connect 23 1 34 0; +#X connect 23 2 24 0; +#X connect 24 1 7 0; +#X connect 25 0 23 1; +#X connect 26 0 31 0; +#X connect 26 1 9 0; +#X connect 27 0 11 0; +#X connect 31 0 23 0; +#X connect 32 0 31 3; diff --git a/iemlib1/peakenv~-help.pd b/iemlib1/peakenv~-help.pd new file mode 100644 index 0000000..c08d199 --- /dev/null +++ b/iemlib1/peakenv~-help.pd @@ -0,0 +1,38 @@ +#N canvas 190 268 481 430 10; +#X msg 10 143 0; +#X msg 43 143 1; +#X obj 45 168 sig~; +#X floatatom 45 336 9 0 0 0 - - -; +#X msg 148 207 reset; +#X msg 81 144 10; +#X text 50 207 ~signal_in~; +#X text 42 39 dsp ON/OFF; +#X obj 14 59 dsp; +#X floatatom 14 80 3 0 0 0 - - -; +#X text 41 81 % cpu; +#X obj 45 237 peakenv~ 1000; +#X text 123 337 1.output: peak-envelope; +#X text 136 255 (output_envelope decrements about 63% in this time) +; +#X obj 45 260 unsig~ 50; +#X text 187 206 resets peak-envelope to 0; +#X text 133 241 1.arg: time-constant [ms] (default: 0 ms); +#X text 9 7 peakenv~; +#X text 86 4 signal-peak-envelope; +#X obj 14 41 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X text 115 388 IEM KUG; +#X text 99 376 musil; +#X text 129 376 @; +#X text 135 376 iem.at; +#X text 50 365 (c) Thomas Musil 2000 - 2005; +#X text 98 398 Graz \, Austria; +#X connect 0 0 2 0; +#X connect 1 0 2 0; +#X connect 2 0 11 0; +#X connect 4 0 11 0; +#X connect 5 0 2 0; +#X connect 8 0 9 0; +#X connect 11 0 14 0; +#X connect 14 0 3 0; +#X connect 19 0 8 0; diff --git a/iemlib1/prvu~-help.pd b/iemlib1/prvu~-help.pd new file mode 100644 index 0000000..b661d9f --- /dev/null +++ b/iemlib1/prvu~-help.pd @@ -0,0 +1,138 @@ +#N canvas 210 11 728 595 10; +#X msg 167 246 0; +#X msg 468 246 0.5; +#X msg 540 246 1; +#X obj 96 283 sig~; +#X floatatom 96 481 9 0 0 0 - - -; +#X floatatom 163 435 9 0 0 0 - - -; +#X msg 96 189 reset; +#X msg 96 223 start; +#X msg 96 206 stop; +#X msg 357 246 0.1; +#X msg 321 246 0.01; +#X msg 279 246 0.001; +#X msg 237 246 0.0001; +#X msg 194 246 1e-005; +#X msg 390 246 0.25; +#X msg 427 246 0.316; +#X msg 499 246 0.707; +#X msg 570 246 1.414; +#X msg 612 246 2; +#X msg 645 246 10; +#X text 27 352 ~signal_in~; +#X text 201 47 (periode between 2 output-events); +#X text 32 42 dsp ON/OFF; +#X obj 14 61 dsp; +#X floatatom 14 82 3 0 0 0 - - -; +#X text 41 83 % cpu; +#X obj 96 395 unpack 0 0 0; +#X floatatom 129 458 9 0 0 0 - - -; +#X text 195 459 2.item: peak_level [dB]; +#X text 160 482 1.item: rms_level [dB]; +#X obj 14 40 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 25 381 vu 15 120 empty empty -1 -8 0 8 -66577 -1 1 0; +#X floatatom 96 261 9 0 0 0 - - -; +#X obj 125 303 phasor~; +#X obj 125 322 cos~; +#X obj 96 339 *~; +#X floatatom 24 524 6 0 0 0 - - -; +#X floatatom 34 508 6 0 0 0 - - -; +#X text 181 151 4.arg:overflow_threshold [dB] (default: -0.01 +dB); +#X text 200 85 (repeat the peak on output until peakholdtime); +#X text 106 377 output: of 3 items:; +#X text 229 435 3.item: overflow_per_metrotime_counter [-] +; +#X msg 96 51 t_metro \$1; +#X msg 96 89 t_hold \$1; +#X msg 96 127 t_release \$1; +#X msg 96 166 threshold \$1; +#X floatatom 96 34 9 50 500 0 - - -; +#X floatatom 96 72 9 10 5000 0 - - -; +#X floatatom 96 110 9 50 2000 0 - - -; +#X text 204 120 (output_level decrements by about 8.6 dB = 63% during +this; +#X text 556 120 time); +#X floatatom 96 149 9 -120 30 0 - - -; +#X text 201 162 (output_overflow_counter increments by 1 per metrotime +\, if; +#X text 553 162 peaklevel > threshold); +#X obj 24 557 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 34 540 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 21 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 218 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 233 * 0.99; +#X obj 21 252 + 0.01; +#X obj 21 199 metro 2567; +#X obj 96 361 prvu~; +#X text 181 36 1.arg:metrotime [ms] (default: 300 ms); +#X text 181 109 3.arg:releasetime [ms] (default: 300 ms); +#X text 180 74 2.arg:peakholdtime [ms] (default: 1000 ms); +#X obj 125 283 sig~ 10001; +#X text 7 8 prvu~; +#X text 67 8 peak- rms- vu-meter; +#X text 134 188 reset peak- and rms-level to; +#X text 307 188 -99.9 dB and overflow_counter to 0; +#X text 134 205 stop the metro-clock of prvu~; +#X text 134 223 start the metro-clock of prvu~; +#X text 78 509 dB; +#X text 68 525 dB; +#X obj 167 361 prvu~ 300 1000 300 -0.01; +#X text 175 538 IEM KUG; +#X text 159 526 musil; +#X text 189 526 @; +#X text 195 526 iem.at; +#X text 110 515 (c) Thomas Musil 2000 - 2005; +#X text 158 548 Graz \, Austria; +#X connect 0 0 32 0; +#X connect 1 0 32 0; +#X connect 2 0 32 0; +#X connect 3 0 35 0; +#X connect 6 0 61 0; +#X connect 7 0 61 0; +#X connect 8 0 61 0; +#X connect 9 0 32 0; +#X connect 10 0 32 0; +#X connect 11 0 32 0; +#X connect 12 0 32 0; +#X connect 13 0 32 0; +#X connect 14 0 32 0; +#X connect 15 0 32 0; +#X connect 16 0 32 0; +#X connect 17 0 32 0; +#X connect 18 0 32 0; +#X connect 19 0 32 0; +#X connect 23 0 24 0; +#X connect 26 0 4 0; +#X connect 26 1 27 0; +#X connect 26 2 5 0; +#X connect 30 0 23 0; +#X connect 31 0 36 0; +#X connect 31 1 37 0; +#X connect 32 0 3 0; +#X connect 33 0 34 0; +#X connect 34 0 35 1; +#X connect 35 0 61 0; +#X connect 36 0 54 0; +#X connect 37 0 55 0; +#X connect 42 0 61 0; +#X connect 43 0 61 0; +#X connect 44 0 61 0; +#X connect 45 0 61 0; +#X connect 46 0 42 0; +#X connect 47 0 43 0; +#X connect 48 0 44 0; +#X connect 51 0 45 0; +#X connect 56 0 60 0; +#X connect 57 0 58 0; +#X connect 58 0 59 0; +#X connect 59 0 32 0; +#X connect 60 0 57 0; +#X connect 61 0 26 0; +#X connect 61 0 31 0; +#X connect 65 0 33 0; diff --git a/iemlib1/pvu~-help.pd b/iemlib1/pvu~-help.pd new file mode 100644 index 0000000..19227b2 --- /dev/null +++ b/iemlib1/pvu~-help.pd @@ -0,0 +1,120 @@ +#N canvas 210 11 730 597 10; +#X msg 167 246 0; +#X msg 468 246 0.5; +#X msg 540 246 1; +#X obj 96 283 sig~; +#X floatatom 115 415 9 0 0 0 - - -; +#X msg 96 189 reset; +#X msg 96 223 start; +#X msg 96 206 stop; +#X msg 357 246 0.1; +#X msg 321 246 0.01; +#X msg 279 246 0.001; +#X msg 237 246 0.0001; +#X msg 194 246 1e-005; +#X msg 390 246 0.25; +#X msg 427 246 0.316; +#X msg 499 246 0.707; +#X msg 570 246 1.414; +#X msg 612 246 2; +#X msg 645 246 10; +#X text 27 352 ~signal_in~; +#X text 201 81 (periode between 2 output-events); +#X text 32 42 dsp ON/OFF; +#X obj 14 61 dsp; +#X floatatom 14 82 3 0 0 0 - - -; +#X text 41 83 % cpu; +#X floatatom 96 435 9 0 0 0 - - -; +#X obj 14 40 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 25 381 vu 15 120 empty empty -1 -8 0 8 -66577 -1 1 0; +#X floatatom 96 261 9 0 0 0 - - -; +#X obj 125 303 phasor~; +#X obj 125 322 cos~; +#X obj 96 339 *~; +#X floatatom 34 508 6 0 0 0 - - -; +#X msg 96 85 t_metro \$1; +#X msg 96 127 t_release \$1; +#X msg 96 166 threshold \$1; +#X floatatom 96 68 9 50 500 0 - - -; +#X floatatom 96 110 9 50 2000 0 - - -; +#X text 204 120 (output_level decrements by about 8.6 dB = 63% during +this; +#X text 556 120 time); +#X floatatom 96 149 9 -120 30 0 - - -; +#X text 201 162 (output_overflow_counter increments by 1 per metrotime +\, if; +#X text 553 162 peaklevel > threshold); +#X obj 34 540 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 21 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 218 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 233 * 0.99; +#X obj 21 252 + 0.01; +#X obj 21 199 metro 2567; +#X text 181 70 1.arg:metrotime [ms] (default: 300 ms); +#X obj 125 283 sig~ 10001; +#X text 78 509 dB; +#X text 7 8 pvu~; +#X text 67 8 peak-vu-meter; +#X obj 96 361 pvu~; +#X text 181 415 2.outlet: overflow_per_metrotime_counter [-] +; +#X text 162 436 1.outlet: peak_level [dB]; +#X text 134 188 reset peak-level to; +#X text 256 189 -199.9 dB and overflow_counter to 0; +#X text 134 204 stop the metro-clock of pvu~; +#X text 134 223 start the metro-clock of pvu~; +#X text 181 109 2.arg:releasetime [ms] (default: 300 ms); +#X text 181 151 3.arg:overflow_threshold [dB] (default: -0.01 +dB); +#X obj 150 361 pvu~ 300 300 -0.01; +#X text 195 528 IEM KUG; +#X text 179 516 musil; +#X text 209 516 @; +#X text 215 516 iem.at; +#X text 130 505 (c) Thomas Musil 2000 - 2005; +#X text 178 538 Graz \, Austria; +#X connect 0 0 28 0; +#X connect 1 0 28 0; +#X connect 2 0 28 0; +#X connect 3 0 31 0; +#X connect 5 0 54 0; +#X connect 6 0 54 0; +#X connect 7 0 54 0; +#X connect 8 0 28 0; +#X connect 9 0 28 0; +#X connect 10 0 28 0; +#X connect 11 0 28 0; +#X connect 12 0 28 0; +#X connect 13 0 28 0; +#X connect 14 0 28 0; +#X connect 15 0 28 0; +#X connect 16 0 28 0; +#X connect 17 0 28 0; +#X connect 18 0 28 0; +#X connect 22 0 23 0; +#X connect 26 0 22 0; +#X connect 27 1 32 0; +#X connect 28 0 3 0; +#X connect 29 0 30 0; +#X connect 30 0 31 1; +#X connect 31 0 54 0; +#X connect 32 0 43 0; +#X connect 33 0 54 0; +#X connect 34 0 54 0; +#X connect 35 0 54 0; +#X connect 36 0 33 0; +#X connect 37 0 34 0; +#X connect 40 0 35 0; +#X connect 44 0 48 0; +#X connect 45 0 46 0; +#X connect 46 0 47 0; +#X connect 47 0 28 0; +#X connect 48 0 45 0; +#X connect 50 0 29 0; +#X connect 54 0 25 0; +#X connect 54 0 27 1; +#X connect 54 1 4 0; diff --git a/iemlib1/rvu~-help.pd b/iemlib1/rvu~-help.pd new file mode 100644 index 0000000..f96c1d7 --- /dev/null +++ b/iemlib1/rvu~-help.pd @@ -0,0 +1,112 @@ +#N canvas 210 11 730 597 10; +#X msg 167 190 0; +#X msg 468 191 0.5; +#X msg 540 191 1; +#X obj 96 229 sig~; +#X floatatom 96 343 9 0 0 0 - - -; +#X msg 96 135 reset; +#X msg 96 169 start; +#X msg 96 152 stop; +#X msg 357 190 0.1; +#X msg 321 190 0.01; +#X msg 279 190 0.001; +#X msg 237 190 0.0001; +#X msg 194 190 1e-005; +#X msg 390 191 0.25; +#X msg 427 191 0.316; +#X msg 499 191 0.707; +#X msg 570 191 1.414; +#X msg 612 191 2; +#X msg 645 191 10; +#X text 27 298 ~signal_in~; +#X text 201 47 (periode between 2 output-events); +#X text 32 42 dsp ON/OFF; +#X obj 14 61 dsp; +#X floatatom 14 82 3 0 0 0 - - -; +#X text 41 83 % cpu; +#X text 160 344 1.item: rms_level [dB]; +#X obj 14 40 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 25 327 vu 15 120 empty empty -1 -8 0 8 -66577 -1 1 0; +#X floatatom 96 207 9 0 0 0 - - -; +#X obj 125 249 phasor~; +#X obj 125 268 cos~; +#X obj 96 285 *~; +#X floatatom 24 470 6 0 0 0 - - -; +#X floatatom 34 454 6 0 0 0 - - -; +#X msg 96 51 t_metro \$1; +#X msg 96 97 t_release \$1; +#X floatatom 96 34 9 50 500 0 - - -; +#X floatatom 96 80 9 50 2000 0 - - -; +#X text 204 90 (output_level decrements by about 8.6 dB = 63% during +this; +#X text 556 91 time); +#X obj 24 503 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 34 486 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 21 116 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 164 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 21 179 * 0.99; +#X obj 21 198 + 0.01; +#X obj 21 145 metro 2567; +#X text 181 36 1.arg:metrotime [ms] (default: 300 ms); +#X obj 125 229 sig~ 10001; +#X text 78 455 dB; +#X text 68 471 dB; +#X text 7 8 rvu~; +#X text 67 7 rms- vu-meter; +#X text 181 79 2.arg:releasetime [ms] (default: 300 ms); +#X obj 96 307 rvu~; +#X text 106 323 output: :; +#X text 134 134 reset rms-level to -99.9 dB; +#X text 134 151 stop the metro-clock of rvu~; +#X text 134 169 start the metro-clock of rvu~; +#X text 195 468 IEM KUG; +#X text 179 456 musil; +#X text 209 456 @; +#X text 215 456 iem.at; +#X text 130 445 (c) Thomas Musil 2000 - 2005; +#X text 178 478 Graz \, Austria; +#X connect 0 0 28 0; +#X connect 1 0 28 0; +#X connect 2 0 28 0; +#X connect 3 0 31 0; +#X connect 5 0 54 0; +#X connect 6 0 54 0; +#X connect 7 0 54 0; +#X connect 8 0 28 0; +#X connect 9 0 28 0; +#X connect 10 0 28 0; +#X connect 11 0 28 0; +#X connect 12 0 28 0; +#X connect 13 0 28 0; +#X connect 14 0 28 0; +#X connect 15 0 28 0; +#X connect 16 0 28 0; +#X connect 17 0 28 0; +#X connect 18 0 28 0; +#X connect 22 0 23 0; +#X connect 26 0 22 0; +#X connect 27 0 32 0; +#X connect 27 1 33 0; +#X connect 28 0 3 0; +#X connect 29 0 30 0; +#X connect 30 0 31 1; +#X connect 31 0 54 0; +#X connect 32 0 40 0; +#X connect 33 0 41 0; +#X connect 34 0 54 0; +#X connect 35 0 54 0; +#X connect 36 0 34 0; +#X connect 37 0 35 0; +#X connect 42 0 46 0; +#X connect 43 0 44 0; +#X connect 44 0 45 0; +#X connect 45 0 28 0; +#X connect 46 0 43 0; +#X connect 48 0 29 0; +#X connect 54 0 27 0; +#X connect 54 0 4 0; diff --git a/iemlib1/sin_phase~-help.pd b/iemlib1/sin_phase~-help.pd new file mode 100644 index 0000000..e1e6b9e --- /dev/null +++ b/iemlib1/sin_phase~-help.pd @@ -0,0 +1,64 @@ +#N canvas 375 118 488 460 10; +#X text 28 48 dsp ON/OFF; +#X floatatom 155 63 3 15 133 0 - - -; +#X obj 155 81 mtof; +#X floatatom 155 102 9 0 22000 0 - - -; +#X text 214 101 Hz; +#X floatatom 294 158 6 -360 360 0 - - -; +#X floatatom 11 88 5 0 0 0 - - -; +#X text 46 87 % cpu; +#X obj 11 68 dsp; +#X obj 11 48 tgl 15 0 empty empty empty 8 -8 0 10 -262144 -1 -1 0 1 +; +#X text 10 7 sin_phase~; +#X text 105 8 calculate phase-difference between 2; +#X text 105 20 sine-waves \, in samples (signal-out); +#X obj 155 241 sin_phase~; +#X obj 209 216 cos~; +#X obj 154 220 cos~; +#X obj 154 198 +~ 0; +#X obj 155 122 phasor~ 440; +#X text 340 155 percent; +#X text 180 61 midi-pitch; +#X text 295 140 phase-difference; +#X obj 156 264 lp1~ 10 100; +#X obj 157 286 unsig~; +#X floatatom 157 372 5 0 0 0 - - -; +#X obj 157 308 / 44100; +#X floatatom 92 326 5 0 0 0 - - -; +#X obj 157 330 * 10; +#X obj 157 350 * 360; +#X text 195 371 degree; +#X obj 61 268 unsig~; +#X floatatom 61 291 5 0 0 0 - - -; +#X obj 294 181 / 360; +#X obj 268 116 f; +#X text 115 418 IEM KUG; +#X text 99 406 musil; +#X text 129 406 @; +#X text 135 406 iem.at; +#X text 50 395 (c) Thomas Musil 2000 - 2005; +#X text 98 428 Graz \, Austria; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 3 0 17 0; +#X connect 3 0 32 0; +#X connect 5 0 31 0; +#X connect 8 0 6 0; +#X connect 9 0 8 0; +#X connect 13 0 21 0; +#X connect 13 0 29 0; +#X connect 14 0 13 1; +#X connect 15 0 13 0; +#X connect 16 0 15 0; +#X connect 17 0 14 0; +#X connect 17 0 16 0; +#X connect 21 0 22 0; +#X connect 22 0 24 0; +#X connect 22 0 25 0; +#X connect 24 0 26 0; +#X connect 26 0 27 0; +#X connect 27 0 23 0; +#X connect 29 0 30 0; +#X connect 31 0 16 1; +#X connect 32 0 26 1; diff --git a/iemlib1/soundfile_info-help.pd b/iemlib1/soundfile_info-help.pd new file mode 100644 index 0000000..631960c --- /dev/null +++ b/iemlib1/soundfile_info-help.pd @@ -0,0 +1,36 @@ +#N canvas 153 56 725 412 10; +#X obj 31 45 openpanel; +#X obj 31 26 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 31 92 read \$1; +#X obj 31 166 soundfile_info; +#X obj 31 217 print; +#X text 40 146 "read"-message needs a symbol (soundfile in wave format) +; +#X symbolatom 131 75 66 0 0 0 - - -; +#X text 50 184 "list"-message output with 7 items; +#X text 91 224 4.item: header-size in bytes; +#X text 91 194 1.item: samplerate in Hz; +#X text 91 204 2.item: file-name; +#X text 91 234 5.item: number of channels; +#X text 7 2 soundfile_info; +#X text 130 2 show the header-data of a wav-file; +#X text 91 254 7.item: endianness ("l" for little); +#X text 260 264 ("b" for big); +#X text 214 279 (eg. little endian "wav" is natural format on Intel-machines) +; +#X text 214 314 (eg. big endian "aiff" is natural format on Macintosh-machines) +; +#X text 91 214 3.item: sound-data-length in samples; +#X text 91 244 6.item: sample-resolution in bytes; +#X text 95 328 IEM KUG; +#X text 79 316 musil; +#X text 109 316 @; +#X text 115 316 iem.at; +#X text 30 305 (c) Thomas Musil 2000 - 2005; +#X text 78 338 Graz \, Austria; +#X connect 0 0 2 0; +#X connect 0 0 6 0; +#X connect 1 0 0 0; +#X connect 2 0 3 0; +#X connect 3 0 4 0; diff --git a/iemlib1/split-help.pd b/iemlib1/split-help.pd new file mode 100644 index 0000000..69c1907 --- /dev/null +++ b/iemlib1/split-help.pd @@ -0,0 +1,31 @@ +#N canvas 168 213 427 347 10; +#X obj 21 212 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X obj 58 170 bng 15 250 50 0 empty empty empty 8 -8 0 10 -262144 -1 +-1; +#X text 41 253 (c) miller puckette; +#X text 7 8 split; +#X obj 21 130 split 5; +#X text 35 243 the original object moses; +#X floatatom 21 65 4 0 0 0 - - -; +#X floatatom 58 109 4 0 0 0 - - -; +#X floatatom 21 192 4 0 0 0 - - -; +#X floatatom 58 150 4 0 0 0 - - -; +#X text 19 50 input_value ; +#X text 52 8 part -messages into less and greater equal than +limit; +#X text 60 94 limit ; +#X text 92 150 output: input greater equal than limit; +#X text 55 193 output: input less than limit; +#X text 115 308 IEM KUG; +#X text 99 296 musil; +#X text 129 296 @; +#X text 135 296 iem.at; +#X text 50 285 (c) Thomas Musil 2000 - 2005; +#X text 98 318 Graz \, Austria; +#X connect 4 0 8 0; +#X connect 4 1 9 0; +#X connect 6 0 4 0; +#X connect 7 0 4 1; +#X connect 8 0 0 0; +#X connect 9 0 1 0; diff --git a/iemlib1/src/FIR~.c b/iemlib1/src/FIR~.c new file mode 100644 index 0000000..05bf267 --- /dev/null +++ b/iemlib1/src/FIR~.c @@ -0,0 +1,169 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + + +/* ---------- FIR~ - FIR-filter with table-coef ----------- */ + +typedef struct _FIR_tilde +{ + t_object x_obj; + t_float *x_coef_beg; + t_float *x_history_beg; + int x_rw_index; + int x_fir_order; + t_symbol *x_table_name; + t_float x_msi; +} t_FIR_tilde; + +t_class *FIR_tilde_class; + +static t_int *FIR_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_FIR_tilde *x = (t_FIR_tilde *)(w[3]); + int n = (t_int)(w[4]); + int rw_index = x->x_rw_index; + int i, j; + int order = x->x_fir_order; + int ord16 = order / 16; + t_float sum=0.0f; + t_float *coef = x->x_coef_beg; + t_float *write_hist1=x->x_history_beg; + t_float *write_hist2; + t_float *read_hist; + t_float *coef_vec; + t_float *hist_vec; + + if(!coef) + goto FIR_tildeperfzero; + + write_hist1 = x->x_history_beg; + write_hist2 = write_hist1 + order; + read_hist = write_hist2; + + for(i=0; i= order) + rw_index -= order; + } + + x->x_rw_index = rw_index; + return(w+5); + +FIR_tildeperfzero: + + while(n--) + *out++ = 0.0f; + return(w+5); +} + +void FIR_tilde_set(t_FIR_tilde *x, t_symbol *table_name, t_floatarg forder) +{ + t_garray *ga; + int table_size; + int order = (int)forder; + + x->x_table_name = table_name; + if(!(ga = (t_garray *)pd_findbyclass(x->x_table_name, garray_class))) + { + if(*table_name->s_name) + error("FIR~: %s: no such table~", x->x_table_name->s_name); + x->x_coef_beg = 0; + } + else if(!garray_getfloatarray(ga, &table_size, &x->x_coef_beg)) + { + error("%s: bad template for FIR~", x->x_table_name->s_name); + x->x_coef_beg = 0; + } + else if(table_size < order) + { + error("FIR~: tablesize %d < order %d !!!!", table_size, order); + x->x_coef_beg = 0; + } + else + garray_usedindsp(ga); + x->x_rw_index = 0; + if(order > x->x_fir_order)/* resize */ + x->x_history_beg = (t_float *)resizebytes(x->x_history_beg, 2*x->x_fir_order*sizeof(t_float), 2*order*sizeof(float)); + x->x_fir_order = order; +} + +static void FIR_tilde_dsp(t_FIR_tilde *x, t_signal **sp) +{ + FIR_tilde_set(x, x->x_table_name, x->x_fir_order); + dsp_add(FIR_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void *FIR_tilde_new(t_symbol *ref, t_floatarg np) +{ + t_FIR_tilde *x = (t_FIR_tilde *)pd_new(FIR_tilde_class); + + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0; + x->x_table_name = ref; + x->x_coef_beg = 0; + if((int)np < 1) + np = 1.0; + x->x_fir_order = (int)np; + x->x_history_beg = (t_float *)getbytes((2*x->x_fir_order)*sizeof(t_float)); + x->x_rw_index = 0; + return(x); +} + +static void FIR_tilde_free(t_FIR_tilde *x) +{ + if(x->x_history_beg) + freebytes(x->x_history_beg, (2*x->x_fir_order)*sizeof(t_float)); +} + +void FIR_tilde_setup(void) +{ + FIR_tilde_class = class_new(gensym("FIR~"), (t_newmethod)FIR_tilde_new, + (t_method)FIR_tilde_free, sizeof(t_FIR_tilde), 0, A_DEFSYM, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(FIR_tilde_class, t_FIR_tilde, x_msi); + class_addmethod(FIR_tilde_class, (t_method)FIR_tilde_dsp, gensym("dsp"), 0); + class_addmethod(FIR_tilde_class, (t_method)FIR_tilde_set, + gensym("set"), A_SYMBOL, A_FLOAT, 0); +// class_sethelpsymbol(FIR_tilde_class, gensym("iemhelp/help-FIR~")); +} diff --git a/iemlib1/src/biquad_freq_resp.c b/iemlib1/src/biquad_freq_resp.c new file mode 100644 index 0000000..e95a84c --- /dev/null +++ b/iemlib1/src/biquad_freq_resp.c @@ -0,0 +1,86 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ------------------------ biquad_freq_resp ------------------- */ +/* -- calculates the frequency responce of a biquad structure -- */ + +typedef struct _biquad_freq_resp +{ + t_object x_obj; + t_float a0; + t_float a1; + t_float a2; + t_float b1; + t_float b2; + t_outlet *x_out_re; + t_outlet *x_out_im; +} t_biquad_freq_resp; + +static t_class *biquad_freq_resp_class; + +static void biquad_freq_resp_float(t_biquad_freq_resp *x, t_floatarg f) +{ + t_float re1, im1, re2, im2; + t_float c, s, a; + + if(f < 0.0f) + f = 0.0f; + else if(f > 180.0f) + f = 180.0; + f *= 3.14159265f; + f /= 180.0f; + + c = cos(f); + s = sin(f); + + re1 = x->a0 + x->a1*c + x->a2*(c*c - s*s); + im1 = x->a1*s + x->a2*2.0f*(s*c); + re2 = 1.0f - x->b1*c - x->b2*(c*c - s*s); + im2 = -x->b1*s - x->b2*2.0f*(s*c); + a = re2*re2 + im2*im2; + outlet_float(x->x_out_im, (re1*im2 - re2*im1)/a);/* because z^-1 = e^-jwt, negative sign */ + outlet_float(x->x_out_re, (re1*re2 + im1*im2)/a); + +} +/* y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2);*/ + +static void biquad_freq_resp_list(t_biquad_freq_resp *x, t_symbol *s, int argc, t_atom *argv) +{ + if((argc == 5)&&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,3)&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,0)) + { + x->b1 = (float)atom_getfloatarg(0, argc, argv); + x->b2 = (float)atom_getfloatarg(1, argc, argv); + x->a0 = (float)atom_getfloatarg(2, argc, argv); + x->a1 = (float)atom_getfloatarg(3, argc, argv); + x->a2 = (float)atom_getfloatarg(4, argc, argv); + } +} + +static void *biquad_freq_resp_new(void) +{ + t_biquad_freq_resp *x = (t_biquad_freq_resp *)pd_new(biquad_freq_resp_class); + x->x_out_re = outlet_new(&x->x_obj, &s_float); + x->x_out_im = outlet_new(&x->x_obj, &s_float); + x->b1 = 0.0f; + x->b2 = 0.0f; + x->a0 = 0.0f; + x->a1 = 0.0f; + x->a2 = 0.0f; + return (x); +} + +void biquad_freq_resp_setup(void) +{ + biquad_freq_resp_class = class_new(gensym("biquad_freq_resp"), (t_newmethod)biquad_freq_resp_new, 0, + sizeof(t_biquad_freq_resp), 0, 0); + class_addfloat(biquad_freq_resp_class, biquad_freq_resp_float); + class_addlist(biquad_freq_resp_class, (t_method)biquad_freq_resp_list); +// class_sethelpsymbol(biquad_freq_resp_class, gensym("iemhelp/help-biquad_freq_resp")); +} diff --git a/iemlib1/src/db2v.c b/iemlib1/src/db2v.c new file mode 100644 index 0000000..0bb1846 --- /dev/null +++ b/iemlib1/src/db2v.c @@ -0,0 +1,38 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* -------- db2v - a techn. dB to rms-value converter. --------- */ + +static t_class *db2v_class; + +t_float db2v(t_float f) +{ + return (f <= -199.9 ? 0 : exp(0.11512925465 * f)); +} + +static void db2v_float(t_object *x, t_floatarg f) +{ + outlet_float(x->ob_outlet, db2v(f)); +} + +static void *db2v_new(void) +{ + t_object *x = (t_object *)pd_new(db2v_class); + outlet_new(x, &s_float); + return (x); +} + +void db2v_setup(void) +{ + db2v_class = class_new(gensym("db2v"), db2v_new, 0, + sizeof(t_object), 0, 0); + class_addfloat(db2v_class, (t_method)db2v_float); +// class_sethelpsymbol(db2v_class, gensym("iemhelp/help-db2v")); +} diff --git a/iemlib1/src/f2note.c b/iemlib1/src/f2note.c new file mode 100644 index 0000000..2630552 --- /dev/null +++ b/iemlib1/src/f2note.c @@ -0,0 +1,183 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ------------------------- f2note ---------------------- */ +/* ------ frequency to note plus cents converter --------- */ + +typedef struct _f2note +{ + t_object x_obj; + void *x_outlet_midi; + void *x_outlet_note; + void *x_outlet_cent; + int x_centomidi; + t_float x_refhz; + t_float x_refexp; + t_float x_reflog; + t_symbol *x_set; +} t_f2note; + +static t_class *f2note_class; + +t_float f2note_mtof(t_f2note *x, t_float midi) +{ + return(x->x_refexp * exp(0.057762265047 * midi)); +} + +t_float f2note_ftom(t_f2note *x, t_float freq) +{ + return (freq > 0 ? 17.31234049 * log(x->x_reflog * freq) : -1500); +} + +void f2note_calc_ref(t_f2note *x) +{ + t_float ln2=log(2.0); + + x->x_refexp = x->x_refhz*exp(-5.75*ln2); + x->x_reflog = 1.0/x->x_refexp; +} + +static void f2note_make_note(char *str, int midi) +{ + int j,k,l=0; + + j = midi / 12; + k = midi % 12; + if(k <= 5) + { + if(k <= 2) + { + if(k==0) + str[l]='c'; + else if(k==1) + { + str[l++]='#'; + str[l]='c'; + } + else + str[l]='d'; + } + else + { + if(k==3) + { + str[l++]='#'; + str[l]='d'; + } + else if(k==4) + str[l]='e'; + else + str[l]='f'; + } + } + else + { + if(k <= 8) + { + if(k==6) + { + str[l++]='#'; + str[l]='f'; + } + else if(k==7) + str[l]='g'; + else + { + str[l++]='#'; + str[l]='g'; + } + } + else + { + if(k==9) + str[l]='a'; + else if(k==10) + { + str[l++]='#'; + str[l]='a'; + } + else + str[l]='h'; + } + } + + if(j < 4) + { + str[l] -= 'a'; + str[l] += 'A'; + } + l++; + if(j < 3) + { + str[l++] = '0' + (char)(3 - j); + } + else if(j > 4) + { + str[l++] = '0' + (char)(j - 4); + } + str[l] = 0; +} + +static void f2note_bang(t_f2note *x) +{ + int i,j; + t_atom at; + char s[4]; + + i = (x->x_centomidi + 50)/100; + j = x->x_centomidi - 100*i; + outlet_float(x->x_outlet_cent, (t_float)j); + f2note_make_note(s, i); + SETSYMBOL(&at, gensym(s)); + outlet_anything(x->x_outlet_note, x->x_set, 1, &at); + outlet_float(x->x_outlet_midi, 0.01f*(t_float)(x->x_centomidi)); +} + +static void f2note_float(t_f2note *x, t_floatarg freq) +{ + x->x_centomidi = (int)(100.0f*f2note_ftom(x, freq) + 0.5f); + f2note_bang(x); +} + +void f2note_ref(t_f2note *x, t_floatarg ref) +{ + x->x_refhz = ref; + f2note_calc_ref(x); +} + +static void *f2note_new(t_floatarg ref) +{ + t_f2note *x = (t_f2note *)pd_new(f2note_class); + + if(ref == 0.0f) + ref=440.0f; + x->x_refhz = ref; + x->x_centomidi = (int)(100.0f*ref + 0.499f); + f2note_calc_ref(x); + x->x_outlet_midi = outlet_new(&x->x_obj, &s_float); + x->x_outlet_note = outlet_new(&x->x_obj, &s_list); + x->x_outlet_cent = outlet_new(&x->x_obj, &s_float); + x->x_set = gensym("set"); + return (x); +} + +static void f2note_free(t_f2note *x) +{ +} + +void f2note_setup(void) +{ + f2note_class = class_new(gensym("f2note"), (t_newmethod)f2note_new, (t_method)f2note_free, + sizeof(t_f2note), 0, A_DEFFLOAT, 0); + class_addbang(f2note_class,f2note_bang); + class_addfloat(f2note_class,f2note_float); + class_addmethod(f2note_class, (t_method)f2note_ref, gensym("ref"), A_FLOAT, 0); +// class_sethelpsymbol(f2note_class, gensym("iemhelp/help-f2note")); +} diff --git a/iemlib1/src/filter~.c b/iemlib1/src/filter~.c new file mode 100644 index 0000000..1a18072 --- /dev/null +++ b/iemlib1/src/filter~.c @@ -0,0 +1,813 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + + +/* ---------- filter~ - slow dynamic filter-kernel 1. and 2. order ----------- */ + +typedef struct _filter_tilde +{ + t_object x_obj; + t_float wn1; + t_float wn2; + t_float a0; + t_float a1; + t_float a2; + t_float b1; + t_float b2; + t_float sr; + t_float cur_f; + t_float cur_l; + t_float cur_a; + t_float cur_b; + t_float delta_f; + t_float delta_a; + t_float delta_b; + t_float end_f; + t_float end_a; + t_float end_b; + t_float ticks_per_interpol_time; + t_float rcp_ticks; + t_float interpol_time; + int ticks; + int counter_f; + int counter_a; + int counter_b; + int inv; + int hp; + int first_order; + int event_mask; + void (*calc)(); + void *x_debug_outlet; + t_atom x_at[5]; + t_float x_msi; +} t_filter_tilde; + +t_class *filter_tilde_class; + +static void filter_tilde_snafu(t_filter_tilde *x) +{ + +} + +static void filter_tilde_lp1(t_filter_tilde *x) +{ + t_float al; + + al = x->cur_a * x->cur_l; + x->a0 = 1.0f/(1.0f + al); + x->a1 = x->a0; + x->b1 = (al - 1.0f)*x->a0; +} + +static void filter_tilde_lp2(t_filter_tilde *x) +{ + t_float l, al, bl2, rcp; + + l = x->cur_l; + al = l*x->cur_a; + bl2 = l*l*x->cur_b + 1.0f; + rcp = 1.0f/(al + bl2); + x->a0 = rcp; + x->a1 = 2.0f*rcp; + x->a2 = x->a0; + x->b1 = rcp*2.0f*(bl2 - 2.0f); + x->b2 = rcp*(al - bl2); +} + +static void filter_tilde_hp1(t_filter_tilde *x) +{ + t_float al, rcp; + + al = x->cur_a * x->cur_l; + rcp = 1.0f/(1.0f + al); + x->a0 = rcp*al; + x->a1 = -x->a0; + x->b1 = rcp*(al - 1.0f); +} + +static void filter_tilde_hp2(t_filter_tilde *x) +{ + t_float l, al, bl2, rcp; + + l = x->cur_l; + bl2 = l*l*x->cur_b + 1.0f; + al = l*x->cur_a; + rcp = 1.0f/(al + bl2); + x->a0 = rcp*(bl2 - 1.0f); + x->a1 = -2.0f*x->a0; + x->a2 = x->a0; + x->b1 = rcp*2.0f*(bl2 - 2.0f); + x->b2 = rcp*(al - bl2); +} + +static void filter_tilde_rp2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a; + rcp = 1.0f/(al + l2); + x->a0 = rcp*l; + x->a2 = -x->a0; + x->b1 = rcp*2.0f*(l2 - 2.0f); + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_bp2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a; + rcp = 1.0f/(al + l2); + x->a0 = rcp*al; + x->a2 = -x->a0; + x->b1 = rcp*2.0f*(l2 - 2.0f); + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_bs2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a; + rcp = 1.0f/(al + l2); + x->a0 = rcp*l2; + x->a1 = rcp*2.0f*(2.0f - l2); + x->a2 = x->a0; + x->b1 = -x->a1; + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_rpw2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a/x->cur_f; + rcp = 1.0f/(al + l2); + x->a0 = rcp*l; + x->a2 = -x->a0; + x->b1 = rcp*2.0f*(l2 - 2.0f); + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_bpw2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a/x->cur_f; + rcp = 1.0f/(al + l2); + x->a0 = rcp*al; + x->a2 = -x->a0; + x->b1 = rcp*2.0f*(l2 - 2.0f); + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_bsw2(t_filter_tilde *x) +{ + t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a/x->cur_f; + rcp = 1.0f/(al + l2); + x->a0 = rcp*l2; + x->a1 = rcp*2.0f*(2.0f - l2); + x->a2 = x->a0; + x->b1 = -x->a1; + x->b2 = rcp*(al - l2); +} + +static void filter_tilde_ap1(t_filter_tilde *x) +{ + t_float al; + + al = x->cur_a * x->cur_l; + x->a0 = (1.0f - al)/(1.0f + al); + x->b1 = -x->a0; +} + +static void filter_tilde_ap2(t_filter_tilde *x) +{ + t_float l, al, bl2, rcp; + + l = x->cur_l; + bl2 = l*l*x->cur_b + 1.0f; + al = l*x->cur_a; + rcp = 1.0f/(al + bl2); + x->a1 = rcp*2.0f*(2.0f - bl2); + x->a0 = rcp*(bl2 - al); + x->b1 = -x->a1; + x->b2 = -x->a0; +} + +/*static void filter_tilde_bp2(t_filter_tilde *x) +{ +t_float l, al, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0; + al = l*x->cur_a; + rcp = 1.0f/(al + l2); + x->a0 = rcp*al; + x->a2 = -x->a0; + x->b1 = rcp*2.0f*(2.0f - l2); + x->b2 = rcp*(l2 - al); +}*/ + +static void filter_tilde_dsp_tick(t_filter_tilde *x) +{ + if(x->event_mask) + { + if(x->counter_f) + { + float l, si, co; + + if(x->counter_f <= 1) + { + x->cur_f = x->end_f; + x->counter_f = 0; + x->event_mask &= 6;/*set event_mask_bit 0 = 0*/ + } + else + { + x->counter_f--; + x->cur_f *= x->delta_f; + } + l = x->cur_f * x->sr; + if(l < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(l > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(l); + co = cos(l); + x->cur_l = co/si; + } + } + if(x->counter_a) + { + if(x->counter_a <= 1) + { + x->cur_a = x->end_a; + x->counter_a = 0; + x->event_mask &= 5;/*set event_mask_bit 1 = 0*/ + } + else + { + x->counter_a--; + x->cur_a *= x->delta_a; + } + } + if(x->counter_b) + { + if(x->counter_b <= 1) + { + x->cur_b = x->end_b; + x->counter_b = 0; + x->event_mask &= 3;/*set event_mask_bit 2 = 0*/ + } + else + { + x->counter_b--; + x->cur_b *= x->delta_b; + } + } + + (*(x->calc))(x); + + /* stability check */ + if(x->first_order) + { + if(x->b1 <= -0.9999998f) + x->b1 = -0.9999998f; + else if(x->b1 >= 0.9999998f) + x->b1 = 0.9999998f; + } + else + { + float discriminant = x->b1 * x->b1 + 4.0f * x->b2; + + if(x->b1 <= -1.9999996f) + x->b1 = -1.9999996f; + else if(x->b1 >= 1.9999996f) + x->b1 = 1.9999996f; + + if(x->b2 <= -0.9999998f) + x->b2 = -0.9999998f; + else if(x->b2 >= 0.9999998f) + x->b2 = 0.9999998f; + + if(discriminant >= 0.0f) + { + if(0.9999998f - x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f - x->b1; + if(0.9999998f + x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f + x->b1; + } + } + } +} + +static t_int *filter_tilde_perform_2o(t_int *w) +{ + t_float *in = (float *)(w[1]); + t_float *out = (float *)(w[2]); + t_filter_tilde *x = (t_filter_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn0, wn1=x->wn1, wn2=x->wn2; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + filter_tilde_dsp_tick(x); + for(i=0; iwn1 = wn1; + x->wn2 = wn2; + return(w+5); +} +/* yn0 = *out; +xn0 = *in; +************* +yn0 = a0*xn0 + a1*xn1 + a2*xn2 + b1*yn1 + b2*yn2; +yn2 = yn1; +yn1 = yn0; +xn2 = xn1; +xn1 = xn0; +************************* +y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2);*/ + +static t_int *filter_tilde_perf8_2o(t_int *w) +{ + t_float *in = (float *)(w[1]); + t_float *out = (float *)(w[2]); + t_filter_tilde *x = (t_filter_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn[10]; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + filter_tilde_dsp_tick(x); + wn[0] = x->wn2; + wn[1] = x->wn1; + for(i=0; iwn1 = wn[1]; + x->wn2 = wn[0]; + return(w+5); +} + +static t_int *filter_tilde_perform_1o(t_int *w) +{ + t_float *in = (float *)(w[1]); + t_float *out = (float *)(w[2]); + t_filter_tilde *x = (t_filter_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn0, wn1=x->wn1; + t_float a0=x->a0, a1=x->a1; + t_float b1=x->b1; + + filter_tilde_dsp_tick(x); + for(i=0; iwn1 = wn1; + return(w+5); +} + +static t_int *filter_tilde_perf8_1o(t_int *w) +{ + t_float *in = (float *)(w[1]); + t_float *out = (float *)(w[2]); + t_filter_tilde *x = (t_filter_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn[9]; + t_float a0=x->a0, a1=x->a1; + t_float b1=x->b1; + + filter_tilde_dsp_tick(x); + wn[0] = x->wn1; + for(i=0; iwn1 = wn[0]; + return(w+5); +} + +static void filter_tilde_ft4(t_filter_tilde *x, t_floatarg t) +{ + int i = (int)((x->ticks_per_interpol_time)*t+0.49999f); + + x->interpol_time = t; + if(i <= 0) + { + x->ticks = 1; + x->rcp_ticks = 1.0; + } + else + { + x->ticks = i; + x->rcp_ticks = 1.0 / (t_float)i; + } +} + +static void filter_tilde_ft3(t_filter_tilde *x, t_floatarg b) +{ + if(b <= 0.0f) + b = 0.000001f; + if(x->hp) + b = 1.0 / b; + if(b != x->cur_b) + { + x->end_b = b; + x->counter_b = x->ticks; + x->delta_b = exp(log(b/x->cur_b)*x->rcp_ticks); + x->event_mask |= 4;/*set event_mask_bit 2 = 1*/ + } +} + +static void filter_tilde_ft2(t_filter_tilde *x, t_floatarg a) +{ + if(a <= 0.0f) + a = 0.000001f; + if(x->inv) + a = 1.0f / a; + if(x->hp) + a /= x->cur_b; + if(a != x->cur_a) + { + x->end_a = a; + x->counter_a = x->ticks; + x->delta_a = exp(log(a/x->cur_a)*x->rcp_ticks); + x->event_mask |= 2;/*set event_mask_bit 1 = 1*/ + } +} + +static void filter_tilde_ft1(t_filter_tilde *x, t_floatarg f) +{ + if(f <= 0.0f) + f = 0.000001f; + if(f != x->cur_f) + { + x->end_f = f; + x->counter_f = x->ticks; + x->delta_f = exp(log(f/x->cur_f)*x->rcp_ticks); + x->event_mask |= 1;/*set event_mask_bit 0 = 1*/ + } +} + +static void filter_tilde_print(t_filter_tilde *x) +{ + // post("fb1 = %g, fb2 = %g, ff1 = %g, ff2 = %g, ff3 = %g", x->b1, x->b2, x->a0, x->a1, x->a2); + x->x_at[0].a_w.w_float = x->b1; + x->x_at[1].a_w.w_float = x->b2; + x->x_at[2].a_w.w_float = x->a0; + x->x_at[3].a_w.w_float = x->a1; + x->x_at[4].a_w.w_float = x->a2; + outlet_list(x->x_debug_outlet, &s_list, 5, x->x_at); +} + +static void filter_tilde_dsp(t_filter_tilde *x, t_signal **sp) +{ + t_float si, co, f; + int i, n=(int)sp[0]->s_n; + + x->sr = 3.14159265358979323846f / (t_float)(sp[0]->s_sr); + x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)+0.49999f); + if(i <= 0) + { + x->ticks = 1; + x->rcp_ticks = 1.0f; + } + else + { + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + } + f = x->cur_f * x->sr; + if(f < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(f > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(f); + co = cos(f); + x->cur_l = co/si; + } + if(x->first_order) + { + if(n&7) + dsp_add(filter_tilde_perform_1o, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + else + dsp_add(filter_tilde_perf8_1o, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + } + else + { + if(n&7) + dsp_add(filter_tilde_perform_2o, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + else + dsp_add(filter_tilde_perf8_2o, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + } +} + +static void *filter_tilde_new(t_symbol *s, int argc, t_atom *argv) +{ + t_filter_tilde *x = (t_filter_tilde *)pd_new(filter_tilde_class); + int i; + t_float si, co, f=0.0f, a=0.0f, b=0.0f, interpol=0.0f; + t_symbol *filt_typ=gensym(""); + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft3")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft4")); + outlet_new(&x->x_obj, &s_signal); + x->x_debug_outlet = outlet_new(&x->x_obj, &s_list); + x->x_msi = 0.0f; + + x->x_at[0].a_type = A_FLOAT; + x->x_at[1].a_type = A_FLOAT; + x->x_at[2].a_type = A_FLOAT; + x->x_at[3].a_type = A_FLOAT; + x->x_at[4].a_type = A_FLOAT; + + x->event_mask = 1; + x->counter_f = 1; + x->counter_a = 0; + x->counter_b = 0; + x->delta_f = 0.0f; + x->delta_a = 0.0f; + x->delta_b = 0.0f; + x->interpol_time = 0.0f; + x->wn1 = 0.0f; + x->wn2 = 0.0f; + x->a0 = 0.0f; + x->a1 = 0.0f; + x->a2 = 0.0f; + x->b1 = 0.0f; + x->b2 = 0.0f; + x->sr = 3.14159265358979323846f / 44100.0f; + x->calc = filter_tilde_snafu; + x->first_order = 0; + if((argc == 5)&&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,3)&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_SYMBOL(argv,0)) + { + filt_typ = atom_getsymbolarg(0, argc, argv); + f = (t_float)atom_getfloatarg(1, argc, argv); + a = (t_float)atom_getfloatarg(2, argc, argv); + b = (t_float)atom_getfloatarg(3, argc, argv); + interpol = (t_float)atom_getfloatarg(4, argc, argv); + } + x->cur_f = f; + f *= x->sr; + if(f < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(f > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(f); + co = cos(f); + x->cur_l = co/si; + } + if(a <= 0.0f) + a = 0.000001f; + if(b <= 0.0f) + b = 0.000001f; + x->cur_b = b; + + if(interpol <= 0.0f) + interpol = 0.0f; + x->interpol_time = interpol; + x->ticks_per_interpol_time = 0.001f * 44100.0f / 64.0f; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)+0.49999f); + if(i <= 0) + { + x->ticks = 1; + x->rcp_ticks = 1.0f; + } + else + { + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + } + + x->calc = filter_tilde_snafu; + + x->cur_a = 1.0f/a; /*a was Q*/ + x->inv = 1; + x->hp = 0; + + if(filt_typ->s_name) + { + if(filt_typ == gensym("ap1")) + { + x->calc = filter_tilde_ap1; + x->a1 = 1.0f; + x->first_order = 1; + } + else if(filt_typ == gensym("ap2")) + { + x->calc = filter_tilde_ap2; + x->a2 = 1.0f; + } + else if(filt_typ == gensym("ap1c")) + { + x->calc = filter_tilde_ap1; + x->a1 = 1.0f; + x->inv = 0; + x->cur_a = a; /*a was damping*/ + x->first_order = 1; + } + else if(filt_typ == gensym("ap2c")) + { + x->calc = filter_tilde_ap2; + x->a2 = 1.0f; + x->inv = 0; + x->cur_a = a; /*a was damping*/ + } + else if(filt_typ == gensym("bpq2")) + { + x->calc = filter_tilde_bp2; + } + else if(filt_typ == gensym("rbpq2")) + { + x->calc = filter_tilde_rp2; + } + else if(filt_typ == gensym("bsq2")) + { + x->calc = filter_tilde_bs2; + } + else if(filt_typ == gensym("bpw2")) + { + x->calc = filter_tilde_bpw2; + x->inv = 0; + x->cur_a = a; /*a was bw*/ + } + else if(filt_typ == gensym("rbpw2")) + { + x->calc = filter_tilde_rpw2; + x->inv = 0; + x->cur_a = a; /*a was bw*/ + } + else if(filt_typ == gensym("bsw2")) + { + x->calc = filter_tilde_bsw2; + x->inv = 0; + x->cur_a = a; /*a was bw*/ + } + else if(filt_typ == gensym("hp1")) + { + x->calc = filter_tilde_hp1; + x->first_order = 1; + } + else if(filt_typ == gensym("hp2")) + { + x->calc = filter_tilde_hp2; + } + else if(filt_typ == gensym("lp1")) + { + x->calc = filter_tilde_lp1; + x->first_order = 1; + } + else if(filt_typ == gensym("lp2")) + { + x->calc = filter_tilde_lp2; + } + else if(filt_typ == gensym("hp1c")) + { + x->calc = filter_tilde_hp1; + x->cur_a = 1.0f / a; + x->first_order = 1; + } + else if(filt_typ == gensym("hp2c")) + { + x->calc = filter_tilde_hp2; + x->inv = 0; + x->cur_a = a / b; + x->cur_b = 1.0f / b; + x->hp = 1; + } + else if(filt_typ == gensym("lp1c")) + { + x->calc = filter_tilde_lp1; + x->inv = 0; + x->cur_a = a; /*a was damping*/ + x->first_order = 1; + } + else if(filt_typ == gensym("lp2c")) + { + x->calc = filter_tilde_lp2; + x->inv = 0; + x->cur_a = a; /*a was damping*/ + } + else + { + post("filter~-Error: 1. initial-arguments: kind: \ +lp1, lp2, hp1, hp2, \ +lp1c, lp2c, hp1c, hp2c, \ +ap1, ap2, ap1c, ap2c, \ +bpq2, rbpq2, bsq2, \ +bpw2, rbpw2, bsw2!"); + } + x->end_f = x->cur_f; + x->end_a = x->cur_a; + x->end_b = x->cur_b; + } + return (x); +} + +void filter_tilde_setup(void) +{ + filter_tilde_class = class_new(gensym("filter~"), (t_newmethod)filter_tilde_new, + 0, sizeof(t_filter_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(filter_tilde_class, t_filter_tilde, x_msi); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_dsp, gensym("dsp"), 0); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_ft2, gensym("ft2"), A_FLOAT, 0); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_ft3, gensym("ft3"), A_FLOAT, 0); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_ft4, gensym("ft4"), A_FLOAT, 0); + class_addmethod(filter_tilde_class, (t_method)filter_tilde_print, gensym("print"), 0); +// class_sethelpsymbol(filter_tilde_class, gensym("iemhelp/help-filter~")); +} diff --git a/iemlib1/src/for++.c b/iemlib1/src/for++.c new file mode 100644 index 0000000..904d81f --- /dev/null +++ b/iemlib1/src/for++.c @@ -0,0 +1,185 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + +/* ----------------------------- for++ -------------------------------- */ +/* -- an internal timed counter (start-, stop-number and metro-time) -- */ + +typedef struct _forpp +{ + t_object x_obj; + int x_beg; + int x_end; + t_float x_delay; + int x_cur; + int x_incr; + void *x_out_end; + void *x_clock; + void *x_clock2; +} t_forpp; + +static t_class *forpp_class; + +static void forpp_tick2(t_forpp *x) +{ + outlet_bang(x->x_out_end); + clock_unset(x->x_clock2); +} + +static void forpp_tick(t_forpp *x) +{ + outlet_float(x->x_obj.ob_outlet, x->x_cur); + x->x_cur += x->x_incr; + if(x->x_incr > 0) + { + if(x->x_cur <= x->x_end) + clock_delay(x->x_clock, x->x_delay); + else + { + clock_unset(x->x_clock); + clock_delay(x->x_clock2, x->x_delay); + } + } + else + { + if(x->x_cur >= x->x_end) + clock_delay(x->x_clock, x->x_delay); + else + { + clock_unset(x->x_clock); + clock_delay(x->x_clock2, x->x_delay); + } + } +} + +static void forpp_bang(t_forpp *x) +{ + x->x_cur = x->x_beg; + outlet_float(x->x_obj.ob_outlet, x->x_cur); + x->x_cur += x->x_incr; + if(x->x_incr > 0) + { + if(x->x_cur <= x->x_end) + clock_delay(x->x_clock, x->x_delay); + else + { + clock_unset(x->x_clock); + clock_delay(x->x_clock2, x->x_delay); + } + } + else + { + if(x->x_cur >= x->x_end) + clock_delay(x->x_clock, x->x_delay); + else + { + clock_unset(x->x_clock); + clock_delay(x->x_clock2, x->x_delay); + } + } + +} + +static void forpp_start(t_forpp *x) +{ + forpp_bang(x); +} + +static void forpp_stop(t_forpp *x) +{ + if(x->x_incr > 0) + x->x_cur = x->x_end + 1; + else + x->x_cur = x->x_end - 1; + clock_unset(x->x_clock); + clock_unset(x->x_clock2); +} + +static void forpp_float(t_forpp *x, t_floatarg beg) +{ + x->x_beg = (int)beg; + if(x->x_end < x->x_beg) + x->x_incr = -1; + else + x->x_incr = 1; +} + +static void forpp_ft1(t_forpp *x, t_floatarg end) +{ + x->x_end = (int)end; + if(x->x_end < x->x_beg) + x->x_incr = -1; + else + x->x_incr = 1; +} + +static void forpp_ft2(t_forpp *x, t_floatarg delay) +{ + if(delay < 0.0) + delay = 0.0; + x->x_delay = delay; +} + +static void forpp_list(t_forpp *x, t_symbol *s, int argc, t_atom *argv) +{ + if(argc == 2) + { + forpp_float(x, atom_getfloatarg(0, argc, argv)); + forpp_ft1(x, atom_getfloatarg(1, argc, argv)); + } + else if(argc == 3) + { + forpp_float(x, atom_getfloatarg(0, argc, argv)); + forpp_ft1(x, atom_getfloatarg(1, argc, argv)); + forpp_ft2(x, atom_getfloatarg(2, argc, argv)); + } +} + +static void *forpp_new(t_floatarg beg, t_floatarg end, t_floatarg delay) +{ + t_forpp *x = (t_forpp *)pd_new(forpp_class); + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); + outlet_new(&x->x_obj, &s_float); + x->x_out_end = outlet_new(&x->x_obj, &s_bang); + x->x_clock = clock_new(x, (t_method)forpp_tick); + x->x_clock2 = clock_new(x, (t_method)forpp_tick2); + x->x_beg = (int)beg; + x->x_end = (int)end; + if(x->x_end < x->x_beg) + x->x_incr = -1; + else + x->x_incr = 1; + if(delay < 0.0) + delay = 0.0; + x->x_delay = delay; + x->x_cur = x->x_beg; + return(x); +} + +static void forpp_ff(t_forpp *x) +{ + clock_free(x->x_clock); + clock_free(x->x_clock2); +} + +void forpp_setup(void) +{ + forpp_class = class_new(gensym("for++"), (t_newmethod)forpp_new, + (t_method)forpp_ff, sizeof(t_forpp), + 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addbang(forpp_class, forpp_bang); + class_addfloat(forpp_class, forpp_float); + class_addlist(forpp_class, forpp_list); + class_addmethod(forpp_class, (t_method)forpp_start, gensym("start"), 0); + class_addmethod(forpp_class, (t_method)forpp_stop, gensym("stop"), 0); + class_addmethod(forpp_class, (t_method)forpp_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(forpp_class, (t_method)forpp_ft2, gensym("ft2"), A_FLOAT, 0); +// class_sethelpsymbol(forpp_class, gensym("iemhelp/help-for++")); +} diff --git a/iemlib1/src/gate.c b/iemlib1/src/gate.c new file mode 100644 index 0000000..0405717 --- /dev/null +++ b/iemlib1/src/gate.c @@ -0,0 +1,78 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + + +/* --------- gate ---------------------- */ +/* ----------- like spigot ------------ */ + +typedef struct _gate +{ + t_object x_obj; + t_float x_state; +} t_gate; + +static t_class *gate_class; + +static void gate_bang(t_gate *x) +{ + if(x->x_state != 0) + outlet_bang(x->x_obj.ob_outlet); +} + +static void gate_pointer(t_gate *x, t_gpointer *gp) +{ + if(x->x_state != 0) + outlet_pointer(x->x_obj.ob_outlet, gp); +} + +static void gate_float(t_gate *x, t_floatarg f) +{ + if(x->x_state != 0) + outlet_float(x->x_obj.ob_outlet, f); +} + +static void gate_symbol(t_gate *x, t_symbol *s) +{ + if(x->x_state != 0) + outlet_symbol(x->x_obj.ob_outlet, s); +} + +static void gate_list(t_gate *x, t_symbol *s, int argc, t_atom *argv) +{ + if(x->x_state != 0) + outlet_list(x->x_obj.ob_outlet, s, argc, argv); +} + +static void gate_anything(t_gate *x, t_symbol *s, int argc, t_atom *argv) +{ + if(x->x_state != 0) + outlet_anything(x->x_obj.ob_outlet, s, argc, argv); +} + +static void *gate_new(t_floatarg f) +{ + t_gate *x = (t_gate *)pd_new(gate_class); + floatinlet_new(&x->x_obj, &x->x_state); + outlet_new(&x->x_obj, 0); + x->x_state = (f==0.0f)?0.0f:1.0f; + return (x); +} + +void gate_setup(void) +{ + gate_class = class_new(gensym("gate"), (t_newmethod)gate_new, 0, + sizeof(t_gate), 0, A_DEFFLOAT, 0); + class_addbang(gate_class, gate_bang); + class_addpointer(gate_class, gate_pointer); + class_addfloat(gate_class, gate_float); + class_addsymbol(gate_class, gate_symbol); + class_addlist(gate_class, gate_list); + class_addanything(gate_class, gate_anything); +// class_sethelpsymbol(gate_class, gensym("iemhelp/help-gate")); +} diff --git a/iemlib1/src/hml_shelf~.c b/iemlib1/src/hml_shelf~.c new file mode 100644 index 0000000..abf2184 --- /dev/null +++ b/iemlib1/src/hml_shelf~.c @@ -0,0 +1,548 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ---------- hml_shelf~ - high-middle-low-shelving filter ----------- */ + +typedef struct _hml_shelf_tilde +{ + t_object x_obj; + t_float wn1; + t_float wn2; + t_float a0; + t_float a1; + t_float a2; + t_float b1; + t_float b2; + t_float sr; + t_float cur_lf; + t_float cur_hf; + t_float cur_lg; + t_float cur_mg; + t_float cur_hg; + t_float delta_lf; + t_float delta_hf; + t_float delta_lg; + t_float delta_mg; + t_float delta_hg; + t_float end_lf; + t_float end_hf; + t_float end_lg; + t_float end_mg; + t_float end_hg; + t_float ticks_per_interpol_time; + t_float rcp_ticks; + t_float interpol_time; + int ticks; + int counter_lf; + int counter_hf; + int counter_lg; + int counter_mg; + int counter_hg; + int event_mask; + void *x_debug_outlet; + t_atom x_at[5]; + t_float x_msi; +} t_hml_shelf_tilde; + +t_class *hml_shelf_tilde_class; + +static void hml_shelf_tilde_calc(t_hml_shelf_tilde *x) +{ + t_float rf = x->cur_hf/x->cur_lf; + t_float mf = x->cur_hf*x->cur_lf; + t_float lg = x->cur_lg; + t_float rcplg = 1.0f/lg; + t_float mg = x->cur_mg; + t_float rcpmg = 1.0f/mg; + t_float hg = x->cur_hg; + t_float rcphg = 1.0f/hg; + t_float f = mf*x->sr; + t_float l = cos(f)/sin(f); + t_float k1 = rf*l; + t_float k2 = l/rf; + t_float k3 = l*l; + t_float k4 = k3*hg; + t_float k5 = k3*rcphg; + t_float k6 = rcplg + k5; + t_float k7 = rcpmg*k1 + k2*rcplg*rcphg*mg; + t_float k8 = lg + k4; + t_float k9 = mg*k1 + k2*lg*hg*rcpmg; + t_float k10 = 1.0f/(k6 + k7); + + x->b2 = k10*(k7 - k6); + x->b1 = k10*2.0f*(k5 - rcplg); + x->a2 = k10*(k8 - k9); + x->a1 = k10*2.0f*(lg - k4); + x->a0 = k10*(k8 + k9); +} + +/* +high- & low- shelving-filter: +L....sqrt(lowlevel); +rL...rsqrt(lowlevel); +M....sqrt(mediumlevel); +rM...rsqrt(mediumlevel); +H....sqrt(highlevel); +rH...rsqrt(highlevel); +V....sqrt(highfrequency/lowfrequency); +P....j*2*pi*f/(2*pi*V*lowfrequency); + +Y/X = [M/(1/M)] * [(L/M + PV)/(M/L + PV)] * [(1 + HP/(VM))/(1 + MP/(VH))]; +Y/X = (L + P*(M*V + L*H/(V*M)) + P*P*H) / (rL + P*(rM*V + rL*rH/(V*rM)) + P*P*rH); + +hlshlv: lowlevel: ll; mediumlevel: lm; highlevel: hl; lowfrequency: fl; highfrequency: fh; samplerate: sr; + +V = sqrt(fh/fl); +f = fl*V; +L = sqrt(ll); +rL = 1.0/L; +M = sqrt(lm); +rM = 1.0/M; +H = sqrt(lh); +rH = 1.0/H; + +l = cot(f*3.14159265358979323846/sr); +k1 = V*l; +k2 = l/V; +l2 = l*l; +l3 = l2*H; +l4 = l2*rH; +m1 = k2*L*H*rM; +m2 = k2*rL*rH*M; +n1 = rL + l4; +n2 = rM*k1 + m2; +p1 = L + l3; +p2 = M*k1 + m1; +a012 = 1.0/(n1 + n2); + +b2 = a012*(n2 - n1); +b1 = a012*2.0*(l4 - rL); +a2 = a012*(p1 - p2); +a1 = a012*2.0*(L - l3); +a0 = a012*(p1 + p2); + +rf = sqrt(fh/fl); +mf = fl*rf; +L = sqrt(ll); +rL = 1.0/L; +M = sqrt(lm); +rM = 1.0/M; +H = sqrt(lh); +rH = 1.0/H; + +l = cot(fm*3.14159265358979323846/sr); +k1 = V*l; +k2 = l/V; +k3 = l*l; +k4 = k3*H; +k5 = k3*rH; +k6 = rL + k5; +k7 = rM*k1 + k2*rL*rH*M; +k8 = L + k4; +k9 = M*k1 + k2*L*H*rM; +k10 = 1.0/(k6 + k7); + +b2 = k10*(k7 - k6); +b1 = k10*2.0*(k5 - rL); +a2 = k10*(k8 - k9); +a1 = k10*2.0*(L - k4); +a0 = k10*(k8 + k9); +*/ + + +static void hml_shelf_tilde_dsp_tick(t_hml_shelf_tilde *x) +{ + if(x->event_mask) + { + t_float discriminant; + + if(x->counter_lg) + { + if(x->counter_lg <= 1) + { + x->cur_lg = x->end_lg; + x->counter_lg = 0; + x->event_mask &= 30;/*set event_mask_bit 0 = 0*/ + } + else + { + x->counter_lg--; + x->cur_lg *= x->delta_lg; + } + } + if(x->counter_lf) + { + if(x->counter_lf <= 1) + { + x->cur_lf = x->end_lf; + x->counter_lf = 0; + x->event_mask &= 29;/*set event_mask_bit 1 = 0*/ + } + else + { + x->counter_lf--; + x->cur_lf *= x->delta_lf; + } + } + if(x->counter_mg) + { + if(x->counter_mg <= 1) + { + x->cur_mg = x->end_mg; + x->counter_mg = 0; + x->event_mask &= 27;/*set event_mask_bit 2 = 0*/ + } + else + { + x->counter_mg--; + x->cur_mg *= x->delta_mg; + } + } + if(x->counter_hf) + { + if(x->counter_hf <= 1) + { + x->cur_hf = x->end_hf; + x->counter_hf = 0; + x->event_mask &= 23;/*set event_mask_bit 3 = 0*/ + } + else + { + x->counter_hf--; + x->cur_hf *= x->delta_hf; + } + } + if(x->counter_hg) + { + if(x->counter_hg <= 1) + { + x->cur_hg = x->end_hg; + x->counter_hg = 0; + x->event_mask &= 15;/*set event_mask_bit 4 = 0*/ + } + else + { + x->counter_hg--; + x->cur_hg *= x->delta_hg; + } + } + hml_shelf_tilde_calc(x); + + /* stability check */ + + discriminant = x->b1 * x->b1 + 4.0f * x->b2; + if(x->b1 <= -1.9999996f) + x->b1 = -1.9999996f; + else if(x->b1 >= 1.9999996f) + x->b1 = 1.9999996f; + + if(x->b2 <= -0.9999998f) + x->b2 = -0.9999998f; + else if(x->b2 >= 0.9999998f) + x->b2 = 0.9999998f; + + if(discriminant >= 0.0f) + { + if(0.9999998f - x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f - x->b1; + if(0.9999998f + x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f + x->b1; + } + } +} + +static t_int *hml_shelf_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_hml_shelf_tilde *x = (t_hml_shelf_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn0, wn1=x->wn1, wn2=x->wn2; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + hml_shelf_tilde_dsp_tick(x); + for(i=0; iwn1 = wn1; + x->wn2 = wn2; + return(w+5); +} + +/* yn0 = *out; +xn0 = *in; +************* +yn0 = a0*xn0 + a1*xn1 + a2*xn2 + b1*yn1 + b2*yn2; +yn2 = yn1; +yn1 = yn0; +xn2 = xn1; +xn1 = xn0; +************************* +y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2); +*/ + +static t_int *hml_shelf_tilde_perf8(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_hml_shelf_tilde *x = (t_hml_shelf_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn[10]; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + hml_shelf_tilde_dsp_tick(x); + wn[0] = x->wn2; + wn[1] = x->wn1; + for(i=0; iwn1 = wn[1]; + x->wn2 = wn[0]; + return(w+5); +} + +static void hml_shelf_tilde_ft6(t_hml_shelf_tilde *x, t_floatarg t) +{ + int i = (int)((x->ticks_per_interpol_time)*t); + + x->interpol_time = t; + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; +} + +static void hml_shelf_tilde_ft5(t_hml_shelf_tilde *x, t_floatarg hl) +{ + t_float hg = exp(0.057564627325 * hl); + + if(hg != x->cur_hg) + { + x->end_hg = hg; + x->counter_hg = x->ticks; + x->delta_hg = exp(log(hg/x->cur_hg)*x->rcp_ticks); + x->event_mask |= 16;/*set event_mask_bit 4 = 1*/ + } +} + +static void hml_shelf_tilde_ft4(t_hml_shelf_tilde *x, t_floatarg hf) +{ + t_float sqhf; + + if(hf <= 0.0f) + hf = 0.000001f; + sqhf = sqrt(hf); + if(sqhf != x->cur_hf) + { + x->end_hf = sqhf; + x->counter_hf = x->ticks; + x->delta_hf = exp(log(sqhf/x->cur_hf)*x->rcp_ticks); + x->event_mask |= 8;/*set event_mask_bit 3 = 1*/ + } +} + +static void hml_shelf_tilde_ft3(t_hml_shelf_tilde *x, t_floatarg ml) +{ + t_float mg = exp(0.057564627325 * ml); + + if(mg != x->cur_mg) + { + x->end_mg = mg; + x->counter_mg = x->ticks; + x->delta_mg = exp(log(mg/x->cur_mg)*x->rcp_ticks); + x->event_mask |= 4;/*set event_mask_bit 2 = 1*/ + } +} + +static void hml_shelf_tilde_ft2(t_hml_shelf_tilde *x, t_floatarg lf) +{ + t_float sqlf; + + if(lf <= 0.0f) + lf = 0.000001f; + sqlf = sqrt(lf); + if(sqlf != x->cur_lf) + { + x->end_lf = sqlf; + x->counter_lf = x->ticks; + x->delta_lf = exp(log(sqlf/x->cur_lf)*x->rcp_ticks); + x->event_mask |= 2;/*set event_mask_bit 1 = 1*/ + } +} + +static void hml_shelf_tilde_ft1(t_hml_shelf_tilde *x, t_floatarg ll) +{ + t_float lg = exp(0.057564627325 * ll); + + if(lg != x->cur_lg) + { + x->end_lg = lg; + x->counter_lg = x->ticks; + x->delta_lg = exp(log(lg/x->cur_lg)*x->rcp_ticks); + x->event_mask |= 1;/*set event_mask_bit 0 = 1*/ + } +} + +static void hml_shelf_tilde_print(t_hml_shelf_tilde *x) +{ + // post("fb1 = %g, fb2 = %g, ff1 = %g, ff2 = %g, ff3 = %g", x->b1, x->b2, x->a0, x->a1, x->a2); + x->x_at[0].a_w.w_float = x->b1; + x->x_at[1].a_w.w_float = x->b2; + x->x_at[2].a_w.w_float = x->a0; + x->x_at[3].a_w.w_float = x->a1; + x->x_at[4].a_w.w_float = x->a2; + outlet_list(x->x_debug_outlet, &s_list, 5, x->x_at); +} + +static void hml_shelf_tilde_dsp(t_hml_shelf_tilde *x, t_signal **sp) +{ + int i, n=(int)sp[0]->s_n; + + x->sr = 3.14159265358979323846f / (t_float)(sp[0]->s_sr); + x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + if(n&7) + dsp_add(hml_shelf_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + else + dsp_add(hml_shelf_tilde_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); +} + +static void *hml_shelf_tilde_new(t_symbol *s, int argc, t_atom *argv) +{ + t_hml_shelf_tilde *x = (t_hml_shelf_tilde *)pd_new(hml_shelf_tilde_class); + int i; + t_float lf=200.0f, hf=2000.0f, ll=0.0f, ml=0.0f, hl=0.0f, interpol=0.0f; + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft3")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft4")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft5")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft6")); + outlet_new(&x->x_obj, &s_signal); + x->x_debug_outlet = outlet_new(&x->x_obj, &s_list); + x->x_msi = 0; + + x->x_at[0].a_type = A_FLOAT; + x->x_at[1].a_type = A_FLOAT; + x->x_at[2].a_type = A_FLOAT; + x->x_at[3].a_type = A_FLOAT; + x->x_at[4].a_type = A_FLOAT; + + x->event_mask = 2; + x->counter_lg = 0; + x->counter_lf = 1; + x->counter_mg = 0; + x->counter_hf = 0; + x->counter_hg = 0; + x->delta_lg = 0.0f; + x->delta_lf = 0.0f; + x->delta_mg = 0.0f; + x->delta_hf = 0.0f; + x->delta_hg = 0.0f; + x->interpol_time = 0.0f; + x->wn1 = 0.0f; + x->wn2 = 0.0f; + x->a0 = 0.0f; + x->a1 = 0.0f; + x->a2 = 0.0f; + x->b1 = 0.0f; + x->b2 = 0.0f; + x->sr = 3.14159265358979323846f / 44100.0f; + if((argc == 6)&&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,3) + &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,0)) + { + ll = (t_float)atom_getfloatarg(0, argc, argv); + lf = (t_float)atom_getfloatarg(1, argc, argv); + ml = (t_float)atom_getfloatarg(2, argc, argv); + hf = (t_float)atom_getfloatarg(3, argc, argv); + hl = (t_float)atom_getfloatarg(4, argc, argv); + interpol = (t_float)atom_getfloatarg(5, argc, argv); + } + x->cur_lg = exp(0.057564627325 * ll); + x->cur_mg = exp(0.057564627325 * ml); + x->cur_hg = exp(0.057564627325 * hl); + if(lf <= 0.0f) + lf = 0.000001f; + if(hf <= 0.0f) + hf = 0.000001f; + x->cur_lf = sqrt(lf); + x->cur_hf = sqrt(hf); + if(interpol < 0.0f) + interpol = 0.0f; + x->interpol_time = interpol; + x->ticks_per_interpol_time = 0.5f; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + x->end_lf = x->cur_lf; + x->end_hf = x->cur_hf; + x->end_lg = x->cur_lg; + x->end_mg = x->cur_mg; + x->end_hg = x->cur_hg; + return(x); +} + +void hml_shelf_tilde_setup(void) +{ + hml_shelf_tilde_class = class_new(gensym("hml_shelf~"), (t_newmethod)hml_shelf_tilde_new, + 0, sizeof(t_hml_shelf_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(hml_shelf_tilde_class, t_hml_shelf_tilde, x_msi); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_dsp, gensym("dsp"), 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft2, gensym("ft2"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft3, gensym("ft3"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft4, gensym("ft4"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft5, gensym("ft5"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_ft6, gensym("ft6"), A_FLOAT, 0); + class_addmethod(hml_shelf_tilde_class, (t_method)hml_shelf_tilde_print, gensym("print"), 0); +// class_sethelpsymbol(hml_shelf_tilde_class, gensym("iemhelp/help-hml_shelf~")); +} diff --git a/iemlib1/src/iem_cot4~.c b/iemlib1/src/iem_cot4~.c new file mode 100644 index 0000000..b4f7d52 --- /dev/null +++ b/iemlib1/src/iem_cot4~.c @@ -0,0 +1,168 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ------------------------ iem_cot4~ ----------------------------- */ + +t_float *iem_cot4_tilde_table_cos=(t_float *)0L; +t_float *iem_cot4_tilde_table_sin=(t_float *)0L; + +static t_class *iem_cot4_tilde_class; + +typedef struct _iem_cot4_tilde +{ + t_object x_obj; + t_float x_sr; + t_float x_msi; +} t_iem_cot4_tilde; + +static t_int *iem_cot4_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_float norm_freq; + t_float hout; + t_iem_cot4_tilde *x = (t_iem_cot4_tilde *)(w[3]); + t_float sr=x->x_sr; + int n = (int)(w[4]); + t_float *ctab = iem_cot4_tilde_table_cos, *stab = iem_cot4_tilde_table_sin; + t_float *caddr, *saddr, cf1, cf2, sf1, sf2, frac; + double dphase; + int normhipart; + int32 mytfi; + union tabfudge tf; + + tf.tf_d = UNITBIT32; + normhipart = tf.tf_i[HIOFFSET]; + +#if 0 /* this is the readable version of the code. */ + while (n--) + { + norm_freq = *in * sr; + if(norm_freq < 0.0001f) + norm_freq = 0.0001f; + else if(norm_freq > 0.9f) + norm_freq = 0.9f; + dphase = (double)(norm_freq * (t_float)(COSTABSIZE)) + UNITBIT32; + tf.tf_d = dphase; + mytfi = tf.tf_i[HIOFFSET] & (COSTABSIZE-1); + saddr = stab + (mytfi); + caddr = ctab + (mytfi); + tf.tf_i[HIOFFSET] = normhipart; + frac = tf.tf_d - UNITBIT32; + sf1 = saddr[0]; + sf2 = saddr[1]; + cf1 = caddr[0]; + cf2 = caddr[1]; + in++; + *out++ = (cf1 + frac * (cf2 - cf1))/(sf1 + frac * (sf2 - sf1)); + } +#endif +#if 1 /* this is the same, unwrapped by hand. prolog beg*/ + n /= 4; + norm_freq = *in * sr; + if(norm_freq < 0.0001f) + norm_freq = 0.0001f; + else if(norm_freq > 0.9f) + norm_freq = 0.9f; + dphase = (double)(norm_freq * (t_float)(COSTABSIZE)) + UNITBIT32; + tf.tf_d = dphase; + mytfi = tf.tf_i[HIOFFSET] & (COSTABSIZE-1); + saddr = stab + (mytfi); + caddr = ctab + (mytfi); + tf.tf_i[HIOFFSET] = normhipart; + in += 4; /*prolog end*/ + while (--n) + { + norm_freq = *in * sr; + if(norm_freq < 0.0001f) + norm_freq = 0.0001f; + else if(norm_freq > 0.9f) + norm_freq = 0.9f; + dphase = (double)(norm_freq * (t_float)(COSTABSIZE)) + UNITBIT32; + frac = tf.tf_d - UNITBIT32; + tf.tf_d = dphase; + sf1 = saddr[0]; + sf2 = saddr[1]; + cf1 = caddr[0]; + cf2 = caddr[1]; + mytfi = tf.tf_i[HIOFFSET] & (COSTABSIZE-1); + saddr = stab + (mytfi); + caddr = ctab + (mytfi); + hout = (cf1 + frac * (cf2 - cf1))/(sf1 + frac * (sf2 - sf1)); + *out++ = hout; + *out++ = hout; + *out++ = hout; + *out++ = hout; + in += 4; + tf.tf_i[HIOFFSET] = normhipart; + }/*epilog beg*/ + frac = tf.tf_d - UNITBIT32; + sf1 = saddr[0]; + sf2 = saddr[1]; + cf1 = caddr[0]; + cf2 = caddr[1]; + hout = (cf1 + frac * (cf2 - cf1))/(sf1 + frac * (sf2 - sf1)); + *out++ = hout; + *out++ = hout; + *out++ = hout; + *out++ = hout; + /*epilog end*/ +#endif + return (w+5); +} + +static void iem_cot4_tilde_dsp(t_iem_cot4_tilde *x, t_signal **sp) +{ + x->x_sr = 2.0f / (t_float)sp[0]->s_sr; + dsp_add(iem_cot4_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void iem_cot4_tilde_maketable(void) +{ + int i; + t_float *fp, phase, fff, phsinc = 0.5*3.141592653 / ((t_float)COSTABSIZE); + union tabfudge tf; + + if(!iem_cot4_tilde_table_sin) + { + iem_cot4_tilde_table_sin = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); + for(i=COSTABSIZE+1, fp=iem_cot4_tilde_table_sin, phase=0; i--; fp++, phase+=phsinc) + *fp = sin(phase); + } + if(!iem_cot4_tilde_table_cos) + { + iem_cot4_tilde_table_cos = (t_float *)getbytes(sizeof(t_float) * (COSTABSIZE+1)); + for(i=COSTABSIZE+1, fp=iem_cot4_tilde_table_cos, phase=0; i--; fp++, phase+=phsinc) + *fp = cos(phase); + } + tf.tf_d = UNITBIT32 + 0.5; + if((unsigned)tf.tf_i[LOWOFFSET] != 0x80000000) + bug("iem_cot4~: unexpected machine alignment"); +} + +static void *iem_cot4_tilde_new(void) +{ + t_iem_cot4_tilde *x = (t_iem_cot4_tilde *)pd_new(iem_cot4_tilde_class); + + outlet_new(&x->x_obj, gensym("signal")); + x->x_msi = 0; + return (x); +} + +void iem_cot4_tilde_setup(void) +{ + iem_cot4_tilde_class = class_new(gensym("iem_cot4~"), (t_newmethod)iem_cot4_tilde_new, 0, + sizeof(t_iem_cot4_tilde), 0, 0); + class_addcreator((t_newmethod)iem_cot4_tilde_new, gensym("iem_cot~"), 0); + CLASS_MAINSIGNALIN(iem_cot4_tilde_class, t_iem_cot4_tilde, x_msi); + class_addmethod(iem_cot4_tilde_class, (t_method)iem_cot4_tilde_dsp, gensym("dsp"), 0); + iem_cot4_tilde_maketable(); +// class_sethelpsymbol(iem_cot4_tilde_class, gensym("iemhelp/help-iem_cot4~")); +} diff --git a/iemlib1/src/iem_delay~.c b/iemlib1/src/iem_delay~.c new file mode 100644 index 0000000..03a1636 --- /dev/null +++ b/iemlib1/src/iem_delay~.c @@ -0,0 +1,201 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" + + +/* -------------------------- iem_delay~ ------------------------------ */ + +static t_class *iem_delay_tilde_class; + +#define IEMDELAY_DEF_VEC_SIZE 64 + +typedef struct _iem_delay_tilde +{ + t_object x_obj; + int x_mallocsize; + t_float x_max_delay_ms; + t_float x_current_delay_ms; + t_float *x_begmem1; + t_float *x_begmem2; + int x_writeindex; + int x_blocksize; + int x_delay_samples; + t_float x_sr; + t_float x_msi; +} t_iem_delay_tilde; + +static void iem_delay_tilde_cur_del(t_iem_delay_tilde *x, t_floatarg f) +{ + if(f < 0.0f) + f = 0.0f; + else if(f > x->x_max_delay_ms) + f = x->x_max_delay_ms; + x->x_current_delay_ms = f; + x->x_delay_samples = (int)(0.001f*x->x_sr * f + 0.5f); +} + +static t_int *iem_delay_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_iem_delay_tilde *x = (t_iem_delay_tilde *)(w[3]); + int n=(int)(w[4]); + int writeindex = x->x_writeindex; + t_float *vec1, *vec2, *vec3; + + vec1 = x->x_begmem1 + writeindex; + vec2 = x->x_begmem2 + writeindex; + vec3 = x->x_begmem2 + writeindex - x->x_delay_samples; + writeindex += n; + while(n--) + { + *vec1++ = *vec2++ = *in++; + *out++ = *vec3++; + } + if(writeindex >= x->x_mallocsize) + { + writeindex -= x->x_mallocsize; + } + x->x_writeindex = writeindex; + return(w+5); +} + +static t_int *iem_delay_tilde_perf8(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_iem_delay_tilde *x = (t_iem_delay_tilde *)(w[3]); + int i, n=(int)(w[4]); + int writeindex = x->x_writeindex; + t_float *vec1, *vec2; + + vec1 = x->x_begmem1 + writeindex; + vec2 = x->x_begmem2 + writeindex; + for(i=0; ix_begmem2 + writeindex - x->x_delay_samples; + for(i=0; i= x->x_mallocsize) + { + writeindex -= x->x_mallocsize; + } + x->x_writeindex = writeindex; + return(w+5); +} + +static void iem_delay_tilde_dsp(t_iem_delay_tilde *x, t_signal **sp) +{ + int blocksize = sp[0]->s_n, i; + + if(!x->x_blocksize)/*first time*/ + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (blocksize - 1)); + nsamps += blocksize; + x->x_mallocsize = nsamps; + x->x_begmem1 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem2 = x->x_begmem1 + x->x_mallocsize; + post("beginn = %x", (unsigned long)x->x_begmem1); + x->x_writeindex = blocksize; + x->x_sr = (t_float)sp[0]->s_sr; + x->x_blocksize = blocksize; + x->x_delay_samples = (int)(0.001f*x->x_sr * x->x_current_delay_ms + 0.5f); + } + else if((x->x_blocksize != blocksize) || ((t_float)sp[0]->s_sr != x->x_sr)) + { + int nsamps = x->x_max_delay_ms * (t_float)sp[0]->s_sr * 0.001f; + + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (blocksize - 1)); + nsamps += blocksize; + + x->x_begmem1 = (t_float *)resizebytes(x->x_begmem1, 2*x->x_mallocsize*sizeof(t_float), 2*nsamps*sizeof(t_float)); + x->x_mallocsize = nsamps; + x->x_begmem2 = x->x_begmem1 + x->x_mallocsize; + post("beginn = %x", (unsigned long)x->x_begmem1); + if(x->x_writeindex >= nsamps) + x->x_writeindex -= nsamps; + x->x_sr = (t_float)sp[0]->s_sr; + x->x_blocksize = blocksize; + x->x_delay_samples = (int)(0.001f*x->x_sr * x->x_current_delay_ms + 0.5f); + } + + if(blocksize&7) + dsp_add(iem_delay_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, blocksize); + else + dsp_add(iem_delay_tilde_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, x, blocksize); +} + +static void *iem_delay_tilde_new(t_floatarg max_delay_ms, t_floatarg current_delay_ms) +{ + t_iem_delay_tilde *x = (t_iem_delay_tilde *)pd_new(iem_delay_tilde_class); + int nsamps; + + if(max_delay_ms < 2.0f) + max_delay_ms = 2.0f; + x->x_max_delay_ms = max_delay_ms; + if(current_delay_ms < 0.0f) + current_delay_ms = 0.0f; + else if(current_delay_ms > max_delay_ms) + current_delay_ms = max_delay_ms; + x->x_current_delay_ms = current_delay_ms; + nsamps = max_delay_ms * sys_getsr() * 0.001f; + if(nsamps < 1) + nsamps = 1; + nsamps += ((- nsamps) & (IEMDELAY_DEF_VEC_SIZE - 1)); + nsamps += IEMDELAY_DEF_VEC_SIZE; + x->x_mallocsize = nsamps; + x->x_begmem1 = (t_float *)getbytes(2 * x->x_mallocsize * sizeof(t_float)); + x->x_begmem2 = x->x_begmem1 + x->x_mallocsize; + x->x_writeindex = IEMDELAY_DEF_VEC_SIZE; + x->x_blocksize = 0; + x->x_sr = 0.0f; + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0.0f; + return (x); +} + +static void iem_delay_tilde_free(t_iem_delay_tilde *x) +{ + freebytes(x->x_begmem1, 2 * x->x_mallocsize * sizeof(t_float)); +} + +void iem_delay_tilde_setup(void) +{ + iem_delay_tilde_class = class_new(gensym("iem_delay~"), (t_newmethod)iem_delay_tilde_new, (t_method)iem_delay_tilde_free, + sizeof(t_iem_delay_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(iem_delay_tilde_class, t_iem_delay_tilde, x_msi); + class_addmethod(iem_delay_tilde_class, (t_method)iem_delay_tilde_dsp, gensym("dsp"), 0); + class_addmethod(iem_delay_tilde_class, (t_method)iem_delay_tilde_cur_del, gensym("ft1"), A_FLOAT, 0); +} diff --git a/iemlib1/src/iem_pow4~.c b/iemlib1/src/iem_pow4~.c new file mode 100644 index 0000000..838ed5f --- /dev/null +++ b/iemlib1/src/iem_pow4~.c @@ -0,0 +1,78 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ------------------------ iem_pow4~ ----------------------------- */ + +static t_class *iem_pow4_tilde_class; + +typedef struct _iem_pow4_tilde +{ + t_object x_obj; + t_float x_exp; + t_float x_msi; +} t_iem_pow4_tilde; + +static void iem_pow4_tilde_ft1(t_iem_pow4_tilde *x, t_floatarg f) +{ + x->x_exp = f; +} + +static t_int *iem_pow4_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_iem_pow4_tilde *x = (t_iem_pow4_tilde *)(w[3]); + t_float y=x->x_exp; + t_float f, g; + int n = (int)(w[4])/4; + + while (n--) + { + f = *in; + if(f < 0.01f) + f = 0.01f; + else if(f > 1000.0f) + f = 1000.0f; + g = log(f); + f = exp(g*y); + *out++ = f; + *out++ = f; + *out++ = f; + *out++ = f; + in += 4; + } + return (w+5); +} + +static void iem_pow4_tilde_dsp(t_iem_pow4_tilde *x, t_signal **sp) +{ + dsp_add(iem_pow4_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void *iem_pow4_tilde_new(t_floatarg f) +{ + t_iem_pow4_tilde *x = (t_iem_pow4_tilde *)pd_new(iem_pow4_tilde_class); + + x->x_exp = f; + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + outlet_new(&x->x_obj, gensym("signal")); + x->x_msi = 0; + return (x); +} + +void iem_pow4_tilde_setup(void) +{ + iem_pow4_tilde_class = class_new(gensym("iem_pow4~"), (t_newmethod)iem_pow4_tilde_new, 0, + sizeof(t_iem_pow4_tilde), 0, A_DEFFLOAT, 0); + class_addcreator((t_newmethod)iem_pow4_tilde_new, gensym("icot~"), 0); + CLASS_MAINSIGNALIN(iem_pow4_tilde_class, t_iem_pow4_tilde, x_msi); + class_addmethod(iem_pow4_tilde_class, (t_method)iem_pow4_tilde_dsp, gensym("dsp"), 0); + class_addmethod(iem_pow4_tilde_class, (t_method)iem_pow4_tilde_ft1, gensym("ft1"), A_FLOAT, 0); +// class_sethelpsymbol(iem_pow4_tilde_class, gensym("iemhelp/help-iem_pow4~")); +} diff --git a/iemlib1/src/iem_sqrt4~.c b/iemlib1/src/iem_sqrt4~.c new file mode 100644 index 0000000..78b4ef6 --- /dev/null +++ b/iemlib1/src/iem_sqrt4~.c @@ -0,0 +1,108 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +#define IEMSQRT4TAB1SIZE 256 +#define IEMSQRT4TAB2SIZE 1024 + +/* ------------------------ iem_sqrt4~ ----------------------------- */ + +t_float *iem_sqrt4_tilde_exptab=(t_float *)0L; +t_float *iem_sqrt4_tilde_mantissatab=(t_float *)0L; + +static t_class *iem_sqrt4_tilde_class; + +typedef struct _iem_sqrt4_tilde +{ + t_object x_obj; + t_float x_msi; +} t_iem_sqrt4_tilde; + +static t_int *iem_sqrt4_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_int n = (t_int)(w[3])/4; + + while(n--) + { + t_float f = *in; + t_float g, h; + long l = *(long *)(in); + + if(f < 0.0f) + { + *out++ = 0.0f; + *out++ = 0.0f; + *out++ = 0.0f; + *out++ = 0.0f; + } + else + { + g = iem_sqrt4_tilde_exptab[(l >> 23) & 0xff] * iem_sqrt4_tilde_mantissatab[(l >> 13) & 0x3ff]; + h = f * (1.5f * g - 0.5f * g * g * g * f); + *out++ = h; + *out++ = h; + *out++ = h; + *out++ = h; + } + in += 4; + } + return(w+4); +} + +static void iem_sqrt4_tilde_dsp(t_iem_sqrt4_tilde *x, t_signal **sp) +{ + dsp_add(iem_sqrt4_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +static void iem_sqrt4_tilde_maketable(void) +{ + int i; + t_float f; + long l; + + if(!iem_sqrt4_tilde_exptab) + { + iem_sqrt4_tilde_exptab = (t_float *)getbytes(sizeof(t_float) * IEMSQRT4TAB1SIZE); + for(i=0; ix_obj, gensym("signal")); + x->x_msi = 0; + return (x); +} + +void iem_sqrt4_tilde_setup(void) +{ + iem_sqrt4_tilde_class = class_new(gensym("iem_sqrt4~"), (t_newmethod)iem_sqrt4_tilde_new, 0, + sizeof(t_iem_sqrt4_tilde), 0, 0); + CLASS_MAINSIGNALIN(iem_sqrt4_tilde_class, t_iem_sqrt4_tilde, x_msi); + class_addmethod(iem_sqrt4_tilde_class, (t_method)iem_sqrt4_tilde_dsp, gensym("dsp"), 0); + iem_sqrt4_tilde_maketable(); +// class_sethelpsymbol(iem_sqrt4_tilde_class, gensym("iemhelp/help-iem_sqrt4~")); +} diff --git a/iemlib1/src/iemlib.h b/iemlib1/src/iemlib.h new file mode 100644 index 0000000..203a5e5 --- /dev/null +++ b/iemlib1/src/iemlib.h @@ -0,0 +1,108 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#ifndef __IEMLIB_H__ +#define __IEMLIB_H__ + + +#define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER) +#define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT) +#define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL) +#define IS_A_DOLLAR(atom,index) ((atom+index)->a_type == A_DOLLAR) +#define IS_A_DOLLSYM(atom,index) ((atom+index)->a_type == A_DOLLSYM) +#define IS_A_SEMI(atom,index) ((atom+index)->a_type == A_SEMI) +#define IS_A_COMMA(atom,index) ((atom+index)->a_type == A_COMMA) + + +#ifdef NT +int sys_noloadbang; +//t_symbol *iemgui_key_sym=0; +#include +#else +extern int sys_noloadbang; +//extern t_symbol *iemgui_key_sym; +#include +#endif + +#define DEFDELVS 64 +#define XTRASAMPS 4 +#define SAMPBLK 4 + + +#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */ + +/* machine-dependent definitions. These ifdefs really +should have been by CPU type and not by operating system! */ +#ifdef IRIX +/* big-endian. Most significant byte is at low address in memory */ +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#define int32 long /* a data type that has 32 bits */ +#else +#ifdef MSW +/* little-endian; most significant byte is at highest address */ +#define HIOFFSET 1 +#define LOWOFFSET 0 +#define int32 long +#else +#ifdef __FreeBSD__ +#include +#if BYTE_ORDER == LITTLE_ENDIAN +#define HIOFFSET 1 +#define LOWOFFSET 0 +#else +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#endif /* BYTE_ORDER */ +#include +#define int32 int32_t +#endif +#ifdef __linux__ + +#include + +#if !defined(__BYTE_ORDER) || !defined(__LITTLE_ENDIAN) +#error No byte order defined +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define HIOFFSET 1 +#define LOWOFFSET 0 +#else +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#endif /* __BYTE_ORDER */ + +#include +#define int32 int32_t + +#else +#ifdef __APPLE__ +#define HIOFFSET 0 /* word offset to find MSB */ +#define LOWOFFSET 1 /* word offset to find LSB */ +#define int32 int /* a data type that has 32 bits */ + +#endif /* __APPLE__ */ +#endif /* __linux__ */ +#endif /* MSW */ +#endif /* SGI */ + +union tabfudge +{ + double tf_d; + int32 tf_i[2]; +}; + +#if defined __i386__ || defined __x86_64__ +#define IEM_DENORMAL(f) ((((*(unsigned int*)&(f))&0x60000000)==0) || \ +(((*(unsigned int*)&(f))&0x60000000)==0x60000000)) +/* more stringent test: anything not between 1e-19 and 1e19 in absolute val */ +#else + +#define IEM_DENORMAL(f) 0 + +#endif + +#endif diff --git a/iemlib1/src/iemlib1.c b/iemlib1/src/iemlib1.c new file mode 100644 index 0000000..e8e7bb9 --- /dev/null +++ b/iemlib1/src/iemlib1.c @@ -0,0 +1,78 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + +static t_class *iemlib1_class; + +static void *iemlib1_new(void) +{ + t_object *x = (t_object *)pd_new(iemlib1_class); + + return (x); +} + +void biquad_freq_resp_setup(void); +void db2v_setup(void); +void f2note_setup(void); +void filter_tilde_setup(void); +void FIR_tilde_setup(void); +void forpp_setup(void); +void gate_setup(void); +void hml_shelf_tilde_setup(void); +void iem_cot4_tilde_setup(void); +void iem_delay_tilde_setup(void); +void iem_pow4_tilde_setup(void); +void iem_sqrt4_tilde_setup(void); +void lp1_t_tilde_setup(void); +void mov_avrg_kern_tilde_setup(void); +void para_bp2_tilde_setup(void); +void peakenv_tilde_setup(void); +void prvu_tilde_setup(void); +void pvu_tilde_setup(void); +void rvu_tilde_setup(void); +void sin_phase_tilde_setup(void); +void soundfile_info_setup(void); +void split_setup(void); +void v2db_setup(void); +void vcf_filter_tilde_setup(void); + +/* ------------------------ setup routine ------------------------- */ + +void iemlib1_setup(void) +{ + iemlib1_class = class_new(gensym("iemlib1"), iemlib1_new, 0, + sizeof(t_object), CLASS_NOINLET, 0); + + biquad_freq_resp_setup(); + db2v_setup(); + f2note_setup(); + filter_tilde_setup(); + FIR_tilde_setup(); + forpp_setup(); + gate_setup(); + hml_shelf_tilde_setup(); + iem_cot4_tilde_setup(); + iem_delay_tilde_setup(); + iem_pow4_tilde_setup(); + iem_sqrt4_tilde_setup(); + lp1_t_tilde_setup(); + mov_avrg_kern_tilde_setup(); + para_bp2_tilde_setup(); + peakenv_tilde_setup(); + prvu_tilde_setup(); + pvu_tilde_setup(); + rvu_tilde_setup(); + sin_phase_tilde_setup(); + soundfile_info_setup(); + split_setup(); + v2db_setup(); + vcf_filter_tilde_setup(); + + post("iemlib1 (R-1.17) library loaded! (c) Thomas Musil 11.2006"); + post(" musil%ciem.at iem KUG Graz Austria", '@'); +} diff --git a/iemlib1/src/iemlib1.dsp b/iemlib1/src/iemlib1.dsp new file mode 100644 index 0000000..9018881 --- /dev/null +++ b/iemlib1/src/iemlib1.dsp @@ -0,0 +1,85 @@ +# Microsoft Developer Studio Project File - Name="iemlib1" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=iemlib1 - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "iemlib1.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "iemlib1.mak" CFG="iemlib1 - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "iemlib1 - Win32 Release" (basierend auf "Win32 (x86) External Target") +!MESSAGE "iemlib1 - Win32 Debug" (basierend auf "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "iemlib1 - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iemlib1.exe" +# PROP Bsc_Name "iemlib1.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "iemlib1 - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iemlib1.exe" +# PROP Bsc_Name "iemlib1.bsc" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "iemlib1 - Win32 Release" +# Name "iemlib1 - Win32 Debug" + +!IF "$(CFG)" == "iemlib1 - Win32 Release" + +!ELSEIF "$(CFG)" == "iemlib1 - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=.\makefile_win +# End Source File +# End Target +# End Project diff --git a/iemlib1/src/iemlib1.dsw b/iemlib1/src/iemlib1.dsw new file mode 100644 index 0000000..0fed87a --- /dev/null +++ b/iemlib1/src/iemlib1.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "iemlib1"=.\iemlib1.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/iemlib1/src/lp1_t~.c b/iemlib1/src/lp1_t~.c new file mode 100644 index 0000000..a4a625f --- /dev/null +++ b/iemlib1/src/lp1_t~.c @@ -0,0 +1,210 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* -- lp1_t~ - slow dynamic lowpass-filter 1. order with tau input --- */ + +typedef struct _lp1_t_tilde +{ + t_object x_obj; + t_float yn1; + t_float c0; + t_float c1; + t_float sr; + t_float cur_t; + t_float delta_t; + t_float end_t; + t_float ticks_per_interpol_time; + t_float rcp_ticks; + t_float interpol_time; + int ticks; + int counter_t; + t_float x_msi; +} t_lp1_t_tilde; + +t_class *lp1_t_tilde_class; + +static void lp1_t_tilde_dsp_tick(t_lp1_t_tilde *x) +{ + if(x->counter_t) + { + if(x->counter_t <= 1) + { + x->cur_t = x->end_t; + x->counter_t = 0; + } + else + { + x->counter_t--; + x->cur_t += x->delta_t; + } + if(x->cur_t == 0.0f) + x->c1 = 0.0f; + else + x->c1 = exp((x->sr)/x->cur_t); + x->c0 = 1.0f - x->c1; + } +} + +static t_int *lp1_t_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_lp1_t_tilde *x = (t_lp1_t_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float yn0, yn1=x->yn1; + t_float c0=x->c0, c1=x->c1; + + lp1_t_tilde_dsp_tick(x); + for(i=0; iyn1 = yn1; + return(w+5); +} + +static t_int *lp1_t_tilde_perf8(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_lp1_t_tilde *x = (t_lp1_t_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float yn[9]; + t_float c0=x->c0, c1=x->c1; + + lp1_t_tilde_dsp_tick(x); + yn[0] = x->yn1; + for(i=0; iyn1 = yn[0]; + return(w+5); +} + +static void lp1_t_tilde_ft2(t_lp1_t_tilde *x, t_floatarg t) +{ + int i = (int)((x->ticks_per_interpol_time)*t); + + x->interpol_time = t; + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; +} + +static void lp1_t_tilde_ft1(t_lp1_t_tilde *x, t_floatarg time_const) +{ + if(time_const < 0.0f) + time_const = 0.0f; + if(time_const != x->cur_t) + { + x->end_t = time_const; + x->counter_t = x->ticks; + x->delta_t = (time_const - x->cur_t) * x->rcp_ticks; + } +} + +static void lp1_t_tilde_dsp(t_lp1_t_tilde *x, t_signal **sp) +{ + int i, n=(int)sp[0]->s_n; + + x->sr = -1000.0f / (t_float)(sp[0]->s_sr); + x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + if(x->cur_t == 0.0f) + x->c1 = 0.0f; + else + x->c1 = exp((x->sr)/x->cur_t); + x->c0 = 1.0f - x->c1; + if(n&7) + dsp_add(lp1_t_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + else + dsp_add(lp1_t_tilde_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); +} + +static void *lp1_t_tilde_new(t_symbol *s, int argc, t_atom *argv) +{ + t_lp1_t_tilde *x = (t_lp1_t_tilde *)pd_new(lp1_t_tilde_class); + int i; + t_float time_const=0.0f, interpol=0.0f; + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0; + x->counter_t = 1; + x->delta_t = 0.0f; + x->interpol_time = 0.0f; + x->yn1 = 0.0f; + x->sr = -1.0f / 44.1f; + if((argc >= 1)&&IS_A_FLOAT(argv,0)) + time_const = (t_float)atom_getfloatarg(0, argc, argv); + if((argc >= 2)&&IS_A_FLOAT(argv,1)) + interpol = (t_float)atom_getfloatarg(1, argc, argv); + if(time_const < 0.0f) + time_const = 0.0f; + x->cur_t = time_const; + if(time_const == 0.0f) + x->c1 = 0.0f; + else + x->c1 = exp((x->sr)/time_const); + x->c0 = 1.0f - x->c1; + if(interpol < 0.0f) + interpol = 0.0f; + x->interpol_time = interpol; + x->ticks_per_interpol_time = 0.5f; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + x->end_t = x->cur_t; + return (x); +} + +void lp1_t_tilde_setup(void) +{ + lp1_t_tilde_class = class_new(gensym("lp1_t~"), (t_newmethod)lp1_t_tilde_new, + 0, sizeof(t_lp1_t_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(lp1_t_tilde_class, t_lp1_t_tilde, x_msi); + class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_dsp, gensym("dsp"), 0); + class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(lp1_t_tilde_class, (t_method)lp1_t_tilde_ft2, gensym("ft2"), A_FLOAT, 0); +// class_sethelpsymbol(lp1_t_tilde_class, gensym("iemhelp/help-lp1_t~")); +} diff --git a/iemlib1/src/makefile b/iemlib1/src/makefile new file mode 100644 index 0000000..f1fa0e4 --- /dev/null +++ b/iemlib1/src/makefile @@ -0,0 +1,4 @@ +TARGET = iemlib1 + +include ../../Make.include + diff --git a/iemlib1/src/makefile.darwin b/iemlib1/src/makefile.darwin new file mode 100644 index 0000000..242c511 --- /dev/null +++ b/iemlib1/src/makefile.darwin @@ -0,0 +1,73 @@ +current: all + +.SUFFIXES: .pd_darwin + +INCLUDE = -I. -I/usr/local/src/pd/src + +LDFLAGS = -export-dynamic -shared +LIB = -ldl -lm -lpthread + +#select either the DBG and OPT compiler flags below: + +CFLAGS = -DPD -DUNIX -g -Wall -W -Werror -Wno-unused \ + -Wno-parentheses -Wno-switch -O2 -fno-strict-aliasing \ + $(INCLUDE) $(UCFLAGS) $(AFLAGS) \ + +MACOSXLINKFLAGS = -bundle -bundle_loader /usr/local/src/pd/bin/pd + +SYSTEM = $(shell uname -m) + +# the sources + +SRC = biquad_freq_resp.c \ + db2v.c \ + f2note.c \ + filter~.c \ + FIR~.c \ + forpp.c \ + gate.c \ + hml_shelf~.c \ + iem_cot4~.c \ + iem_delay~.c \ + iem_pow4~.c \ + iem_sqrt4~.c \ + lp1_t~.c \ + mov_avrg_kern~.c \ + para_bp2~.c \ + peakenv~.c \ + prvu~.c \ + pvu~.c \ + rvu~.c \ + sin_phase~.c \ + soundfile_info.c \ + split.c \ + v2db.c \ + vcf_filter~.c \ + iemlib1.c + +TARGET = iemlib1.pd_darwin + + +OBJ = $(SRC:.c=.o) + +# +# ------------------ targets ------------------------------------ +# + +clean: + rm ../../lib/$(TARGET) + rm *.o + +all: $(OBJ) + @echo :: $(OBJ) + $(CC) $(MACOSXLINKFLAGS) -o $(TARGET) *.o $(LIB) + strip --strip-unneeded $(TARGET) + mv $(TARGET) ../../lib + +$(OBJ) : %.o : %.c + touch $*.c + $(CC) $(CFLAGS) -DPD $(INCLUDE) -c -o $*.o $*.c + + + + diff --git a/iemlib1/src/makefile_linux b/iemlib1/src/makefile_linux new file mode 100644 index 0000000..bc0d68f --- /dev/null +++ b/iemlib1/src/makefile_linux @@ -0,0 +1,69 @@ +current: all + +.SUFFIXES: .pd_linux + +INCLUDE = -I. -I/usr/local/src/pd/src + +LDFLAGS = -export-dynamic -shared +LIB = -ldl -lm -lpthread + +#select either the DBG and OPT compiler flags below: + +CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \ + -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \ + -DDL_OPEN + +SYSTEM = $(shell uname -m) + +# the sources + +SRC = biquad_freq_resp.c \ + db2v.c \ + f2note.c \ + filter~.c \ + FIR~.c \ + forpp.c \ + gate.c \ + hml_shelf~.c \ + iem_cot4~.c \ + iem_delay~.c \ + iem_pow4~.c \ + iem_sqrt4~.c \ + lp1_t~.c \ + mov_avrg_kern~.c \ + para_bp2~.c \ + peakenv~.c \ + prvu~.c \ + pvu~.c \ + rvu~.c \ + sin_phase~.c \ + soundfile_info.c \ + split.c \ + v2db.c \ + vcf_filter~.c \ + iemlib1.c + +TARGET = iemlib1.pd_linux + + +OBJ = $(SRC:.c=.o) + +# +# ------------------ targets ------------------------------------ +# + +clean: + rm $(TARGET) + rm *.o + +all: $(OBJ) + @echo :: $(OBJ) + $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB) + strip --strip-unneeded $(TARGET) + +$(OBJ) : %.o : %.c + $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c + + + + diff --git a/iemlib1/src/makefile_win b/iemlib1/src/makefile_win new file mode 100644 index 0000000..fa89f45 --- /dev/null +++ b/iemlib1/src/makefile_win @@ -0,0 +1,55 @@ +all: ..\iemlib1.dll + +VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98" +PD_INST_PATH = "C:\Programme\pd-0.39-2" +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN +PD_WIN_L_FLAGS = /nologo + +PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ + $(VIS_CPP_PATH)\lib\libc.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + $(VIS_CPP_PATH)\lib\kernel32.lib \ + $(VIS_CPP_PATH)\lib\wsock32.lib \ + $(VIS_CPP_PATH)\lib\winmm.lib \ + $(PD_INST_PATH)\bin\pthreadVC.lib \ + $(PD_INST_PATH)\bin\pd.lib + +SRC = biquad_freq_resp.c \ + db2v.c \ + f2note.c \ + filter~.c \ + FIR~.c \ + for++.c \ + gate.c \ + hml_shelf~.c \ + iem_cot4~.c \ + iem_delay~.c \ + iem_pow4~.c \ + iem_sqrt4~.c \ + lp1_t~.c \ + mov_avrg_kern~.c \ + para_bp2~.c \ + peakenv~.c \ + prvu~.c \ + pvu~.c \ + rvu~.c \ + sin_phase~.c \ + soundfile_info.c \ + split.c \ + v2db.c \ + vcf_filter~.c \ + iemlib1.c + + +OBJ = $(SRC:.c=.obj) + +.c.obj: + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + +..\iemlib1.dll: $(OBJ) + link $(PD_WIN_L_FLAGS) /dll /export:iemlib1_setup \ + /out:..\iemlib1.dll $(OBJ) $(PD_WIN_LIB) + +clean: + del *.obj diff --git a/iemlib1/src/mov_avrg_kern~.c b/iemlib1/src/mov_avrg_kern~.c new file mode 100644 index 0000000..ef7fe3e --- /dev/null +++ b/iemlib1/src/mov_avrg_kern~.c @@ -0,0 +1,135 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + + +/* -- mov_avrg_kern~ - kernel for a moving-average-filter with IIR - */ + +typedef struct _mov_avrg_kern_tilde +{ + t_object x_obj; + double x_wn1; + double x_a0; + double x_sr; + double x_mstime; + int x_nsamps; + int x_counter; + t_float x_msi; +} t_mov_avrg_kern_tilde; + +t_class *mov_avrg_kern_tilde_class; + +static t_int *mov_avrg_kern_tilde_perform(t_int *w) +{ + t_float *in_direct = (t_float *)(w[1]); + t_float *in_delayed = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + t_mov_avrg_kern_tilde *x = (t_mov_avrg_kern_tilde *)(w[4]); + int i, n = (int)(w[5]); + double wn0, wn1=x->x_wn1, a0=x->x_a0; + + if(x->x_counter) + { + int counter = x->x_counter; + + if(counter >= n) + { + x->x_counter = counter - n; + for(i=0; ix_counter = 0; + for(i=0; ix_wn1 = wn1; + return(w+6); +} + +static void mov_avrg_kern_tilde_ft1(t_mov_avrg_kern_tilde *x, t_floatarg mstime) +{ + if(mstime < 0.04) + mstime = 0.04; + x->x_mstime = (double)mstime; + x->x_nsamps = (int)(x->x_sr * x->x_mstime); + x->x_counter = x->x_nsamps; + x->x_wn1 = 0.0; + x->x_a0 = 1.0/(double)(x->x_nsamps); +} + +static void mov_avrg_kern_tilde_reset(t_mov_avrg_kern_tilde *x) +{ + x->x_counter = x->x_nsamps; + x->x_wn1 = 0.0; +} + +static void mov_avrg_kern_tilde_dsp(t_mov_avrg_kern_tilde *x, t_signal **sp) +{ + x->x_sr = 0.001*(double)(sp[0]->s_sr); + x->x_nsamps = (int)(x->x_sr * x->x_mstime); + x->x_counter = x->x_nsamps; + x->x_wn1 = 0.0; + x->x_a0 = 1.0/(double)(x->x_nsamps); + dsp_add(mov_avrg_kern_tilde_perform, 5, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, x, sp[0]->s_n); +} + +static void *mov_avrg_kern_tilde_new(t_floatarg mstime) +{ + t_mov_avrg_kern_tilde *x = (t_mov_avrg_kern_tilde *)pd_new(mov_avrg_kern_tilde_class); + + if(mstime < 0.04) + mstime = 0.04; + x->x_mstime = (double)mstime; + x->x_sr = 44.1; + x->x_nsamps = (int)(x->x_sr * x->x_mstime); + x->x_counter = x->x_nsamps; + x->x_wn1 = 0.0; + x->x_a0 = 1.0/(double)(x->x_nsamps); + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0; + return(x); +} + +void mov_avrg_kern_tilde_setup(void) +{ + mov_avrg_kern_tilde_class = class_new(gensym("mov_avrg_kern~"), (t_newmethod)mov_avrg_kern_tilde_new, + 0, sizeof(t_mov_avrg_kern_tilde), 0, A_FLOAT, 0); + CLASS_MAINSIGNALIN(mov_avrg_kern_tilde_class, t_mov_avrg_kern_tilde, x_msi); + class_addmethod(mov_avrg_kern_tilde_class, (t_method)mov_avrg_kern_tilde_dsp, gensym("dsp"), 0); + class_addmethod(mov_avrg_kern_tilde_class, (t_method)mov_avrg_kern_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(mov_avrg_kern_tilde_class, (t_method)mov_avrg_kern_tilde_reset, gensym("reset"), 0); +} diff --git a/iemlib1/src/para_bp2~.c b/iemlib1/src/para_bp2~.c new file mode 100644 index 0000000..5c5903a --- /dev/null +++ b/iemlib1/src/para_bp2~.c @@ -0,0 +1,418 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + + +/* ---------- para_bp2~ - parametric bandpass 2. order ----------- */ + +typedef struct _para_bp2_tilde +{ + t_object x_obj; + t_float wn1; + t_float wn2; + t_float a0; + t_float a1; + t_float a2; + t_float b1; + t_float b2; + t_float sr; + t_float cur_f; + t_float cur_l; + t_float cur_a; + t_float cur_g; + t_float delta_f; + t_float delta_a; + t_float delta_g; + t_float end_f; + t_float end_a; + t_float end_g; + t_float ticks_per_interpol_time; + t_float rcp_ticks; + t_float interpol_time; + int ticks; + int counter_f; + int counter_a; + int counter_g; + int event_mask; + void *x_debug_outlet; + t_atom x_at[5]; + t_float x_msi; +} t_para_bp2_tilde; + +t_class *para_bp2_tilde_class; + +static void para_bp2_tilde_calc(t_para_bp2_tilde *x) +{ + t_float l, al, gal, l2, rcp; + + l = x->cur_l; + l2 = l*l + 1.0f; + al = l*x->cur_a; + gal = al*x->cur_g; + rcp = 1.0f/(al + l2); + x->a0 = rcp*(l2 + gal); + x->a1 = rcp*2.0f*(2.0f - l2); + x->a2 = rcp*(l2 - gal); + x->b1 = -x->a1; + x->b2 = rcp*(al - l2); +} + +static void para_bp2_tilde_dsp_tick(t_para_bp2_tilde *x) +{ + if(x->event_mask) + { + t_float discriminant; + + if(x->counter_f) + { + t_float l, si, co; + + if(x->counter_f <= 1) + { + x->cur_f = x->end_f; + x->counter_f = 0; + x->event_mask &= 6;/*set event_mask_bit 0 = 0*/ + } + else + { + x->counter_f--; + x->cur_f *= x->delta_f; + } + l = x->cur_f * x->sr; + if(l < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(l > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(l); + co = cos(l); + x->cur_l = co/si; + } + } + if(x->counter_a) + { + if(x->counter_a <= 1) + { + x->cur_a = x->end_a; + x->counter_a = 0; + x->event_mask &= 5;/*set event_mask_bit 1 = 0*/ + } + else + { + x->counter_a--; + x->cur_a *= x->delta_a; + } + } + if(x->counter_g) + { + if(x->counter_g <= 1) + { + x->cur_g = x->end_g; + x->counter_g = 0; + x->event_mask &= 3;/*set event_mask_bit 2 = 0*/ + } + else + { + x->counter_g--; + x->cur_g *= x->delta_g; + } + } + + para_bp2_tilde_calc(x); + + /* stability check */ + + discriminant = x->b1 * x->b1 + 4.0f * x->b2; + if(x->b1 <= -1.9999996f) + x->b1 = -1.9999996f; + else if(x->b1 >= 1.9999996f) + x->b1 = 1.9999996f; + + if(x->b2 <= -0.9999998f) + x->b2 = -0.9999998f; + else if(x->b2 >= 0.9999998f) + x->b2 = 0.9999998f; + + if(discriminant >= 0.0f) + { + if(0.9999998f - x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f - x->b1; + if(0.9999998f + x->b1 - x->b2 < 0.0f) + x->b2 = 0.9999998f + x->b1; + } + } +} + +static t_int *para_bp2_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_para_bp2_tilde *x = (t_para_bp2_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn0, wn1=x->wn1, wn2=x->wn2; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + para_bp2_tilde_dsp_tick(x); + for(i=0; iwn1 = wn1; + x->wn2 = wn2; + return(w+5); +} +/* yn0 = *out; +xn0 = *in; +************* +yn0 = a0*xn0 + a1*xn1 + a2*xn2 + b1*yn1 + b2*yn2; +yn2 = yn1; +yn1 = yn0; +xn2 = xn1; +xn1 = xn0; +************************* +y/x = (a0 + a1*z-1 + a2*z-2)/(1 - b1*z-1 - b2*z-2);*/ + +static t_int *para_bp2_tilde_perf8(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_para_bp2_tilde *x = (t_para_bp2_tilde *)(w[3]); + int i, n = (t_int)(w[4]); + t_float wn[10]; + t_float a0=x->a0, a1=x->a1, a2=x->a2; + t_float b1=x->b1, b2=x->b2; + + para_bp2_tilde_dsp_tick(x); + wn[0] = x->wn2; + wn[1] = x->wn1; + for(i=0; iwn1 = wn[1]; + x->wn2 = wn[0]; + return(w+5); +} + +static void para_bp2_tilde_ft4(t_para_bp2_tilde *x, t_floatarg t) +{ + int i = (int)((x->ticks_per_interpol_time)*t); + + x->interpol_time = t; + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; +} + +static void para_bp2_tilde_ft3(t_para_bp2_tilde *x, t_floatarg l) +{ + t_float g = exp(0.11512925465 * l); + + if(g != x->cur_g) + { + x->end_g = g; + x->counter_g = x->ticks; + x->delta_g = exp(log(g/x->cur_g)*x->rcp_ticks); + x->event_mask |= 4;/*set event_mask_bit 2 = 1*/ + } +} + +static void para_bp2_tilde_ft2(t_para_bp2_tilde *x, t_floatarg q) +{ + t_float a; + + if(q <= 0.0f) + q = 0.000001f; + a = 1.0f/q; + if(a != x->cur_a) + { + x->end_a = a; + x->counter_a = x->ticks; + x->delta_a = exp(log(a/x->cur_a)*x->rcp_ticks); + x->event_mask |= 2;/*set event_mask_bit 1 = 1*/ + } +} + +static void para_bp2_tilde_ft1(t_para_bp2_tilde *x, t_floatarg f) +{ + if(f <= 0.0f) + f = 0.000001f; + if(f != x->cur_f) + { + x->end_f = f; + x->counter_f = x->ticks; + x->delta_f = exp(log(f/x->cur_f)*x->rcp_ticks); + x->event_mask |= 1;/*set event_mask_bit 0 = 1*/ + } +} + +static void para_bp2_tilde_print(t_para_bp2_tilde *x) +{ + // post("fb1 = %g, fb2 = %g, ff1 = %g, ff2 = %g, ff3 = %g", x->b1, x->b2, x->a0, x->a1, x->a2); + x->x_at[0].a_w.w_float = x->b1; + x->x_at[1].a_w.w_float = x->b2; + x->x_at[2].a_w.w_float = x->a0; + x->x_at[3].a_w.w_float = x->a1; + x->x_at[4].a_w.w_float = x->a2; + outlet_list(x->x_debug_outlet, &s_list, 5, x->x_at); +} + +static void para_bp2_tilde_dsp(t_para_bp2_tilde *x, t_signal **sp) +{ + t_float si, co, f; + int i, n=(int)sp[0]->s_n; + + x->sr = 3.14159265358979323846f / (t_float)(sp[0]->s_sr); + x->ticks_per_interpol_time = 0.001f * (t_float)(sp[0]->s_sr) / (t_float)n; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + f = x->cur_f * x->sr; + if(f < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(f > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(f); + co = cos(f); + x->cur_l = co/si; + } + if(n&7) + dsp_add(para_bp2_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); + else + dsp_add(para_bp2_tilde_perf8, 4, sp[0]->s_vec, sp[1]->s_vec, x, n); +} + +static void *para_bp2_tilde_new(t_symbol *s, int argc, t_atom *argv) +{ + t_para_bp2_tilde *x = (t_para_bp2_tilde *)pd_new(para_bp2_tilde_class); + int i; + t_float si, co, f=0.0f, q=1.0f, l=0.0f, interpol=0.0f; + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft3")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft4")); + outlet_new(&x->x_obj, &s_signal); + x->x_debug_outlet = outlet_new(&x->x_obj, &s_list); + x->x_msi = 0; + + x->x_at[0].a_type = A_FLOAT; + x->x_at[1].a_type = A_FLOAT; + x->x_at[2].a_type = A_FLOAT; + x->x_at[3].a_type = A_FLOAT; + x->x_at[4].a_type = A_FLOAT; + + x->event_mask = 1; + x->counter_f = 1; + x->counter_a = 0; + x->counter_g = 0; + x->delta_f = 0.0f; + x->delta_a = 0.0f; + x->delta_g = 0.0f; + x->interpol_time = 500.0f; + x->wn1 = 0.0f; + x->wn2 = 0.0f; + x->a0 = 0.0f; + x->a1 = 0.0f; + x->a2 = 0.0f; + x->b1 = 0.0f; + x->b2 = 0.0f; + x->sr = 3.14159265358979323846f / 44100.0f; + x->cur_a = 1.0f; + if((argc == 4)&&IS_A_FLOAT(argv,3)&&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,0)) + { + f = (t_float)atom_getfloatarg(0, argc, argv); + q = (t_float)atom_getfloatarg(1, argc, argv); + l = (t_float)atom_getfloatarg(2, argc, argv); + interpol = (t_float)atom_getfloatarg(3, argc, argv); + } + if(f <= 0.0f) + f = 0.000001f; + x->cur_f = f; + f *= x->sr; + if(f < 1.0e-20f) + x->cur_l = 1.0e20f; + else if(f > 1.57079632f) + x->cur_l = 0.0f; + else + { + si = sin(f); + co = cos(f); + x->cur_l = co/si; + } + if(q <= 0.0f) + q = 0.000001f; + x->cur_a = 1.0f/q; + x->cur_g = exp(0.11512925465 * l); + if(interpol <= 0.0f) + interpol = 0.0f; + x->interpol_time = interpol; + x->ticks_per_interpol_time = 0.5f; + i = (int)((x->ticks_per_interpol_time)*(x->interpol_time)); + if(i <= 0) + i = 1; + x->ticks = i; + x->rcp_ticks = 1.0f / (t_float)i; + x->end_f = x->cur_f; + x->end_a = x->cur_a; + x->end_g = x->cur_g; + return(x); +} + +void para_bp2_tilde_setup(void) +{ + para_bp2_tilde_class = class_new(gensym("para_bp2~"), (t_newmethod)para_bp2_tilde_new, + 0, sizeof(t_para_bp2_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(para_bp2_tilde_class, t_para_bp2_tilde, x_msi); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_dsp, gensym("dsp"), 0); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_ft2, gensym("ft2"), A_FLOAT, 0); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_ft3, gensym("ft3"), A_FLOAT, 0); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_ft4, gensym("ft4"), A_FLOAT, 0); + class_addmethod(para_bp2_tilde_class, (t_method)para_bp2_tilde_print, gensym("print"), 0); +// class_sethelpsymbol(para_bp2_tilde_class, gensym("iemhelp/help-para_bp2~")); +} diff --git a/iemlib1/src/peakenv~.c b/iemlib1/src/peakenv~.c new file mode 100644 index 0000000..e821c1f --- /dev/null +++ b/iemlib1/src/peakenv~.c @@ -0,0 +1,95 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ---------------- peakenv~ - simple peak-envelope-converter. ----------------- */ + +typedef struct _peakenv_tilde +{ + t_object x_obj; + t_float x_sr; + t_float x_old_peak; + t_float x_c1; + t_float x_releasetime; + t_float x_msi; +} t_peakenv_tilde; + +t_class *peakenv_tilde_class; + +static void peakenv_tilde_reset(t_peakenv_tilde *x) +{ + x->x_old_peak = 0.0f; +} + +static void peakenv_tilde_ft1(t_peakenv_tilde *x, t_floatarg f)/* release-time in ms */ +{ + if(f < 0.0f) + f = 0.0f; + x->x_releasetime = f; + x->x_c1 = exp(-1.0/(x->x_sr*0.001*x->x_releasetime)); +} + +static t_int *peakenv_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[2]); + t_peakenv_tilde *x = (t_peakenv_tilde *)(w[3]); + int n = (int)(w[4]); + t_float peak = x->x_old_peak; + t_float c1 = x->x_c1; + t_float absolute; + int i; + + for(i=0; i peak) + peak = absolute; + *out++ = peak; + } + /* NAN protect */ + if(IEM_DENORMAL(peak)) + peak = 0.0f; + x->x_old_peak = peak; + return(w+5); +} + +static void peakenv_tilde_dsp(t_peakenv_tilde *x, t_signal **sp) +{ + x->x_sr = (t_float)sp[0]->s_sr; + peakenv_tilde_ft1(x, x->x_releasetime); + dsp_add(peakenv_tilde_perform, 4, sp[0]->s_vec, sp[1]->s_vec, x, sp[0]->s_n); +} + +static void *peakenv_tilde_new(t_floatarg f) +{ + t_peakenv_tilde *x = (t_peakenv_tilde *)pd_new(peakenv_tilde_class); + + if(f <= 0.0f) + f = 0.0f; + x->x_sr = 44100.0f; + peakenv_tilde_ft1(x, f); + x->x_old_peak = 0.0f; + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0; + return(x); +} + +void peakenv_tilde_setup(void) +{ + peakenv_tilde_class = class_new(gensym("peakenv~"), (t_newmethod)peakenv_tilde_new, + 0, sizeof(t_peakenv_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(peakenv_tilde_class, t_peakenv_tilde, x_msi); + class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_dsp, gensym("dsp"), 0); + class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_ft1, gensym("ft1"), A_FLOAT, 0); + class_addmethod(peakenv_tilde_class, (t_method)peakenv_tilde_reset, gensym("reset"), 0); +// class_sethelpsymbol(peakenv_tilde_class, gensym("iemhelp/help-peakenv~")); +} diff --git a/iemlib1/src/prvu~.c b/iemlib1/src/prvu~.c new file mode 100644 index 0000000..327774a --- /dev/null +++ b/iemlib1/src/prvu~.c @@ -0,0 +1,274 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ---------------- prvu~ - simple peak&rms-vu-meter. ----------------- */ + +typedef struct _prvu_tilde +{ + t_object x_obj; + t_atom x_at[3]; + void *x_clock_metro; + t_float x_metro_time; + void *x_clock_hold; + t_float x_hold_time; + t_float x_cur_peak; + t_float x_old_peak; + t_float x_hold_peak; + int x_hold; + t_float x_sum_rms; + t_float x_old_rms; + t_float x_rcp; + t_float x_sr; + t_float x_threshold_over; + int x_overflow_counter; + t_float x_release_time; + t_float x_c1; + int x_started; + t_float x_msi; +} t_prvu_tilde; + +t_class *prvu_tilde_class; +static void prvu_tilde_tick_metro(t_prvu_tilde *x); +static void prvu_tilde_tick_hold(t_prvu_tilde *x); + +static void prvu_tilde_reset(t_prvu_tilde *x) +{ + x->x_at[0].a_w.w_float = -99.9f; + x->x_at[1].a_w.w_float = -99.9f; + x->x_at[2].a_w.w_float = 0.0f; + outlet_list(x->x_obj.ob_outlet, &s_list, 3, x->x_at); + x->x_overflow_counter = 0; + x->x_cur_peak = 0.0f; + x->x_old_peak = 0.0f; + x->x_hold_peak = 0.0f; + x->x_sum_rms = 0.0f; + x->x_old_rms = 0.0f; + x->x_hold = 0; + clock_unset(x->x_clock_hold); + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void prvu_tilde_stop(t_prvu_tilde *x) +{ + clock_unset(x->x_clock_metro); + x->x_started = 0; +} + +static void prvu_tilde_start(t_prvu_tilde *x) +{ + clock_delay(x->x_clock_metro, x->x_metro_time); + x->x_started = 1; +} + +static void prvu_tilde_float(t_prvu_tilde *x, t_floatarg f) +{ + if(f == 0.0) + { + clock_unset(x->x_clock_metro); + x->x_started = 0; + } + else + { + clock_delay(x->x_clock_metro, x->x_metro_time); + x->x_started = 1; + } +} + +static void prvu_tilde_t_release(t_prvu_tilde *x, t_floatarg release_time) +{ + if(release_time <= 5.0f) + release_time = 5.0f; + x->x_release_time = release_time; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); +} + +static void prvu_tilde_t_metro(t_prvu_tilde *x, t_floatarg metro_time) +{ + if(metro_time <= 5.0f) + metro_time = 5.0f; + x->x_metro_time = metro_time; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_rcp = 1.0f/(x->x_sr*(t_float)x->x_metro_time); +} + +static void prvu_tilde_t_hold(t_prvu_tilde *x, t_floatarg hold_time) +{ + if(hold_time <= 5.0f) + hold_time = 5.0f; + x->x_hold_time = hold_time; +} + +static void prvu_tilde_threshold(t_prvu_tilde *x, t_floatarg thresh) +{ + x->x_threshold_over = thresh; +} + +static t_int *prvu_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_prvu_tilde *x = (t_prvu_tilde *)(w[2]); + int n = (int)(w[3]); + t_float peak = x->x_cur_peak, power, sum=x->x_sum_rms; + int i; + + if(x->x_started) + { + for(i=0; i peak) + peak = power; + sum += power; + } + x->x_cur_peak = peak; + x->x_sum_rms = sum; + } + return(w+4); +} + +static void prvu_tilde_dsp(t_prvu_tilde *x, t_signal **sp) +{ + x->x_sr = 0.001*(t_float)sp[0]->s_sr; + x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + dsp_add(prvu_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void prvu_tilde_tick_hold(t_prvu_tilde *x) +{ + x->x_hold = 0; + x->x_hold_peak = x->x_old_peak; +} + +static void prvu_tilde_tick_metro(t_prvu_tilde *x) +{ + t_float dbr, dbp, cur_rms, c1=x->x_c1; + + x->x_old_peak *= c1; + /* NAN protect */ + if(IEM_DENORMAL(x->x_old_peak)) + x->x_old_peak = 0.0f; + + if(x->x_cur_peak > x->x_old_peak) + x->x_old_peak = x->x_cur_peak; + if(x->x_old_peak > x->x_hold_peak) + { + x->x_hold = 1; + x->x_hold_peak = x->x_old_peak; + clock_delay(x->x_clock_hold, x->x_hold_time); + } + if(!x->x_hold) + x->x_hold_peak = x->x_old_peak; + if(x->x_hold_peak <= 0.0000000001f) + dbp = -99.9f; + else if(x->x_hold_peak > 1000000.0f) + { + dbp = 60.0f; + x->x_hold_peak = 1000000.0f; + x->x_old_peak = 1000000.0f; + } + else + dbp = 4.3429448195f*log(x->x_hold_peak); + x->x_cur_peak = 0.0f; + if(dbp >= x->x_threshold_over) + x->x_overflow_counter++; + x->x_at[1].a_w.w_float = dbp; + x->x_at[2].a_w.w_float = (t_float)x->x_overflow_counter; + + cur_rms = (1.0f - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; + /* NAN protect */ + if(IEM_DENORMAL(cur_rms)) + cur_rms = 0.0f; + + if(cur_rms <= 0.0000000001f) + dbr = -99.9f; + else if(cur_rms > 1000000.0f) + { + dbr = 60.0f; + x->x_old_rms = 1000000.0f; + } + else + dbr = 4.3429448195f*log(cur_rms); + x->x_sum_rms = 0.0f; + x->x_old_rms = cur_rms; + x->x_at[0].a_w.w_float = dbr; + outlet_list(x->x_obj.ob_outlet, &s_list, 3, x->x_at); + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void prvu_tilde_ff(t_prvu_tilde *x) +{ + clock_free(x->x_clock_metro); + clock_free(x->x_clock_hold); +} + +static void *prvu_tilde_new(t_floatarg metro_time, t_floatarg hold_time, + t_floatarg release_time, t_floatarg threshold) +{ + t_prvu_tilde *x; + t_float t; + int i; + + x = (t_prvu_tilde *)pd_new(prvu_tilde_class); + if(metro_time <= 0.0f) + metro_time = 300.0f; + if(metro_time <= 5.0f) + metro_time = 5.0f; + if(release_time <= 0.0f) + release_time = 300.0f; + if(release_time <= 5.0f) + release_time = 5.0f; + if(hold_time <= 0.0f) + hold_time = 1000.0f; + if(hold_time <= 5.0f) + hold_time = 5.0f; + if(threshold == 0.0f) + threshold = -0.01f; + x->x_metro_time = metro_time; + x->x_release_time = release_time; + x->x_hold_time = hold_time; + x->x_threshold_over = threshold; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_cur_peak = 0.0f; + x->x_old_peak = 0.0f; + x->x_hold_peak = 0.0f; + x->x_hold = 0; + x->x_sum_rms = 0.0f; + x->x_old_rms = 0.0f; + x->x_sr = 44.1f; + x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_overflow_counter = 0; + x->x_clock_metro = clock_new(x, (t_method)prvu_tilde_tick_metro); + x->x_clock_hold = clock_new(x, (t_method)prvu_tilde_tick_hold); + x->x_started = 1; + outlet_new(&x->x_obj, &s_list); + x->x_at[0].a_type = A_FLOAT; + x->x_at[1].a_type = A_FLOAT; + x->x_at[2].a_type = A_FLOAT; + x->x_msi = 0.0f; + return(x); +} + +void prvu_tilde_setup(void) +{ + prvu_tilde_class = class_new(gensym("prvu~"), (t_newmethod)prvu_tilde_new, + (t_method)prvu_tilde_ff, sizeof(t_prvu_tilde), 0, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(prvu_tilde_class, t_prvu_tilde, x_msi); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_dsp, gensym("dsp"), 0); + class_addfloat(prvu_tilde_class, prvu_tilde_float); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_reset, gensym("reset"), 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_start, gensym("start"), 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_stop, gensym("stop"), 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_t_release, gensym("t_release"), A_FLOAT, 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_t_hold, gensym("t_hold"), A_FLOAT, 0); + class_addmethod(prvu_tilde_class, (t_method)prvu_tilde_threshold, gensym("threshold"), A_FLOAT, 0); +// class_sethelpsymbol(prvu_tilde_class, gensym("iemhelp/help-prvu~")); +} diff --git a/iemlib1/src/pvu~.c b/iemlib1/src/pvu~.c new file mode 100644 index 0000000..b619e8e --- /dev/null +++ b/iemlib1/src/pvu~.c @@ -0,0 +1,198 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ---------------- pvu~ - simple peak-vu-meter. ----------------- */ + +typedef struct _pvu_tilde +{ + t_object x_obj; + void *x_outlet_meter; + void *x_outlet_over; + void *x_clock; + t_float x_cur_peak; + t_float x_old_peak; + t_float x_threshold_over; + t_float x_c1; + t_float x_metro_time; + t_float x_release_time; + int x_overflow_counter; + int x_started; + t_float x_msi; +} t_pvu_tilde; + +t_class *pvu_tilde_class; +static void pvu_tilde_tick(t_pvu_tilde *x); + +static void pvu_tilde_reset(t_pvu_tilde *x) +{ + outlet_float(x->x_outlet_over, 0.0f); + outlet_float(x->x_outlet_meter, -199.9f); + x->x_overflow_counter = 0; + x->x_cur_peak = 0.0f; + x->x_old_peak = 0.0f; + clock_delay(x->x_clock, x->x_metro_time); +} + +static void pvu_tilde_stop(t_pvu_tilde *x) +{ + clock_unset(x->x_clock); + x->x_started = 0; +} + +static void pvu_tilde_start(t_pvu_tilde *x) +{ + clock_delay(x->x_clock, x->x_metro_time); + x->x_started = 1; +} + +static void pvu_tilde_float(t_pvu_tilde *x, t_floatarg f) +{ + if(f == 0.0) + { + clock_unset(x->x_clock); + x->x_started = 0; + } + else + { + clock_delay(x->x_clock, x->x_metro_time); + x->x_started = 1; + } +} + +static void pvu_tilde_t_release(t_pvu_tilde *x, t_floatarg release_time) +{ + if(release_time <= 5.0f) + release_time = 5.0f; + x->x_release_time = release_time; + x->x_c1 = exp(-x->x_metro_time/release_time); +} + +static void pvu_tilde_t_metro(t_pvu_tilde *x, t_floatarg metro_time) +{ + if(metro_time <= 5.0f) + metro_time = 5.0f; + x->x_metro_time = (int)metro_time; + x->x_c1 = exp(-metro_time/x->x_release_time); +} + +static void pvu_tilde_threshold(t_pvu_tilde *x, t_floatarg thresh) +{ + x->x_threshold_over = thresh; +} + +static t_int *pvu_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_pvu_tilde *x = (t_pvu_tilde *)(w[2]); + int n = (int)(w[3]); + t_float peak = x->x_cur_peak; + t_float absolute; + int i; + + if(x->x_started) + { + for(i=0; i peak) + peak = absolute; + } + x->x_cur_peak = peak; + } + return(w+4); +} + +static void pvu_tilde_dsp(t_pvu_tilde *x, t_signal **sp) +{ + dsp_add(pvu_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + clock_delay(x->x_clock, x->x_metro_time); +} + +static void pvu_tilde_tick(t_pvu_tilde *x) +{ + t_float db; + int i; + + x->x_old_peak *= x->x_c1; + /* NAN protect */ + if(IEM_DENORMAL(x->x_old_peak)) + x->x_old_peak = 0.0f; + + if(x->x_cur_peak > x->x_old_peak) + x->x_old_peak = x->x_cur_peak; + if(x->x_old_peak <= 0.0000000001f) + db = -199.9f; + else if(x->x_old_peak > 1000000.0f) + { + db = 120.0f; + x->x_old_peak = 1000000.0f; + } + else + db = 8.6858896381f*log(x->x_old_peak); + if(db >= x->x_threshold_over) + { + x->x_overflow_counter++; + outlet_float(x->x_outlet_over, (t_float)x->x_overflow_counter); + } + outlet_float(x->x_outlet_meter, db); + x->x_cur_peak = 0.0f; + clock_delay(x->x_clock, x->x_metro_time); +} + +static void *pvu_tilde_new(t_floatarg metro_time, t_floatarg release_time, t_floatarg threshold) +{ + t_pvu_tilde *x; + t_float t; + + x = (t_pvu_tilde *)pd_new(pvu_tilde_class); + if(metro_time <= 0.0f) + metro_time = 300.0f; + if(metro_time <= 5.0f) + metro_time = 5.0f; + if(release_time <= 0.0f) + release_time = 300.0f; + if(release_time <= 5.0f) + release_time = 5.0f; + if(threshold == 0.0f) + threshold = -0.01f; + x->x_threshold_over = threshold; + x->x_overflow_counter = 0; + x->x_metro_time = metro_time; + x->x_release_time = release_time; + x->x_c1 = exp(-metro_time/release_time); + x->x_cur_peak = 0.0f; + x->x_old_peak = 0.0f; + x->x_clock = clock_new(x, (t_method)pvu_tilde_tick); + x->x_outlet_meter = outlet_new(&x->x_obj, &s_float);/* left */ + x->x_outlet_over = outlet_new(&x->x_obj, &s_float); /* right */ + x->x_started = 1; + x->x_msi = 0; + return(x); +} + +static void pvu_tilde_ff(t_pvu_tilde *x) +{ + clock_free(x->x_clock); +} + +void pvu_tilde_setup(void ) +{ + pvu_tilde_class = class_new(gensym("pvu~"), (t_newmethod)pvu_tilde_new, + (t_method)pvu_tilde_ff, sizeof(t_pvu_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(pvu_tilde_class, t_pvu_tilde, x_msi); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_dsp, gensym("dsp"), 0); + class_addfloat(pvu_tilde_class, pvu_tilde_float); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_reset, gensym("reset"), 0); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_start, gensym("start"), 0); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_stop, gensym("stop"), 0); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_t_release, gensym("t_release"), A_FLOAT, 0); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); + class_addmethod(pvu_tilde_class, (t_method)pvu_tilde_threshold, gensym("threshold"), A_FLOAT, 0); +// class_sethelpsymbol(pvu_tilde_class, gensym("iemhelp/help-pvu~")); +} diff --git a/iemlib1/src/rvu~.c b/iemlib1/src/rvu~.c new file mode 100644 index 0000000..2adbb52 --- /dev/null +++ b/iemlib1/src/rvu~.c @@ -0,0 +1,178 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + +/* ---------------- rvu~ - simple peak&rms-vu-meter. ----------------- */ + +typedef struct _rvu_tilde +{ + t_object x_obj; + void *x_clock_metro; + t_float x_metro_time; + t_float x_sum_rms; + t_float x_old_rms; + t_float x_rcp; + t_float x_sr; + t_float x_release_time; + t_float x_c1; + int x_started; + t_float x_msi; +} t_rvu_tilde; + +t_class *rvu_tilde_class; +static void rvu_tilde_tick_metro(t_rvu_tilde *x); + +static void rvu_tilde_reset(t_rvu_tilde *x) +{ + outlet_float(x->x_obj.ob_outlet, -99.9f); + x->x_sum_rms = 0.0f; + x->x_old_rms = 0.0f; + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void rvu_tilde_stop(t_rvu_tilde *x) +{ + clock_unset(x->x_clock_metro); + x->x_started = 0; +} + +static void rvu_tilde_start(t_rvu_tilde *x) +{ + clock_delay(x->x_clock_metro, x->x_metro_time); + x->x_started = 1; +} + +static void rvu_tilde_float(t_rvu_tilde *x, t_floatarg f) +{ + if(f == 0.0f) + { + clock_unset(x->x_clock_metro); + x->x_started = 0; + } + else + { + clock_delay(x->x_clock_metro, x->x_metro_time); + x->x_started = 1; + } +} + +static void rvu_tilde_t_release(t_rvu_tilde *x, t_floatarg release_time) +{ + if(release_time <= 5.0f) + release_time = 5.0f; + x->x_release_time = release_time; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); +} + +static void rvu_tilde_t_metro(t_rvu_tilde *x, t_floatarg metro_time) +{ + if(metro_time <= 5.0f) + metro_time = 5.0f; + x->x_metro_time = metro_time; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); +} + +static t_int *rvu_tilde_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_rvu_tilde *x = (t_rvu_tilde *)(w[2]); + int n = (int)(w[3]); + t_float sum=x->x_sum_rms; + int i; + + if(x->x_started) + { + for(i=0; ix_sum_rms = sum; + } + return(w+4); +} + +static void rvu_tilde_dsp(t_rvu_tilde *x, t_signal **sp) +{ + x->x_sr = 0.001*(t_float)sp[0]->s_sr; + x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + dsp_add(rvu_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void rvu_tilde_tick_metro(t_rvu_tilde *x) +{ + t_float dbr, cur_rms, c1=x->x_c1; + + cur_rms = (1.0f - c1)*x->x_sum_rms*x->x_rcp + c1*x->x_old_rms; + /* NAN protect */ + if(IEM_DENORMAL(cur_rms)) + cur_rms = 0.0f; + + if(cur_rms <= 0.0000000001f) + dbr = -99.9f; + else if(cur_rms > 1000000.0f) + { + dbr = 60.0f; + x->x_old_rms = 1000000.0f; + } + else + dbr = 4.3429448195f*log(cur_rms); + x->x_sum_rms = 0.0f; + x->x_old_rms = cur_rms; + outlet_float(x->x_obj.ob_outlet, dbr); + clock_delay(x->x_clock_metro, x->x_metro_time); +} + +static void rvu_tilde_ff(t_rvu_tilde *x) +{ + clock_free(x->x_clock_metro); +} + +static void *rvu_tilde_new(t_floatarg metro_time, t_floatarg release_time) +{ + t_rvu_tilde *x=(t_rvu_tilde *)pd_new(rvu_tilde_class); + + if(metro_time <= 0.0f) + metro_time = 300.0f; + if(metro_time <= 5.0f) + metro_time = 5.0f; + if(release_time <= 0.0f) + release_time = 300.0f; + if(release_time <= 5.0f) + release_time = 5.0f; + x->x_metro_time = metro_time; + x->x_release_time = release_time; + x->x_c1 = exp(-2.0f*x->x_metro_time/x->x_release_time); + x->x_sum_rms = 0.0f; + x->x_old_rms = 0.0f; + x->x_sr = 44.1f; + x->x_rcp = 1.0f/(x->x_sr*x->x_metro_time); + x->x_clock_metro = clock_new(x, (t_method)rvu_tilde_tick_metro); + x->x_started = 1; + outlet_new(&x->x_obj, &s_float); + x->x_msi = 0.0f; + return(x); +} + +void rvu_tilde_setup(void) +{ + rvu_tilde_class = class_new(gensym("rvu~"), (t_newmethod)rvu_tilde_new, + (t_method)rvu_tilde_ff, sizeof(t_rvu_tilde), 0, + A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(rvu_tilde_class, t_rvu_tilde, x_msi); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_dsp, gensym("dsp"), 0); + class_addfloat(rvu_tilde_class, rvu_tilde_float); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_reset, gensym("reset"), 0); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_start, gensym("start"), 0); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_stop, gensym("stop"), 0); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_t_release, gensym("t_release"), A_FLOAT, 0); + class_addmethod(rvu_tilde_class, (t_method)rvu_tilde_t_metro, gensym("t_metro"), A_FLOAT, 0); +// class_sethelpsymbol(rvu_tilde_class, gensym("iemhelp/help-rvu~")); +} diff --git a/iemlib1/src/sin_phase~.c b/iemlib1/src/sin_phase~.c new file mode 100644 index 0000000..78d22c8 --- /dev/null +++ b/iemlib1/src/sin_phase~.c @@ -0,0 +1,121 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" + +/* --- sin_phase~ - output the phase-difference between --- */ +/* --- 2 sinewaves with the same frequency in samples ----- */ +/* --- as a signal ---------------------------------------- */ + +typedef struct _sin_phase_tilde +{ + t_object x_obj; + t_float x_prev1; + t_float x_prev2; + t_float x_cur_out; + int x_counter1; + int x_counter2; + int x_state1; + int x_state2; + t_float x_msi; +} t_sin_phase_tilde; + +t_class *sin_phase_tilde_class; + +static t_int *sin_phase_tilde_perform(t_int *w) +{ + t_float *in1 = (t_float *)(w[1]); + t_float *in2 = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + t_sin_phase_tilde *x = (t_sin_phase_tilde *)(w[4]); + int i, n = (t_int)(w[5]); + t_float prev1=x->x_prev1; + t_float prev2=x->x_prev2; + t_float cur_out=x->x_cur_out; + int counter1=x->x_counter1; + int counter2=x->x_counter2; + int state1=x->x_state1; + int state2=x->x_state2; + + for(i=0; i= 0.0f) && (prev1 < 0.0f)) + {/* pos. zero cross of sig_in_1 */ + state1 = 1; + counter1 = 0; + } + else if((in1[i] < 0.0f) && (prev1 >= 0.0f)) + {/* neg. zero cross of sig_in_1 */ + state2 = 1; + counter2 = 0; + } + + if((in2[i] >= 0.0f) && (prev2 < 0.0f)) + {/* pos. zero cross of sig_in_2 */ + state1 = 0; + cur_out = (t_float)(counter1); + counter1 = 0; + } + else if((in2[i] < 0.0f) && (prev2 >= 0.0f)) + {/* neg. zero cross of sig_in_2 */ + state2 = 0; + cur_out = (t_float)(counter2); + counter2 = 0; + } + + if(state1) + counter1++; + if(state2) + counter2++; + + prev1 = in1[i]; + prev2 = in2[i]; + out[i] = cur_out; + } + + x->x_prev1 = prev1; + x->x_prev2 = prev2; + x->x_cur_out = cur_out; + x->x_counter1 = counter1; + x->x_counter2 = counter2; + x->x_state1 = state1; + x->x_state2 = state2; + + return(w+6); +} + +static void sin_phase_tilde_dsp(t_sin_phase_tilde *x, t_signal **sp) +{ + dsp_add(sin_phase_tilde_perform, 5, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, x, sp[0]->s_n); +} + +static void *sin_phase_tilde_new(void) +{ + t_sin_phase_tilde *x = (t_sin_phase_tilde *)pd_new(sin_phase_tilde_class); + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + outlet_new(&x->x_obj, &s_signal); + + x->x_prev1 = 0.0f; + x->x_prev2 = 0.0f; + x->x_cur_out = 0.0f; + x->x_counter1 = 0; + x->x_counter2 = 0; + x->x_state1 = 0; + x->x_state2 = 0; + x->x_msi = 0; + + return (x); +} + +void sin_phase_tilde_setup(void) +{ + sin_phase_tilde_class = class_new(gensym("sin_phase~"), (t_newmethod)sin_phase_tilde_new, + 0, sizeof(t_sin_phase_tilde), 0, 0); + CLASS_MAINSIGNALIN(sin_phase_tilde_class, t_sin_phase_tilde, x_msi); + class_addmethod(sin_phase_tilde_class, (t_method)sin_phase_tilde_dsp, gensym("dsp"), 0); +// class_sethelpsymbol(sin_phase_tilde_class, gensym("iemhelp/help-sin_phase~")); +} diff --git a/iemlib1/src/soundfile_info.c b/iemlib1/src/soundfile_info.c new file mode 100644 index 0000000..2b0903d --- /dev/null +++ b/iemlib1/src/soundfile_info.c @@ -0,0 +1,256 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include +#include +#include +#include + +#define SFI_HEADER_SAMPLERATE 0 +#define SFI_HEADER_FILENAME 1 +#define SFI_HEADER_MULTICHANNEL_FILE_LENGTH 2 +#define SFI_HEADER_HEADERBYTES 3 +#define SFI_HEADER_CHANNELS 4 +#define SFI_HEADER_BYTES_PER_SAMPLE 5 +#define SFI_HEADER_ENDINESS 6 + +#define SFI_HEADER_SIZE 7 + + + +/* --------------------------- soundfile_info -------------------------------- */ +/* -- reads only header of a wave-file and outputs the important parameters -- */ + +static t_class *soundfile_info_class; + +typedef struct _soundfile_info +{ + t_object x_obj; + long *x_begmem; + int x_size; + t_atom x_atheader[SFI_HEADER_SIZE]; + t_canvas *x_canvas; + void *x_list_out; +} t_soundfile_info; + +static short soundfile_info_str2short(char *cvec) +{ + short s=0; + unsigned char *uc=(unsigned char *)cvec; + + s += (short)(*uc); + s += (short)(*(uc+1)*256); + return(s); +} + +static long soundfile_info_str2long(char *cvec) +{ + long l=0; + unsigned char *uc=(unsigned char *)cvec; + + l += (long)(*uc); + l += (long)(*(uc+1)*256); + l += (long)(*(uc+2)*65536); + l += (long)(*(uc+3)*16777216); + return(l); +} + +static void soundfile_info_read(t_soundfile_info *x, t_symbol *filename) +{ + char completefilename[400]; + int i, n, n2, n4, filesize, read_chars, header_size=0, ch, bps, sr; + FILE *fh; + t_atom *at; + char *cvec; + long ll; + short ss; + + if(filename->s_name[0] == '/')/*make complete path + filename*/ + { + strcpy(completefilename, filename->s_name); + } + else if(((filename->s_name[0] >= 'A')&&(filename->s_name[0] <= 'Z')|| + (filename->s_name[0] >= 'a')&&(filename->s_name[0] <= 'z'))&& + (filename->s_name[1] == ':')&&(filename->s_name[2] == '/')) + { + strcpy(completefilename, filename->s_name); + } + else + { + strcpy(completefilename, canvas_getdir(x->x_canvas)->s_name); + strcat(completefilename, "/"); + strcat(completefilename, filename->s_name); + } + + fh = fopen(completefilename,"rb"); + if(!fh) + { + post("soundfile_info_read: cannot open %s !!\n", completefilename); + } + else + { + n = x->x_size; + n2 = sizeof(short) * x->x_size; + n4 = sizeof(long) * x->x_size; + fseek(fh, 0, SEEK_END); + filesize = ftell(fh); + fseek(fh,0,SEEK_SET); + read_chars = (int)fread(x->x_begmem, sizeof(char), n4, fh) /2; + fclose(fh); + // post("read chars = %d", read_chars); + cvec = (char *)x->x_begmem; + if(read_chars > 4) + { + if(strncmp(cvec, "RIFF", 4)) + { + post("soundfile_info_read-error: %s is no RIFF-WAVE-file", completefilename); + goto soundfile_info_end; + } + header_size += 8; + cvec += 8; + if(strncmp(cvec, "WAVE", 4)) + { + post("soundfile_info_read-error: %s is no RIFF-WAVE-file", completefilename); + goto soundfile_info_end; + } + header_size += 4; + cvec += 4; + + for(i=header_size/2; i 100)) + { + post("soundfile_info_read-error: %s has no common channel-number", completefilename); + goto soundfile_info_end; + } + SETFLOAT(x->x_atheader+SFI_HEADER_CHANNELS, (t_float)ss); + ch = ss; + header_size += 2; + cvec += 2; + ll = soundfile_info_str2long(cvec); + /* samplerate */ + if((ll > 400000) || (ll < 200)) + { + post("soundfile_info_read-error: %s has no common samplerate", completefilename); + goto soundfile_info_end; + } + SETFLOAT(x->x_atheader+SFI_HEADER_SAMPLERATE, (t_float)ll); + sr = ll; + header_size += 4; + cvec += 4; + + header_size += 4; /* bytes_per_sec */ + cvec += 4; + ss = soundfile_info_str2short(cvec); + + /* bytes_per_sample */ + if((ss < 1) || (ss > 100)) + { + post("soundfile_info_read-error: %s has no common number of bytes per sample", completefilename); + goto soundfile_info_end; + } + SETFLOAT(x->x_atheader+SFI_HEADER_BYTES_PER_SAMPLE, (t_float)(ss/ch)); + bps = ss; + header_size += 2; + cvec += 2; + + header_size += 2; /* bits_per_sample */ + cvec += 2; + + for(i=header_size/2; ix_atheader+SFI_HEADER_HEADERBYTES, (t_float)header_size); + + filesize -= header_size; + filesize /= bps; + SETFLOAT(x->x_atheader+SFI_HEADER_MULTICHANNEL_FILE_LENGTH, (t_float)filesize); + SETSYMBOL(x->x_atheader+SFI_HEADER_ENDINESS, gensym("l")); + SETSYMBOL(x->x_atheader+SFI_HEADER_FILENAME, gensym(completefilename)); + + /* post("ch = %d", ss); + post("sr = %d", ll); + post("bps = %d", ss/ch); + post("head = %d", header_size); + post("len = %d", filesize);*/ + + outlet_list(x->x_list_out, &s_list, SFI_HEADER_SIZE, x->x_atheader); + + +soundfile_info_end: + + ; + } + } +} + +static void soundfile_info_free(t_soundfile_info *x) +{ + freebytes(x->x_begmem, x->x_size * sizeof(long)); +} + +static void *soundfile_info_new(void) +{ + t_soundfile_info *x = (t_soundfile_info *)pd_new(soundfile_info_class); + + x->x_size = 10000; + x->x_begmem = (long *)getbytes(x->x_size * sizeof(long)); + x->x_list_out = outlet_new(&x->x_obj, &s_list); + x->x_canvas = canvas_getcurrent(); + return (x); +} + +/* ---------------- global setup function -------------------- */ + +void soundfile_info_setup(void) +{ + soundfile_info_class = class_new(gensym("soundfile_info"), (t_newmethod)soundfile_info_new, + (t_method)soundfile_info_free, sizeof(t_soundfile_info), 0, 0); + class_addmethod(soundfile_info_class, (t_method)soundfile_info_read, gensym("read"), A_SYMBOL, 0); +// class_sethelpsymbol(soundfile_info_class, gensym("iemhelp/help-soundfile_info")); +} diff --git a/iemlib1/src/split.c b/iemlib1/src/split.c new file mode 100644 index 0000000..3360617 --- /dev/null +++ b/iemlib1/src/split.c @@ -0,0 +1,47 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" + + +/* --------- split is like moses ----------- */ + +typedef struct _split +{ + t_object x_obj; + t_outlet *x_out_less; + t_outlet *x_out_greater_equal; + float x_threshold; +} t_split; + +static t_class *split_class; + +static void split_float(t_split *x, t_float f) +{ + if(f < x->x_threshold) + outlet_float(x->x_out_less, f); + else + outlet_float(x->x_out_greater_equal, f); +} + +static void *split_new(t_floatarg f) +{ + t_split *x = (t_split *)pd_new(split_class); + floatinlet_new(&x->x_obj, &x->x_threshold); + x->x_out_less = outlet_new(&x->x_obj, &s_float); + x->x_out_greater_equal = outlet_new(&x->x_obj, &s_float); + x->x_threshold = f; + return (x); +} + +void split_setup(void) +{ + split_class = class_new(gensym("split"), (t_newmethod)split_new, 0, + sizeof(t_split), 0, A_DEFFLOAT, 0); + class_addfloat(split_class, split_float); +// class_sethelpsymbol(split_class, gensym("iemhelp/help-split")); +} diff --git a/iemlib1/src/v2db.c b/iemlib1/src/v2db.c new file mode 100644 index 0000000..7c1adb0 --- /dev/null +++ b/iemlib1/src/v2db.c @@ -0,0 +1,39 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include + + +/* -------- v2db - a rms-value to techn. dB converter. --------- */ + +static t_class *v2db_class; + +t_float v2db(t_float f) +{ + return (f <= 0 ? -199.9 : 8.6858896381*log(f)); +} + +static void v2db_float(t_object *x, t_float f) +{ + outlet_float(x->ob_outlet, v2db(f)); +} + +static void *v2db_new(void) +{ + t_object *x = (t_object *)pd_new(v2db_class); + outlet_new(x, &s_float); + return (x); +} + +void v2db_setup(void) +{ + v2db_class = class_new(gensym("v2db"), v2db_new, 0, + sizeof(t_object), 0, 0); + class_addfloat(v2db_class, (t_method)v2db_float); +// class_sethelpsymbol(v2db_class, gensym("iemhelp/help-v2db")); +} diff --git a/iemlib1/src/vcf_filter~.c b/iemlib1/src/vcf_filter~.c new file mode 100644 index 0000000..1d26df0 --- /dev/null +++ b/iemlib1/src/vcf_filter~.c @@ -0,0 +1,327 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iemlib1 written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ + +#include "m_pd.h" +#include "iemlib.h" +#include +#include + +/* ---------- vcf_filter~ - slow dynamic vcf_filter 1. and 2. order ----------- */ + +typedef struct _vcf_filter_tilde +{ + t_object x_obj; + t_float x_wn1; + t_float x_wn2; + t_float x_msi; + char x_filtname[6]; +} t_vcf_filter_tilde; + +t_class *vcf_filter_tilde_class; + +static t_int *vcf_filter_tilde_perform_snafu(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out = (t_float *)(w[4]); + int n = (t_int)(w[6]); + + while(n--) + *out++ = *in++; + return(w+7); +} + +/* +lp2 +wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); +*out++ = rcp*(wn0 + 2.0f*wn1 + wn2); +wn2 = wn1; +wn1 = wn0; + + bp2 + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*al*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + rbp2 + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*l*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + hp2 + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 - 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + +*/ + +static t_int *vcf_filter_tilde_perform_lp2(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *lp = (t_float *)(w[2]); + t_float *q = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); + int i, n = (t_int)(w[6]); + t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_float l, al, l2, rcp; + + for(i=0; i 1000000.0f) + al = 0.000001f*l; + else + al = l/q[i]; + l2 = l*l + 1.0f; + rcp = 1.0f/(al + l2); + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*(wn0 + 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + } + /* NAN protect */ + if(IEM_DENORMAL(wn2)) + wn2 = 0.0f; + if(IEM_DENORMAL(wn1)) + wn1 = 0.0f; + + x->x_wn1 = wn1; + x->x_wn2 = wn2; + return(w+7); +} + +static t_int *vcf_filter_tilde_perform_bp2(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *lp = (t_float *)(w[2]); + t_float *q = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); + int i, n = (t_int)(w[6]); + t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_float l, al, l2, rcp; + + for(i=0; i 1000000.0f) + al = 0.000001f*l; + else + al = l/q[i]; + l2 = l*l + 1.0f; + rcp = 1.0f/(al + l2); + + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*al*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*al*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*al*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*al*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + } + /* NAN protect */ + if(IEM_DENORMAL(wn2)) + wn2 = 0.0f; + if(IEM_DENORMAL(wn1)) + wn1 = 0.0f; + + x->x_wn1 = wn1; + x->x_wn2 = wn2; + return(w+7); +} + +static t_int *vcf_filter_tilde_perform_rbp2(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *lp = (t_float *)(w[2]); + t_float *q = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); + int i, n = (t_int)(w[6]); + t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_float al, l, l2, rcp; + + for(i=0; i 1000000.0f) + al = 0.000001f*l; + else + al = l/q[i]; + l2 = l*l + 1.0f; + rcp = 1.0f/(al + l2); + + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*l*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*l*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*l*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = rcp*l*(wn0 - wn2); + wn2 = wn1; + wn1 = wn0; + } + /* NAN protect */ + if(IEM_DENORMAL(wn2)) + wn2 = 0.0f; + if(IEM_DENORMAL(wn1)) + wn1 = 0.0f; + + x->x_wn1 = wn1; + x->x_wn2 = wn2; + return(w+7); +} + +static t_int *vcf_filter_tilde_perform_hp2(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *lp = (t_float *)(w[2]); + t_float *q = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)(w[5]); + int i, n = (t_int)(w[6]); + t_float wn0, wn1=x->x_wn1, wn2=x->x_wn2; + t_float l, al, l2, rcp, forw; + + for(i=0; i 1000000.0f) + al = 0.000001f*l; + else + al = l/q[i]; + l2 = l*l + 1.0f; + rcp = 1.0f/(al + l2); + forw = rcp * (l2 - 1.0f); + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + + wn0 = *in++ - rcp*(2.0f*(2.0f - l2)*wn1 + (l2 - al)*wn2); + *out++ = forw*(wn0 - 2.0f*wn1 + wn2); + wn2 = wn1; + wn1 = wn0; + } + /* NAN protect */ + if(IEM_DENORMAL(wn2)) + wn2 = 0.0f; + if(IEM_DENORMAL(wn1)) + wn1 = 0.0f; + + x->x_wn1 = wn1; + x->x_wn2 = wn2; + return(w+7); +} + +static void vcf_filter_tilde_dsp(t_vcf_filter_tilde *x, t_signal **sp) +{ + if(!strcmp(x->x_filtname,"bp2")) + dsp_add(vcf_filter_tilde_perform_bp2, 6, sp[0]->s_vec, sp[1]->s_vec, + sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + else if(!strcmp(x->x_filtname,"rbp2")) + dsp_add(vcf_filter_tilde_perform_rbp2, 6, sp[0]->s_vec, sp[1]->s_vec, + sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + else if(!strcmp(x->x_filtname,"lp2")) + dsp_add(vcf_filter_tilde_perform_lp2, 6, sp[0]->s_vec, sp[1]->s_vec, + sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + else if(!strcmp(x->x_filtname,"hp2")) + dsp_add(vcf_filter_tilde_perform_hp2, 6, sp[0]->s_vec, sp[1]->s_vec, + sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + else + { + dsp_add(vcf_filter_tilde_perform_snafu, 6, sp[0]->s_vec, sp[1]->s_vec, + sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + post("vcf_filter~-Error: 1. initial-arguments: kind: lp2, bp2, rbp2, hp2!"); + } +} + +static void *vcf_filter_tilde_new(t_symbol *filt_typ) +{ + t_vcf_filter_tilde *x = (t_vcf_filter_tilde *)pd_new(vcf_filter_tilde_class); + char *c; + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + outlet_new(&x->x_obj, &s_signal); + x->x_msi = 0; + x->x_wn1 = 0.0f; + x->x_wn2 = 0.0f; + c = (char *)filt_typ->s_name; + c[5] = 0; + strcpy(x->x_filtname, c); + return(x); +} + +void vcf_filter_tilde_setup(void) +{ + vcf_filter_tilde_class = class_new(gensym("vcf_filter~"), (t_newmethod)vcf_filter_tilde_new, + 0, sizeof(t_vcf_filter_tilde), 0, A_SYMBOL, 0); + CLASS_MAINSIGNALIN(vcf_filter_tilde_class, t_vcf_filter_tilde, x_msi); + class_addmethod(vcf_filter_tilde_class, (t_method)vcf_filter_tilde_dsp, gensym("dsp"), 0); +// class_sethelpsymbol(vcf_filter_tilde_class, gensym("iemhelp/help-vcf_filter~")); +} diff --git a/iemlib1/v2db-help.pd b/iemlib1/v2db-help.pd new file mode 100644 index 0000000..360495b --- /dev/null +++ b/iemlib1/v2db-help.pd @@ -0,0 +1,17 @@ +#N canvas 158 78 283 224 10; +#X floatatom 23 99 9 0 0 0 - - -; +#X text 57 75 no arg; +#X floatatom 23 52 9 0 0 0 - - -; +#X text 24 12 v2db; +#X text 104 13 value to dB converter; +#X text 90 102 output_level [dB]; +#X text 90 52 input_value [-]; +#X obj 23 76 v2db; +#X text 115 168 IEM KUG; +#X text 99 156 musil; +#X text 129 156 @; +#X text 135 156 iem.at; +#X text 50 145 (c) Thomas Musil 2000 - 2005; +#X text 98 178 Graz \, Austria; +#X connect 2 0 7 0; +#X connect 7 0 0 0; -- cgit v1.2.1