From d449d31030cfc4a3e06858bf877dcbfacad59f74 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 9 Jan 2006 21:24:28 +0000 Subject: checked in code from sIgpAck0.03.ZIP; cleaned up comment warnings and changed #ifdef NT to #ifdef _MSC_VER; removed sp. prefix and set up for namespaces svn path=/trunk/externals/sigpack/; revision=4381 --- help/chop~-help.pd | 32 ++++++++ help/decimate~-help.pd | 32 ++++++++ help/diode~-help.pd | 26 +++++++ help/foldback~-help.pd | 30 ++++++++ help/foldover~-help.pd | 30 ++++++++ help/freqdiv~-help.pd | 27 +++++++ help/freqshift~-help.pd | 33 ++++++++ help/harmgen~-help.pd | 54 +++++++++++++ help/rectify~-help.pd | 27 +++++++ help/round~-help.pd | 26 +++++++ help/saturate~-help.pd | 29 +++++++ help/sieve~-help.pd | 28 +++++++ help/split~-help.pd | 26 +++++++ help/ustep~-help.pd | 38 ++++++++++ help/vowel~-help.pd | 45 +++++++++++ source/chop~.c | 67 ++++++++++++++++ source/decimate~.c | 76 +++++++++++++++++++ source/diode~.c | 78 +++++++++++++++++++ source/foldback~.c | 70 +++++++++++++++++ source/foldover~.c | 71 +++++++++++++++++ source/freqdiv~.c | 100 ++++++++++++++++++++++++ source/freqshift~.c | 197 ++++++++++++++++++++++++++++++++++++++++++++++++ source/harmgen~.c | 161 +++++++++++++++++++++++++++++++++++++++ source/rectify~.c | 61 +++++++++++++++ source/round~.c | 64 ++++++++++++++++ source/sIgpAck.c | 58 ++++++++++++++ source/saturate~.c | 83 ++++++++++++++++++++ source/sieve~.c | 105 ++++++++++++++++++++++++++ source/split~.c | 72 ++++++++++++++++++ source/ustep~.c | 83 ++++++++++++++++++++ source/vowel~.c | 118 +++++++++++++++++++++++++++++ 31 files changed, 1947 insertions(+) create mode 100644 help/chop~-help.pd create mode 100644 help/decimate~-help.pd create mode 100644 help/diode~-help.pd create mode 100644 help/foldback~-help.pd create mode 100644 help/foldover~-help.pd create mode 100644 help/freqdiv~-help.pd create mode 100644 help/freqshift~-help.pd create mode 100644 help/harmgen~-help.pd create mode 100644 help/rectify~-help.pd create mode 100644 help/round~-help.pd create mode 100644 help/saturate~-help.pd create mode 100644 help/sieve~-help.pd create mode 100644 help/split~-help.pd create mode 100644 help/ustep~-help.pd create mode 100644 help/vowel~-help.pd create mode 100644 source/chop~.c create mode 100644 source/decimate~.c create mode 100644 source/diode~.c create mode 100644 source/foldback~.c create mode 100644 source/foldover~.c create mode 100644 source/freqdiv~.c create mode 100644 source/freqshift~.c create mode 100644 source/harmgen~.c create mode 100644 source/rectify~.c create mode 100644 source/round~.c create mode 100644 source/sIgpAck.c create mode 100644 source/saturate~.c create mode 100644 source/sieve~.c create mode 100644 source/split~.c create mode 100644 source/ustep~.c create mode 100644 source/vowel~.c diff --git a/help/chop~-help.pd b/help/chop~-help.pd new file mode 100644 index 0000000..630bfc9 --- /dev/null +++ b/help/chop~-help.pd @@ -0,0 +1,32 @@ +#N canvas 366 389 462 366 12; +#X obj 155 172 nbx 5 14 -2 2 0 0 empty empty ->factor[-2/2] 60 8 0 +10 -262144 -1 -1 0 256; +#X text 60 35 signal chopping modulator; +#X obj 62 116 osc~ 220; +#X obj 62 312 dac~; +#X obj 156 195 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 92 256; +#X obj 62 277 *~; +#X obj 156 258 line~; +#X obj 156 235 pack 0 50; +#X obj 156 213 dbtorms; +#X text 156 144 ->signal modulation input; +#X text 155 116 ->signal input; +#X text 60 51 multiplicates incoming signal by factor x; +#X text 59 68 if modulation signal is positive; +#X obj 99 146 osc~ 2; +#X text 300 11 arg; +#X text 252 301 sIgpAck 0.02; +#X obj 62 186 sp.chop~ 0; +#X text 213 316 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.chop~---; +#X connect 0 0 16 2; +#X connect 2 0 16 0; +#X connect 4 0 8 0; +#X connect 5 0 3 0; +#X connect 5 0 3 1; +#X connect 6 0 5 1; +#X connect 7 0 6 0; +#X connect 8 0 7 0; +#X connect 13 0 16 1; +#X connect 16 0 5 0; diff --git a/help/decimate~-help.pd b/help/decimate~-help.pd new file mode 100644 index 0000000..3f9e35c --- /dev/null +++ b/help/decimate~-help.pd @@ -0,0 +1,32 @@ +#N canvas 285 400 488 343 12; +#N canvas 0 0 450 300 graph1 0; +#X array deci 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 305 189 graph; +#X msg 8 112 bang; +#X obj 52 105 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 305 102 graph; +#X obj 62 132 tabwrite~ osc; +#X obj 125 172 nbx 5 14 0 1 0 0 empty empty ratio 0 -6 0 10 -262144 +-1 -1 0.02 256; +#X obj 199 172 nbx 5 14 0 32 0 0 empty empty bits[1-32] 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 52 228 tabwrite~ deci; +#X text 51 35 signal decimation; +#X text 51 50 a ratio of 1 is orig. samplerate 0.5 is half; +#X text 273 11 arg; +#X text 51 67 of orig. samplerate etc.; +#X text 260 268 sIgpAck 0.02; +#X obj 52 195 sp.decimate~ 0.5 16; +#X text 222 281 2003 www.weiss-archiv.de; +#X text 51 13 ---sp.decimate~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 13 0; +#X connect 5 0 13 1; +#X connect 6 0 13 2; +#X connect 13 0 7 0; diff --git a/help/diode~-help.pd b/help/diode~-help.pd new file mode 100644 index 0000000..63c60da --- /dev/null +++ b/help/diode~-help.pd @@ -0,0 +1,26 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array diode 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X text 60 13 ---sp.diode~---; +#X obj 62 201 tabwrite~ diode; +#X obj 62 168 sp.diode~ 0; +#X floatatom 145 147 5 0 2 2 mode[0-2] - -; +#X text 294 12 arg; +#X text 60 35 diode rectifier network; +#X text 263 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 7 0; +#X connect 7 0 6 0; +#X connect 8 0 7 1; diff --git a/help/foldback~-help.pd b/help/foldback~-help.pd new file mode 100644 index 0000000..efb78f7 --- /dev/null +++ b/help/foldback~-help.pd @@ -0,0 +1,30 @@ +#N canvas 71 176 476 301 12; +#N canvas 0 0 450 300 graph1 0; +#X array fold 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 143 147 nbx 5 14 -1 0 0 0 empty empty neg 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 225 147 nbx 5 14 0 1 0 0 empty empty pos 0 -6 0 10 -262144 -1 +-1 0 256; +#X obj 62 201 tabwrite~ fold; +#X text 264 240 sIgpAck 0.01; +#X text 299 12 arg; +#X text 60 35 signal mirror; +#X obj 62 168 sp.foldback~ -0.5 0.5; +#X text 224 254 2002 www.weiss-archiv.de; +#X text 60 13 ---sp.foldback~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 11 0; +#X connect 5 0 11 1; +#X connect 6 0 11 2; +#X connect 11 0 7 0; diff --git a/help/foldover~-help.pd b/help/foldover~-help.pd new file mode 100644 index 0000000..c50d7da --- /dev/null +++ b/help/foldover~-help.pd @@ -0,0 +1,30 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array fold 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 123 144 nbx 5 14 0 0.1 0 0 empty empty amp[0-0.1] 0 -6 0 10 +-262144 -1 -1 0.1 256; +#X obj 206 154 nbx 5 14 0 1 0 0 empty empty sym[0-1] 0 -6 0 10 -262144 +-1 -1 1 256; +#X obj 62 201 tabwrite~ fold; +#X text 60 35 foldover distortion; +#X text 294 12 arg; +#X text 262 240 sIgpAck 0.02; +#X obj 62 168 sp.foldover~ 0 0; +#X text 223 254 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.foldover~---; +#X connect 1 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 4 0; +#X connect 2 0 11 0; +#X connect 5 0 11 1; +#X connect 6 0 11 2; +#X connect 11 0 7 0; diff --git a/help/freqdiv~-help.pd b/help/freqdiv~-help.pd new file mode 100644 index 0000000..5381058 --- /dev/null +++ b/help/freqdiv~-help.pd @@ -0,0 +1,27 @@ +#N canvas 71 176 488 313 12; +#N canvas 0 0 450 300 graph1 0; +#X array div 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 338 163 graph; +#X msg 18 85 bang; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 337 75 graph; +#X obj 72 105 tabwrite~ osc; +#X obj 62 201 tabwrite~ div; +#X floatatom 161 143 5 0 8 1 -->denominate - -; +#X text 315 12 arg; +#X text 60 35 signal frequency divider; +#X obj 62 78 osc~ 4; +#X text 220 157 [(int)0-8]; +#X text 293 239 sIgpAck 0.02; +#X obj 62 168 sp.freqdiv~ 1; +#X text 254 254 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.freqdiv~---; +#X connect 1 0 3 0; +#X connect 1 0 4 0; +#X connect 5 0 11 1; +#X connect 8 0 3 0; +#X connect 8 0 11 0; +#X connect 11 0 4 0; diff --git a/help/freqshift~-help.pd b/help/freqshift~-help.pd new file mode 100644 index 0000000..13b1983 --- /dev/null +++ b/help/freqshift~-help.pd @@ -0,0 +1,33 @@ +#N canvas 177 339 492 389 12; +#N canvas 0 0 450 300 graph1 0; +#X array downshift 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 337 163 graph; +#X msg 17 85 bang; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 337 75 graph; +#X obj 72 105 tabwrite~ osc; +#X text 60 13 ---sp.freqshift~---; +#X text 60 35 bode frequency shifter; +#X text 315 12 arg; +#X obj 62 168 sp.freqshift~ 100; +#X obj 62 78 osc~ 110; +#X text 287 334 sIgpAck 0.03; +#X text 248 349 2005 www.weiss-archiv.de; +#X floatatom 193 143 5 0 0 2 shift[hz] - -; +#N canvas 0 0 450 300 graph1 0; +#X array upshift 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 338 252 graph; +#X obj 63 304 tabwrite~ downshift; +#X obj 73 280 tabwrite~ upshift; +#X connect 1 0 3 0; +#X connect 1 0 13 0; +#X connect 1 0 14 0; +#X connect 7 0 13 0; +#X connect 7 1 14 0; +#X connect 8 0 3 0; +#X connect 8 0 7 0; +#X connect 11 0 7 1; diff --git a/help/harmgen~-help.pd b/help/harmgen~-help.pd new file mode 100644 index 0000000..afcd8bc --- /dev/null +++ b/help/harmgen~-help.pd @@ -0,0 +1,54 @@ +#N canvas 211 248 536 429 12; +#N canvas 0 0 450 300 graph1 0; +#X array harm 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 381 169 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 380 79 graph; +#X obj 72 105 tabwrite~ osc; +#X text 60 35 harmonic generator; +#X text 334 17 arg..; +#X text 337 358 sIgpAck 0.02; +#X obj 62 371 tabwrite~ harm; +#X floatatom 86 132 5 -1 1 0 - - -; +#X floatatom 110 153 5 -1 1 0 - - -; +#X floatatom 134 174 5 -1 1 0 - - -; +#X floatatom 159 195 5 -1 1 0 - - -; +#X floatatom 183 215 5 -1 1 0 - - -; +#X floatatom 207 236 5 -1 1 0 - - -; +#X floatatom 232 257 5 -1 1 0 - - -; +#X floatatom 256 277 5 -1 1 0 - - -; +#X floatatom 280 298 5 -1 1 0 - - -; +#X floatatom 305 319 5 -1 1 0 - - -; +#X text 351 318 ->mag10[-1/1]; +#X text 133 130 ->mag1[-1/1]:fundamental freq; +#X text 158 151 ->mag2[-1/1]; +#X text 181 173 ->mag3[-1/1]; +#X text 210 193 ->mag4[-1/1]; +#X text 229 214 ->mag5[-1/1]; +#X text 255 235 ->mag6[-1/1]; +#X text 280 256 ->mag7[-1/1]; +#X text 305 276 ->mag8[-1/1]; +#X text 327 297 ->mag9[-1/1]; +#X obj 62 342 sp.harmgen~ 0 0 0 0 0 0 0 0 0 0; +#X text 298 372 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.harmgen~---; +#X connect 1 0 4 0; +#X connect 1 0 8 0; +#X connect 2 0 4 0; +#X connect 2 0 29 0; +#X connect 9 0 29 1; +#X connect 10 0 29 2; +#X connect 11 0 29 3; +#X connect 12 0 29 4; +#X connect 13 0 29 5; +#X connect 14 0 29 6; +#X connect 15 0 29 7; +#X connect 16 0 29 8; +#X connect 17 0 29 9; +#X connect 18 0 29 10; +#X connect 29 0 8 0; diff --git a/help/rectify~-help.pd b/help/rectify~-help.pd new file mode 100644 index 0000000..0924b84 --- /dev/null +++ b/help/rectify~-help.pd @@ -0,0 +1,27 @@ +#N canvas 149 271 419 288 12; +#N canvas 0 0 450 300 graph1 0; +#X array rect 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 231 159 graph; +#X msg 21 113 bang; +#X obj 62 75 osc~ 1.345; +#X obj 75 133 tabwrite~ osc; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 230 72 graph; +#X text 340 68 1; +#X text 333 124 -1; +#X text 60 35 flips negative values to positive; +#X text 342 153 1; +#X text 334 213 -1; +#X obj 62 201 tabwrite~ rect; +#X text 208 237 sIgpAck 0.01; +#X obj 62 165 sp.rectify~; +#X text 166 250 2002 www.weiss-archiv.de; +#X text 60 13 ---sp.rectify~---; +#X connect 1 0 3 0; +#X connect 1 0 10 0; +#X connect 2 0 3 0; +#X connect 2 0 12 0; +#X connect 12 0 10 0; diff --git a/help/round~-help.pd b/help/round~-help.pd new file mode 100644 index 0000000..8e5ed0a --- /dev/null +++ b/help/round~-help.pd @@ -0,0 +1,26 @@ +#N canvas 190 492 440 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array round 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 307 162 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X floatatom 145 146 5 0 0 2 coarse - -; +#X obj 62 201 tabwrite~ round; +#X text 60 13 ---sp.round~---; +#X text 60 35 simple rounder; +#X text 262 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X text 312 12 arg; +#X obj 62 168 sp.round~ 2; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 12 0; +#X connect 5 0 12 1; +#X connect 12 0 6 0; diff --git a/help/saturate~-help.pd b/help/saturate~-help.pd new file mode 100644 index 0000000..087747c --- /dev/null +++ b/help/saturate~-help.pd @@ -0,0 +1,29 @@ +#N canvas 202 222 476 321 12; +#N canvas 0 0 450 300 graph1 0; +#X array sat 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 185 graph; +#X msg 17 109 bang; +#X obj 61 102 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 305 99 graph; +#X obj 71 129 tabwrite~ osc; +#X obj 184 172 nbx 5 14 -1 1 0 0 empty empty thresh 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 61 225 tabwrite~ sat; +#X text 60 35 soft saturation; +#X text 316 12 arg; +#X text 263 264 sIgpAck 0.02; +#X text 60 50 if signal is above threshold; +#X text 60 65 a soft saturation is added; +#X obj 61 193 sp.saturate~ 0.5; +#X text 223 278 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.saturate~---; +#X connect 1 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 4 0; +#X connect 2 0 12 0; +#X connect 5 0 12 1; +#X connect 12 0 6 0; diff --git a/help/sieve~-help.pd b/help/sieve~-help.pd new file mode 100644 index 0000000..1ae25b9 --- /dev/null +++ b/help/sieve~-help.pd @@ -0,0 +1,28 @@ +#N canvas 71 176 480 305 12; +#N canvas 0 0 450 300 graph1 0; +#X array sieve 44100 float 0; +#X coords 0 1.02 44099 -1.02 100 70 1; +#X restore 306 163 graph; +#X msg 18 85 bang; +#X obj 62 78 osc~ 1.5; +#N canvas 0 0 450 300 graph1 0; +#X array osc 44100 float 0; +#X coords 0 1 44099 -1 100 70 1; +#X restore 306 75 graph; +#X obj 72 105 tabwrite~ osc; +#X floatatom 119 145 1 0 0 2 mode - -; +#X floatatom 191 151 5 0 0 2 samp[-1/1] - -; +#X text 262 240 sIgpAck 0.03; +#X text 223 254 2005 www.weiss-archiv.de; +#X obj 62 201 tabwrite~ sieve; +#X obj 62 168 sp.sieve~ 0 0.5; +#X text 60 13 ---sp.sieve~---; +#X text 60 35 simple sample sifter; +#X text 294 12 arg; +#X connect 1 0 4 0; +#X connect 1 0 9 0; +#X connect 2 0 4 0; +#X connect 2 0 10 0; +#X connect 5 0 10 1; +#X connect 6 0 10 2; +#X connect 10 0 9 0; diff --git a/help/split~-help.pd b/help/split~-help.pd new file mode 100644 index 0000000..32d7f25 --- /dev/null +++ b/help/split~-help.pd @@ -0,0 +1,26 @@ +#N canvas 343 402 362 261 12; +#X floatatom 208 97 5 0 0 0 - - -; +#X obj 109 96 sig~; +#X floatatom 109 74 5 0 0 0 - - -; +#X obj 208 147 snapshot~; +#X obj 109 147 snapshot~; +#X obj 34 127 metro 20; +#X obj 34 102 loadbang; +#X floatatom 109 174 5 0 0 0 - - -; +#X floatatom 208 175 5 0 0 0 - - -; +#X text 60 35 signal split function; +#X text 164 209 sIgpAck 0.01; +#X text 224 13 arg; +#X obj 109 120 sp.split~ 0.5; +#X text 124 224 2002 www.weiss-archiv.de; +#X text 60 13 ---sp.split~---; +#X connect 0 0 12 1; +#X connect 1 0 12 0; +#X connect 2 0 1 0; +#X connect 3 0 8 0; +#X connect 4 0 7 0; +#X connect 5 0 3 0; +#X connect 5 0 4 0; +#X connect 6 0 5 0; +#X connect 12 0 4 0; +#X connect 12 1 3 0; diff --git a/help/ustep~-help.pd b/help/ustep~-help.pd new file mode 100644 index 0000000..61665b8 --- /dev/null +++ b/help/ustep~-help.pd @@ -0,0 +1,38 @@ +#N canvas 194 385 571 387 12; +#X obj 62 318 dac~; +#X obj 95 200 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 62 283 *~; +#X obj 95 263 line~; +#X obj 95 240 pack 0 50; +#X obj 95 218 dbtorms; +#X floatatom 119 118 1 0 0 0 - - -; +#X obj 177 140 nbx 5 14 0 1 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X text 60 35 signal unity step function; +#X text 138 117 Mode[0/1]; +#X text 236 136 Thres[0-1]; +#X text 229 179 Mode0: if signal is above the; +#X text 286 191 specified threshold a unity; +#X text 286 203 step is output \, otherwise zero; +#X text 228 218 Mode1: same as above but if below the; +#X text 283 230 threshold \, the signal passes; +#X text 284 242 unchanged; +#X obj 62 92 osc~ 440; +#X floatatom 62 70 5 0 0 0 - - -; +#X text 301 15 arg; +#X text 308 331 sIgpAck 0.01; +#X obj 62 163 sp.ustep~ 0 0.5; +#X text 269 345 2002 www.weiss-archiv.de; +#X text 60 13 ---sp.ustep~---; +#X connect 1 0 5 0; +#X connect 2 0 0 0; +#X connect 2 0 0 1; +#X connect 3 0 2 1; +#X connect 4 0 3 0; +#X connect 5 0 4 0; +#X connect 6 0 21 1; +#X connect 7 0 21 2; +#X connect 17 0 21 0; +#X connect 18 0 17 0; +#X connect 21 0 2 0; diff --git a/help/vowel~-help.pd b/help/vowel~-help.pd new file mode 100644 index 0000000..57f6f08 --- /dev/null +++ b/help/vowel~-help.pd @@ -0,0 +1,45 @@ +#N canvas 308 311 400 400 12; +#X text 60 35 simple formant filter; +#X text 202 11 arg; +#X obj 62 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 62 96 metro 200; +#X obj 62 120 random 440; +#X msg 195 95 0; +#X msg 195 117 1; +#X msg 195 139 2; +#X msg 195 162 3; +#X msg 194 185 4; +#X obj 193 212 nbx 5 14 0 100 0 0 empty empty empty 0 -6 0 10 -262144 +-1 -1 0 256; +#X obj 62 294 *~; +#X obj 193 275 line~; +#X obj 193 252 pack 0 50; +#X obj 193 230 dbtorms; +#X obj 62 329 dac~; +#X text 232 93 ->a; +#X text 233 117 ->e; +#X text 232 138 ->i; +#X text 231 162 ->o; +#X text 231 184 ->u; +#X obj 62 145 phasor~ 220; +#X text 190 315 sIgpAck 0.02; +#X obj 62 205 sp.vowel~ 0; +#X text 151 330 2003 www.weiss-archiv.de; +#X text 60 13 ---sp.vowel~---; +#X connect 2 0 3 0; +#X connect 3 0 4 0; +#X connect 4 0 21 0; +#X connect 5 0 23 1; +#X connect 6 0 23 1; +#X connect 7 0 23 1; +#X connect 8 0 23 1; +#X connect 9 0 23 1; +#X connect 10 0 14 0; +#X connect 11 0 15 0; +#X connect 11 0 15 1; +#X connect 12 0 11 1; +#X connect 13 0 12 0; +#X connect 14 0 13 0; +#X connect 21 0 23 0; +#X connect 23 0 11 0; diff --git a/source/chop~.c b/source/chop~.c new file mode 100644 index 0000000..df2786c --- /dev/null +++ b/source/chop~.c @@ -0,0 +1,67 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +// ------------------------ sp.chop~ ----------------------------- +// signal chopping modulator + +static t_class *chop_tilde_class; + +typedef struct _chop_tilde +{ + t_object x_obj; + t_sample x_factor; + float x_f; +} t_chop_tilde; + +static void *chop_tilde_new(t_floatarg factor) +{ + t_chop_tilde *x = (t_chop_tilde *)pd_new(chop_tilde_class); + x->x_factor = factor; + outlet_new(&x->x_obj, gensym("signal")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + floatinlet_new(&x->x_obj, &x->x_factor); + x->x_f = 0; + if(factor) x->x_factor = factor; + else x->x_factor = 0; + return (x); +} + +static t_int *chop_tilde_perform(t_int *w) +{ + t_chop_tilde *x = (t_chop_tilde *)(w[1]); + t_float *in1 = (t_float *)(w[2]); + t_float *in2 = (t_float *)(w[3]); + t_float *out = (t_float *)(w[4]); + int n = (int)(w[5]); + float f, m, value; + while (n--) + { + f = *in1++; + m = *in2++; + if(m > 0.) value = f * x->x_factor; + else value = f; + *out++ = value; + } + return (w+6); +} + +static void chop_tilde_dsp(t_chop_tilde *x, t_signal **sp) +{ + dsp_add(chop_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +void chop_tilde_setup(void) +{ + chop_tilde_class = class_new(gensym("sp.chop~"), (t_newmethod)chop_tilde_new, 0, + sizeof(t_chop_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(chop_tilde_class, t_chop_tilde, x_f); + class_addmethod(chop_tilde_class, (t_method)chop_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/decimate~.c b/source/decimate~.c new file mode 100644 index 0000000..b7fb073 --- /dev/null +++ b/source/decimate~.c @@ -0,0 +1,76 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +// ------------------------ sp.decimate~ ----------------------------- +// signal decimation +// code from musicdsp.org posted by tobybear + +static t_class *decimate_tilde_class; + +typedef struct _decimate_tilde +{ + t_object x_obj; + t_sample x_rate; + t_sample x_bits; + float x_f; +} t_decimate_tilde; + +static void *decimate_tilde_new(t_floatarg rate, t_floatarg bits) +{ + t_decimate_tilde *x = (t_decimate_tilde *)pd_new(decimate_tilde_class); + x->x_rate = rate; + x->x_bits = bits; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_rate); + floatinlet_new(&x->x_obj, &x->x_bits); + x->x_f = 0; + if (rate) x->x_rate = rate; + else x->x_rate = 0.5; + if (bits) x->x_bits = bits; + else x->x_bits = 16; + return (x); +} + +static t_int *decimate_tilde_perform(t_int *w) +{ + t_decimate_tilde *x = (t_decimate_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + long int m=1<<(int)(x->x_bits-1); + float y=0, cnt=0; + while (n--) + { + f = *in++; + cnt+=x->x_rate; + if (cnt>=1) + { + cnt-=1; + y=(long int)(f*m)/(float)m; + } + *out++ = y; + } + return (w+5); +} + +static void decimate_tilde_dsp(t_decimate_tilde *x, t_signal **sp) +{ + dsp_add(decimate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void decimate_tilde_setup(void) +{ + decimate_tilde_class = class_new(gensym("sp.decimate~"), (t_newmethod)decimate_tilde_new, 0, + sizeof(t_decimate_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(decimate_tilde_class, t_decimate_tilde, x_f); + class_addmethod(decimate_tilde_class, (t_method)decimate_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/diode~.c b/source/diode~.c new file mode 100644 index 0000000..b024da1 --- /dev/null +++ b/source/diode~.c @@ -0,0 +1,78 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.diode~ ----------------------------- */ +/* Mangles the signal as if it had been passed through a diode rectifier network.*/ +/* code from swh_plugins by steve harris www.plugin.org.uk */ + +static t_class *diode_tilde_class; + +typedef struct _diode_tilde +{ + t_object x_obj; + t_sample x_mode;//0=none,1=halfWave,2=fullWave + float x_f; +} t_diode_tilde; + +static void *diode_tilde_new(t_floatarg mode) +{ + t_diode_tilde *x = (t_diode_tilde *)pd_new(diode_tilde_class); + x->x_mode = mode; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + x->x_f = 0; + if(mode) x->x_mode = mode; + else x->x_mode = 0; + return (x); +} + +static t_int *diode_tilde_perform(t_int *w) +{ + t_diode_tilde *x = (t_diode_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if(x->x_mode >= 0.0f && x->x_mode < 1.0f) { + value = ((1.0f - x->x_mode) * f + (x->x_mode * (f > 0.0f ? f : 0.0f))); + } + else if (x->x_mode >= 1.0f && x->x_mode < 2.0f) { + float fac = x->x_mode - 1.0f; + value = ((1.0f - fac) * (f > 0 ? f : 0.0)) + (fac * fabs(f)); + } + else if (x->x_mode >= 2) { + float fac = x->x_mode < 3 ? x->x_mode - 2 : 1.0; + value = (1.0 - fac) * fabs(f); + } + else { + value = f; + } + *out++ = value; + } + return (w+5); +} + +static void diode_tilde_dsp(t_diode_tilde *x, t_signal **sp) +{ + dsp_add(diode_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void diode_tilde_setup(void) +{ + diode_tilde_class = class_new(gensym("sp.diode~"), (t_newmethod)diode_tilde_new, 0, + sizeof(t_diode_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(diode_tilde_class, t_diode_tilde, x_f); + class_addmethod(diode_tilde_class, (t_method)diode_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/foldback~.c b/source/foldback~.c new file mode 100644 index 0000000..4101a5a --- /dev/null +++ b/source/foldback~.c @@ -0,0 +1,70 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.foldback~ ----------------------------- */ +/* signal mirror */ + +static t_class *foldback_tilde_class; + +typedef struct _foldback_tilde +{ + t_object x_obj; + t_sample x_low; + t_sample x_high; + float x_f; +} t_foldback_tilde; + +static void *foldback_tilde_new(t_floatarg low, t_floatarg high) +{ + t_foldback_tilde *x = (t_foldback_tilde *)pd_new(foldback_tilde_class); + x->x_low = low; + x->x_high = high; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_low); + floatinlet_new(&x->x_obj, &x->x_high); + x->x_f = 0; + if(low) x->x_low = low; + else x->x_low = -1; + if(high) x->x_high = high; + else x->x_high = 1; + return (x); +} + +static t_int *foldback_tilde_perform(t_int *w) +{ + t_foldback_tilde *x = (t_foldback_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if(f < x->x_low) value = (f - ((f - x->x_low) * 2)); + else if(f > x->x_high) value = (f - ((f - x->x_high) * 2)); + else value = f; + *out++ = value; + } + return (w+5); +} + +static void foldback_tilde_dsp(t_foldback_tilde *x, t_signal **sp) +{ + dsp_add(foldback_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void foldback_tilde_setup(void) +{ + foldback_tilde_class = class_new(gensym("sp.foldback~"), (t_newmethod)foldback_tilde_new, 0, + sizeof(t_foldback_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(foldback_tilde_class, t_foldback_tilde, x_f); + class_addmethod(foldback_tilde_class, (t_method)foldback_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/foldover~.c b/source/foldover~.c new file mode 100644 index 0000000..7741c08 --- /dev/null +++ b/source/foldover~.c @@ -0,0 +1,71 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.foldover~ ----------------------------- */ +/* foldover distortion */ +/* code from swh_plugins by steve harris www.plugin.org.uk */ + +static t_class *foldover_tilde_class; + +typedef struct _foldover_tilde +{ + t_object x_obj; + t_sample x_drive_p; + t_sample x_push; + float x_f; +} t_foldover_tilde; + +static void *foldover_tilde_new(t_floatarg drive_p, t_floatarg push) +{ + t_foldover_tilde *x = (t_foldover_tilde *)pd_new(foldover_tilde_class); + x->x_drive_p = drive_p; + x->x_push = push; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_drive_p); + floatinlet_new(&x->x_obj, &x->x_push); + x->x_f = 0; + if(drive_p) x->x_drive_p = drive_p; + else x->x_drive_p = 0; + if(push) x->x_push = push; + else x->x_push = 0; + return (x); +} + +static t_int *foldover_tilde_perform(t_int *w) +{ + t_foldover_tilde *x = (t_foldover_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value, y; + float drive = x->x_drive_p + 1.0f; + while (n--) + { + f = *in++; + y = f * drive + x->x_push; + value = 1.5f * y - 0.5f * y * y *y; + *out++ = value; + } + return (w+5); +} + +static void foldover_tilde_dsp(t_foldover_tilde *x, t_signal **sp) +{ + dsp_add(foldover_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void foldover_tilde_setup(void) +{ + foldover_tilde_class = class_new(gensym("sp.foldover~"), (t_newmethod)foldover_tilde_new, 0, + sizeof(t_foldover_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(foldover_tilde_class, t_foldover_tilde, x_f); + class_addmethod(foldover_tilde_class, (t_method)foldover_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/freqdiv~.c b/source/freqdiv~.c new file mode 100644 index 0000000..fa6ba12 --- /dev/null +++ b/source/freqdiv~.c @@ -0,0 +1,100 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.freqdiv~ ----------------------------- */ +/* frequency divider */ +/* code from swh_plugins by steve harris www.plugins.org.uk */ + +static t_class *freqdiv_tilde_class; + +typedef struct _freqdiv_tilde +{ + t_object x_obj; + t_sample x_denominate; + t_sample x_amp; + float x_count; + t_sample x_lamp; + t_sample x_last; + t_sample x_out; + int x_zeroxs; + float x_f; +} t_freqdiv_tilde; + +static void *freqdiv_tilde_new(t_floatarg denominate) +{ + t_freqdiv_tilde *x = (t_freqdiv_tilde *)pd_new(freqdiv_tilde_class); + x->x_denominate = denominate; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_denominate); + x->x_f = 0; + x->x_amp = 0; + x->x_count = 0; + x->x_lamp = 0; + x->x_last = 0; + x->x_out = 0; + x->x_zeroxs = 0; + if (denominate) x->x_denominate = denominate; + else x->x_denominate = 1; + return (x); +} + +static t_int *freqdiv_tilde_perform(t_int *w) +{ + t_freqdiv_tilde *x = (t_freqdiv_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + int den = (int)x->x_denominate; + while (n--) + { + f = *in++; + x->x_count += 1.0f; + if ((f > 0.0f && x->x_last <= 0.0f) || (f < 0.0f && x->x_last >= 0.0)) + { + x->x_zeroxs++; + if (den == 1) + { + x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; + x->x_lamp = x->x_amp / x->x_count; + x->x_zeroxs = 0; + x->x_count = 0; + x->x_amp = 0; + } + } + x->x_amp += fabs(f); + if (den > 1 && (x->x_zeroxs % den) == den-1) + { + x->x_out = x->x_out > 0.0f ? -1.0f : 1.0f; + x->x_lamp = x->x_amp / x->x_count; + x->x_zeroxs = 0; + x->x_count = 0; + x->x_amp = 0; + } + x->x_last = f; + *out++ = x->x_out * x->x_lamp; + } + return (w+5); +} + +static void freqdiv_tilde_dsp(t_freqdiv_tilde *x, t_signal **sp) +{ + dsp_add(freqdiv_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void freqdiv_tilde_setup(void) +{ + freqdiv_tilde_class = class_new(gensym("sp.freqdiv~"), (t_newmethod)freqdiv_tilde_new, 0, + sizeof(t_freqdiv_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(freqdiv_tilde_class, t_freqdiv_tilde, x_f); + class_addmethod(freqdiv_tilde_class, (t_method)freqdiv_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/freqshift~.c b/source/freqshift~.c new file mode 100644 index 0000000..a7460c5 --- /dev/null +++ b/source/freqshift~.c @@ -0,0 +1,197 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#define M_PI 3.14159265358979323846 +#endif + +/* ------------------------ sp.freqshift~ ----------------------------- */ +/* frequency shifter */ +/* code from swh_plugins by steve harris www.plugins.org.uk */ + +#define SIN_T_SIZE 64 +#define D_SIZE 256 +#define NZEROS 200 + +static t_class *freqshift_tilde_class; + +typedef struct _freqshift_tilde +{ + t_object x_obj; + t_float x_shift;//[0 - 5000] + float *x_delay; + unsigned int x_dptr; + t_float x_fs; + t_float x_last_shift; + t_float x_phi; + float *x_sint; + float x_f; +} t_freqshift_tilde; + +static void *freqshift_tilde_new(t_floatarg shift) +{ + unsigned int i; + + t_freqshift_tilde *x = (t_freqshift_tilde *)pd_new(freqshift_tilde_class); + //x->x_shift = shift; + outlet_new(&x->x_obj, gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_shift); + x->x_fs = sys_getsr(); + x->x_delay = (float *)getbytes(D_SIZE * sizeof(float)); + x->x_sint = (float *)getbytes(SIN_T_SIZE * sizeof(float)); + x->x_dptr = 0; + x->x_phi = 0.0f; + x->x_last_shift = 0.0f; + x->x_f = 0; + for (i = 0; i < SIN_T_SIZE; i++) { + x->x_sint[i] = sin(2.0f * M_PI * (float)i / (float)SIN_T_SIZE); + } + if (shift) x->x_shift = shift; + else x->x_shift = 0; + return (x); +} + +/* The non-zero taps of the Hilbert transformer */ +static float xcoeffs[] = { + +0.0008103736f, +0.0008457886f, +0.0009017196f, +0.0009793364f, + +0.0010798341f, +0.0012044365f, +0.0013544008f, +0.0015310235f, + +0.0017356466f, +0.0019696659f, +0.0022345404f, +0.0025318040f, + +0.0028630784f, +0.0032300896f, +0.0036346867f, +0.0040788644f, + +0.0045647903f, +0.0050948365f, +0.0056716186f, +0.0062980419f, + +0.0069773575f, +0.0077132300f, +0.0085098208f, +0.0093718901f, + +0.0103049226f, +0.0113152847f, +0.0124104218f, +0.0135991079f, + +0.0148917649f, +0.0163008758f, +0.0178415242f, +0.0195321089f, + +0.0213953037f, +0.0234593652f, +0.0257599469f, +0.0283426636f, + +0.0312667947f, +0.0346107648f, +0.0384804823f, +0.0430224431f, + +0.0484451086f, +0.0550553725f, +0.0633242001f, +0.0740128560f, + +0.0884368322f, +0.1090816773f, +0.1412745301f, +0.1988673273f, + +0.3326528346f, +0.9997730178f, -0.9997730178f, -0.3326528346f, + -0.1988673273f, -0.1412745301f, -0.1090816773f, -0.0884368322f, + -0.0740128560f, -0.0633242001f, -0.0550553725f, -0.0484451086f, + -0.0430224431f, -0.0384804823f, -0.0346107648f, -0.0312667947f, + -0.0283426636f, -0.0257599469f, -0.0234593652f, -0.0213953037f, + -0.0195321089f, -0.0178415242f, -0.0163008758f, -0.0148917649f, + -0.0135991079f, -0.0124104218f, -0.0113152847f, -0.0103049226f, + -0.0093718901f, -0.0085098208f, -0.0077132300f, -0.0069773575f, + -0.0062980419f, -0.0056716186f, -0.0050948365f, -0.0045647903f, + -0.0040788644f, -0.0036346867f, -0.0032300896f, -0.0028630784f, + -0.0025318040f, -0.0022345404f, -0.0019696659f, -0.0017356466f, + -0.0015310235f, -0.0013544008f, -0.0012044365f, -0.0010798341f, + -0.0009793364f, -0.0009017196f, -0.0008457886f, -0.0008103736f, +}; + +static float f_clamp(float x, float a, float b) +{ + const float x1 = fabs(x - a); + const float x2 = fabs(x - b); + + x = x1 + a + b; + x -= x2; + x *= 0.5; + + return x; +} + +// Round float to int using IEEE int* hack +static int f_round(float f) { + f += (3<<22); + return *((int*)&f) - 0x4b400000; +} + +// Cubic interpolation function +static float cube_interp(const float fr, const float inm1, const float + in, const float inp1, const float inp2) +{ + return in + 0.5f * fr * (inp1 - inm1 + + fr * (4.0f * inp1 + 2.0f * inm1 - 5.0f * in - inp2 + + fr * (3.0f * (in - inp1) - inm1 + inp2))); +} + +static t_int *freqshift_tilde_perform(t_int *w) +{ + t_freqshift_tilde *x = (t_freqshift_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out1 = (t_float *)(w[3]); + t_float *out2 = (t_float *)(w[4]); + int n = (int)(w[5]); + float f, hilb, rm1, rm2, frac_p; + float shift_i = x->x_last_shift; + float sample_count = sys_getblksize(); + unsigned int i; + int int_p; + const float shift_c = f_clamp(x->x_shift, 0.0f, 10000.0f); + const float shift_inc = (shift_c - x->x_last_shift) / (float)sample_count; + const float freq_fix = (float)SIN_T_SIZE / x->x_fs; + while (n--) + { + f = *in++; + x->x_delay[x->x_dptr] = f; + /* Perform the Hilbert FIR convolution + * (probably FFT would be faster) */ + hilb = 0.0f; + for (i = 0; i <= NZEROS/2; i++) { + hilb += (xcoeffs[i] * x->x_delay[(x->x_dptr - i*2) & (D_SIZE - 1)]); + } + + /* Calcuate the table positions for the sine modulator */ + int_p = f_round(floor(x->x_phi)); + + /* Calculate ringmod1, the transformed input modulated with a shift Hz + * sinewave. This creates a +180 degree sideband at source-shift Hz and + * a 0 degree sindeband at source+shift Hz */ + frac_p = x->x_phi - int_p; + rm1 = hilb * cube_interp(frac_p, x->x_sint[int_p], x->x_sint[int_p+1], + x->x_sint[int_p+2], x->x_sint[int_p+3]); + + /* Calcuate the table positions for the cosine modulator */ + int_p = (int_p + SIN_T_SIZE / 4) & (SIN_T_SIZE - 1); + + /* Calculate ringmod2, the delayed input modulated with a shift Hz + * cosinewave. This creates a 0 degree sideband at source+shift Hz + * and a -180 degree sindeband at source-shift Hz */ + rm2 = x->x_delay[(x->x_dptr - 100) & (D_SIZE - 1)] * cube_interp(frac_p, + x->x_sint[int_p], x->x_sint[int_p+1], x->x_sint[int_p+2], x->x_sint[int_p+3]); + + /* Output the sum and differences of the ringmods. The +/-180 degree + * sidebands cancel (more of less) and just leave the shifted + * components */ + *out1++ = (rm2 - rm1) * 0.5f; /*downshifting*/ + *out2++ = (rm2 + rm1) * 0.5f; /*upshifting*/ + + x->x_dptr = (x->x_dptr + 1) & (D_SIZE - 1); + x->x_phi += shift_i * freq_fix; + while (x->x_phi > SIN_T_SIZE) { + x->x_phi -= SIN_T_SIZE; + } + shift_i += shift_inc; + } + return (w+6); +} + +static void freqshift_tilde_dsp(t_freqshift_tilde *x, t_signal **sp) +{ + dsp_add(freqshift_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +static void freqshift_tilde_free(t_freqshift_tilde *x) +{ + if(x->x_delay) + freebytes(x->x_delay, D_SIZE * sizeof(float)); + if(x->x_sint) + freebytes(x->x_sint, SIN_T_SIZE + 4 * sizeof(float)); +} + +void freqshift_tilde_setup(void) +{ + freqshift_tilde_class = class_new(gensym("sp.freqshift~"), (t_newmethod)freqshift_tilde_new, (t_method)freqshift_tilde_free, + sizeof(t_freqshift_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(freqshift_tilde_class, t_freqshift_tilde, x_f); + class_addmethod(freqshift_tilde_class, (t_method)freqshift_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/harmgen~.c b/source/harmgen~.c new file mode 100644 index 0000000..2ab4851 --- /dev/null +++ b/source/harmgen~.c @@ -0,0 +1,161 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif +#define HARMONICS 11 + +// ------------------------ sp.harmgen~ ----------------------------- +// harmonic generator +// code from swh_plugins by steve harris www.plugins.org.uk + +static t_class *harmgen_tilde_class; + +typedef struct _harmgen_tilde +{ + t_object x_obj; + t_sample x_mag1; + t_sample x_mag2; + t_sample x_mag3; + t_sample x_mag4; + t_sample x_mag5; + t_sample x_mag6; + t_sample x_mag7; + t_sample x_mag8; + t_sample x_mag9; + t_sample x_mag10; + float x_itm; + float x_otm; + float x_f; +} t_harmgen_tilde; + +static void *harmgen_tilde_new(t_floatarg mag1, t_floatarg mag2, t_floatarg mag3, t_floatarg mag4, t_floatarg mag5, t_floatarg mag6, t_floatarg mag7, t_floatarg mag8, t_floatarg mag9, t_floatarg mag10) +{ + t_harmgen_tilde *x = (t_harmgen_tilde *)pd_new(harmgen_tilde_class); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mag1); + floatinlet_new(&x->x_obj, &x->x_mag2); + floatinlet_new(&x->x_obj, &x->x_mag3); + floatinlet_new(&x->x_obj, &x->x_mag4); + floatinlet_new(&x->x_obj, &x->x_mag5); + floatinlet_new(&x->x_obj, &x->x_mag6); + floatinlet_new(&x->x_obj, &x->x_mag7); + floatinlet_new(&x->x_obj, &x->x_mag8); + floatinlet_new(&x->x_obj, &x->x_mag9); + floatinlet_new(&x->x_obj, &x->x_mag10); + x->x_f = 0; + if(mag1) x->x_mag1 = mag1; + else x->x_mag1 = 1; + if(mag2) x->x_mag2 = mag2; + else x->x_mag2 = 1; + if(mag3) x->x_mag3 = mag3; + else x->x_mag3 = 1; + if(mag4) x->x_mag4 = mag4; + else x->x_mag4 = 1; + if(mag5) x->x_mag5 = mag5; + else x->x_mag5 = 1; + if(mag6) x->x_mag6 = mag6; + else x->x_mag6 = 1; + if(mag7) x->x_mag7 = mag7; + else x->x_mag7 = 1; + if(mag8) x->x_mag8 = mag8; + else x->x_mag8 = 1; + if(mag9) x->x_mag9 = mag9; + else x->x_mag9 = 1; + if(mag10) x->x_mag10 = mag10; + else x->x_mag10 = 1; + return (x); +} + +/* Calculate Chebychev coefficents from partial magnitudes, adapted from + * example in Num. Rec. */ +void chebpc(float c[], float d[]) +{ + int k, j; + float sv, dd[HARMONICS]; + + for (j = 0; j < HARMONICS; j++) { + d[j] = dd[j] = 0.0; + } + + d[0] = c[HARMONICS - 1]; + + for (j = HARMONICS - 2; j >= 1; j--) { + for (k = HARMONICS - j; k >= 1; k--) { + sv = d[k]; + d[k] = 2.0 * d[k - 1] - dd[k]; + dd[k] = sv; + } + sv = d[0]; + d[0] = -dd[0] + c[j]; + dd[0] = sv; + } + + for (j = HARMONICS - 1; j >= 1; j--) { + d[j] = d[j - 1] - dd[j]; + } + d[0] = -dd[0] + 0.5 * c[0]; +} + +static t_int *harmgen_tilde_perform(t_int *w) +{ + t_harmgen_tilde *x = (t_harmgen_tilde *)(w[1]); + t_float *in1 = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + unsigned long i; + float mag_fix, y, f, value; + float mag[HARMONICS] = {0.0f, x->x_mag1, x->x_mag2, x->x_mag3, x->x_mag4, x->x_mag5, x->x_mag6, + x->x_mag7, x->x_mag8, x->x_mag9, x->x_mag10}; + float p[HARMONICS]; + + // Normalise magnitudes + mag_fix = (fabs(x->x_mag1) + fabs(x->x_mag2) + fabs(x->x_mag3) + fabs(x->x_mag4) + + fabs(x->x_mag5) + fabs(x->x_mag6) + fabs(x->x_mag7) + fabs(x->x_mag8) + + fabs(x->x_mag9) + fabs(x->x_mag10)); + if (mag_fix < 1.0f) { + mag_fix = 1.0f; + } else { + mag_fix = 1.0f / mag_fix; + } + for (i=0; ix_otm = 0.999f * x->x_otm + y - x->x_itm; + x->x_itm = y; + *out++ = x->x_otm; + } + return (w+5); +} + +static void harmgen_tilde_dsp(t_harmgen_tilde *x, t_signal **sp) +{ + dsp_add(harmgen_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void harmgen_tilde_setup(void) +{ + harmgen_tilde_class = class_new(gensym("sp.harmgen~"), (t_newmethod)harmgen_tilde_new, 0, + sizeof(t_harmgen_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(harmgen_tilde_class, t_harmgen_tilde, x_f); + class_addmethod(harmgen_tilde_class, (t_method)harmgen_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/rectify~.c b/source/rectify~.c new file mode 100644 index 0000000..d2dda88 --- /dev/null +++ b/source/rectify~.c @@ -0,0 +1,61 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.rectify~ ----------------------------- */ +/* flips negative signal values to positive */ + +static t_class *rectify_tilde_class; + +typedef struct _rectify_tilde +{ + t_object x_obj; + float x_f; +} t_rectify_tilde; + +static void *rectify_tilde_new(void) +{ + t_rectify_tilde *x = (t_rectify_tilde *)pd_new(rectify_tilde_class); + outlet_new(&x->x_obj, gensym("signal")); + x->x_f = 0; + return (x); +} + +static t_int *rectify_tilde_perform(t_int *w) +{ + t_rectify_tilde *x = (t_rectify_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + if (f < 0) + value = f * -1; + else + value = f; + *out++ = value; + } + return (w+5); +} + +static void rectify_tilde_dsp(t_rectify_tilde *x, t_signal **sp) +{ + dsp_add(rectify_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void rectify_tilde_setup(void) +{ + rectify_tilde_class = class_new(gensym("sp.rectify~"), (t_newmethod)rectify_tilde_new, 0, + sizeof(t_rectify_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(rectify_tilde_class, t_rectify_tilde, x_f); + class_addmethod(rectify_tilde_class, (t_method)rectify_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/round~.c b/source/round~.c new file mode 100644 index 0000000..e19d134 --- /dev/null +++ b/source/round~.c @@ -0,0 +1,64 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.round~ ----------------------------- */ +/* simple rounder */ + +static t_class *round_tilde_class; + +typedef struct _round_tilde +{ + t_object x_obj; + t_sample x_coarse; + float x_f; +} t_round_tilde; + +static void *round_tilde_new(t_floatarg coarse) +{ + t_round_tilde *x = (t_round_tilde *)pd_new(round_tilde_class); + x->x_coarse = coarse; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_coarse); + x->x_f = 0; + if(coarse) x->x_coarse = coarse; + else x->x_coarse = 1; + return (x); +} + +static t_int *round_tilde_perform(t_int *w) +{ + t_round_tilde *x = (t_round_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, mult, value; + while (n--) + { + f = *in++; + mult = f * x->x_coarse; + value = (int)mult / x->x_coarse; + *out++ = value; + } + return (w+5); +} + +static void round_tilde_dsp(t_round_tilde *x, t_signal **sp) +{ + dsp_add(round_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void round_tilde_setup(void) +{ + round_tilde_class = class_new(gensym("sp.round~"), (t_newmethod)round_tilde_new, 0, + sizeof(t_round_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(round_tilde_class, t_round_tilde, x_f); + class_addmethod(round_tilde_class, (t_method)round_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/sIgpAck.c b/source/sIgpAck.c new file mode 100644 index 0000000..e666e75 --- /dev/null +++ b/source/sIgpAck.c @@ -0,0 +1,58 @@ +#ifndef VERSION +#define VERSION "0.03" +#endif + +#include + + +typedef struct _sigpack +{ + t_object x_obj; +} t_sigpack; + +static t_class* sigpack_class; + +void chop_tilde_setup(); +void decimate_tilde_setup(); +void diode_tilde_setup(); +void foldback_tilde_setup(); +void foldover_tilde_setup(); +void freqdiv_tilde_setup(); +void freqshift_tilde_setup(); +void harmgen_tilde_setup(); +void rectify_tilde_setup(); +void round_tilde_setup(); +void saturate_tilde_setup(); +void sieve_tilde_setup(); +void split_tilde_setup(); +void ustep_tilde_setup(); +void vowel_tilde_setup(); + +static void* sigpack_new(t_symbol* s) { + t_sigpack *x = (t_sigpack *)pd_new(sigpack_class); + return (x); +} + +void sigpack_setup(void) +{ + sigpack_class = class_new(gensym("sIgpAck"), (t_newmethod)sigpack_new, 0, + sizeof(t_sigpack), 0,0); + + chop_tilde_setup(); + decimate_tilde_setup(); + diode_tilde_setup(); + foldback_tilde_setup(); + foldover_tilde_setup(); + freqdiv_tilde_setup(); + freqshift_tilde_setup(); + harmgen_tilde_setup(); + rectify_tilde_setup(); + round_tilde_setup(); + saturate_tilde_setup(); + sieve_tilde_setup(); + split_tilde_setup(); + ustep_tilde_setup(); + vowel_tilde_setup(); + + post("sIgpAck"" "VERSION " weiss www.weiss-archiv.de"); +} diff --git a/source/saturate~.c b/source/saturate~.c new file mode 100644 index 0000000..809f7a0 --- /dev/null +++ b/source/saturate~.c @@ -0,0 +1,83 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#include +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.saturate~ ----------------------------- */ +/* signal soft saturation */ +/* code from www.musicdsp.org posted by bram de jong */ + +static t_class *saturate_tilde_class; + +typedef struct _saturate_tilde +{ + t_object x_obj; + t_sample x_thresh; + float x_f; +} t_saturate_tilde; + +static void *saturate_tilde_new(t_floatarg thresh) +{ + t_saturate_tilde *x = (t_saturate_tilde *)pd_new(saturate_tilde_class); + x->x_thresh = thresh; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_thresh); + x->x_f = 0; + if(thresh) x->x_thresh = thresh; + else x->x_thresh = 1.; + return (x); +} + +static float sigmoid(float x) +{ + if(fabs(x) < 1) + return x * (1.5f - 0.5f * x * x); + else + return x > 0.f ? 1.f : -1.f; +} + +static t_int *saturate_tilde_perform(t_int *w) +{ + t_saturate_tilde *x = (t_saturate_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + float t = x->x_thresh; + while (n--) + { + f = *in++; + if(fabs(f) < t) + value = f; + else + { + if(f > 0.f) + value = t + (1.f - t) * sigmoid((f - t)/((1 - t) * 1.5f)); + else + value = -(t + (1.f - t) * sigmoid((-f - t)/((1 - t) * 1.5f))); + } + *out++ = value; + } + return (w+5); +} + +static void saturate_tilde_dsp(t_saturate_tilde *x, t_signal **sp) +{ + dsp_add(saturate_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void saturate_tilde_setup(void) +{ + saturate_tilde_class = class_new(gensym("sp.saturate~"), (t_newmethod)saturate_tilde_new, 0, + sizeof(t_saturate_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(saturate_tilde_class, t_saturate_tilde, x_f); + class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("dsp"), 0); + class_addmethod(saturate_tilde_class, (t_method)saturate_tilde_dsp, gensym("sigmoid"), A_FLOAT, 0); +} diff --git a/source/sieve~.c b/source/sieve~.c new file mode 100644 index 0000000..31ec10b --- /dev/null +++ b/source/sieve~.c @@ -0,0 +1,105 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.sieve~ ----------------------------- */ +/* sift samples */ + +static t_class *sieve_tilde_class; + +typedef struct _sieve_tilde +{ + t_object x_obj; + t_sample x_mode; + t_sample x_sample; + t_sample x_last; + float x_f; +} t_sieve_tilde; + +static void *sieve_tilde_new(t_floatarg mode, t_floatarg sample) +{ + t_sieve_tilde *x = (t_sieve_tilde *)pd_new(sieve_tilde_class); + x->x_mode = mode; + x->x_sample = sample; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + floatinlet_new(&x->x_obj, &x->x_sample); + x->x_last = 0; + x->x_f = 0; + x->x_mode = 0; + + if(mode) x->x_mode = mode; + if(x->x_mode > 1) x->x_mode = 1; + if(x->x_mode < 0) x->x_mode = 0; + return (x); +} + +static float round(float in) +{ + float y, round; + int temp; + { + round = in * 10; + temp = round; + y = temp * 0.1; + } + return y; +} + +static t_int *sieve_tilde_perform(t_int *w) +{ + t_sieve_tilde *x = (t_sieve_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f; + int mode = x->x_mode; + while (n--) + { + f = *in++; + switch(mode){ + case(0): + if (round(f) != round(x->x_sample)) + { + *out++ = f; + x->x_last = f; + } + else + { + *out++ = x->x_last; + } + break; + case(1): + if (round(f) == round(x->x_sample)) + { + *out++ = f; + x->x_last = f; + } + else + { + *out++ = x->x_last; + } + } + } + return (w+5); +} + +static void sieve_tilde_dsp(t_sieve_tilde *x, t_signal **sp) +{ + dsp_add(sieve_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void sieve_tilde_setup(void) +{ + sieve_tilde_class = class_new(gensym("sp.sieve~"), (t_newmethod)sieve_tilde_new, 0, + sizeof(t_sieve_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(sieve_tilde_class, t_sieve_tilde, x_f); + class_addmethod(sieve_tilde_class, (t_method)sieve_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/split~.c b/source/split~.c new file mode 100644 index 0000000..0fc5a9d --- /dev/null +++ b/source/split~.c @@ -0,0 +1,72 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.split~ ----------------------------- */ +/* signal splitter */ + +static t_class *split_tilde_class; + +typedef struct _split_tilde +{ + t_object x_obj; + float x_f; + t_sample x_thres; +} t_split_tilde; + +static void *split_tilde_new(t_floatarg thres) +{ + t_split_tilde *x = (t_split_tilde *)pd_new(split_tilde_class); + x->x_thres = thres; + outlet_new(&x->x_obj, gensym("signal")); + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_thres); + x->x_f = 0; + if(thres) x->x_thres = thres; + else x->x_thres = 0; + return (x); +} + +static t_int *split_tilde_perform(t_int *w) +{ + t_split_tilde *x = (t_split_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out1 = (t_float *)(w[3]); + t_float *out2 = (t_float *)(w[4]); + int n = (int)(w[5]); + while (n--) + { + float f = *in++; + if(f < x->x_thres) + { + *out1++ = f; + *out2++ = 0; + } + else if(f >= x->x_thres) + { + *out1++ = 0; + *out2++ = f; + } + } + return (w+6); +} + +static void split_tilde_dsp(t_split_tilde *x, t_signal **sp) +{ + dsp_add(split_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); +} + +void split_tilde_setup(void) +{ + split_tilde_class = class_new(gensym("sp.split~"), (t_newmethod)split_tilde_new, 0, + sizeof(t_split_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(split_tilde_class, t_split_tilde, x_f); + class_addmethod(split_tilde_class, (t_method)split_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/ustep~.c b/source/ustep~.c new file mode 100644 index 0000000..d91ea1f --- /dev/null +++ b/source/ustep~.c @@ -0,0 +1,83 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.ustep~ ----------------------------- */ +/* signal unity step function */ + +static t_class *ustep_tilde_class; + +typedef struct _ustep_tilde +{ + t_object x_obj; + t_sample x_mode; + t_sample x_thres; + float x_f; +} t_ustep_tilde; + +static void *ustep_tilde_new(t_floatarg mode, t_floatarg thres) +{ + t_ustep_tilde *x = (t_ustep_tilde *)pd_new(ustep_tilde_class); + x->x_mode = mode; + x->x_thres = thres; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_mode); + floatinlet_new(&x->x_obj, &x->x_thres); + x->x_f = 0; + if(mode) x->x_mode = mode; + else x->x_mode = 0; + if(x->x_mode > 1) x->x_mode = 1; + if(x->x_mode < 0) x->x_mode = 0; + if(thres) x->x_thres = thres; + else x->x_thres = 0.5; + return (x); +} + +static t_int *ustep_tilde_perform(t_int *w) +{ + t_ustep_tilde *x = (t_ustep_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + int mode = x->x_mode; + while (n--) + { + f = *in++; + switch(mode){ + case(0): + if (f >= x->x_thres) + value = 1; + else + value = 0; + break; + case(1): + if (f >= x->x_thres) + value = 1; + else + value = f; + } + *out++ = value; + } + return (w+5); +} + +static void ustep_tilde_dsp(t_ustep_tilde *x, t_signal **sp) +{ + dsp_add(ustep_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void ustep_tilde_setup(void) +{ + ustep_tilde_class = class_new(gensym("sp.ustep~"), (t_newmethod)ustep_tilde_new, 0, + sizeof(t_ustep_tilde), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(ustep_tilde_class, t_ustep_tilde, x_f); + class_addmethod(ustep_tilde_class, (t_method)ustep_tilde_dsp, gensym("dsp"), 0); +} diff --git a/source/vowel~.c b/source/vowel~.c new file mode 100644 index 0000000..3500ffc --- /dev/null +++ b/source/vowel~.c @@ -0,0 +1,118 @@ +/* sIgpAck + * for + * pure-data + * www.weiss-archiv.de */ + +#include "m_pd.h" +#ifdef _MSC_VER +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +/* ------------------------ sp.vowel~ ----------------------------- */ +/* simple formant filter */ +/* code from musicdsp.org posted by alex@smartelectronix.com */ + +static t_class *vowel_tilde_class; + +typedef struct _vowel_tilde +{ + t_object x_obj; + t_sample x_vowelnum; + float x_f; +} t_vowel_tilde; + +static void *vowel_tilde_new(t_floatarg vowelnum) +{ + t_vowel_tilde *x = (t_vowel_tilde *)pd_new(vowel_tilde_class); + x->x_vowelnum = vowelnum; + outlet_new(&x->x_obj, gensym("signal")); + floatinlet_new(&x->x_obj, &x->x_vowelnum); + x->x_f = 0; + if(vowelnum) x->x_vowelnum = vowelnum; + else x->x_vowelnum = 0; + return (x); +} + +const double coeff[5][11]= { + { 8.11044e-06, + 8.943665402, -36.83889529, 92.01697887, -154.337906, 181.6233289, + -151.8651235, 89.09614114, -35.10298511, 8.388101016, -0.923313471 ///A + }, + { 4.36215e-06, + 8.90438318, -36.55179099, 91.05750846, -152.422234, 179.1170248, ///E + -149.6496211,87.78352223, -34.60687431, 8.282228154, -0.914150747 + }, + { 3.33819e-06, + 8.893102966, -36.49532826, 90.96543286, -152.4545478, 179.4835618, + -150.315433, 88.43409371, -34.98612086, 8.407803364, -0.932568035 ///I + }, + { 1.13572e-06, + 8.994734087, -37.2084849, 93.22900521, -156.6929844, 184.596544, ///O + -154.3755513, 90.49663749, -35.58964535, 8.478996281, -0.929252233 + }, + { 4.09431e-07, + 8.997322763, -37.20218544, 93.11385476, -156.2530937, 183.7080141, ///U + -153.2631681, 89.59539726, -35.12454591, 8.338655623, -0.910251753 + } +}; + +static double memory[10] = {0,0,0,0,0,0,0,0,0,0}; + +float formant_filter (float in, int vowelnum) +{ + float res; + res= (float) (coeff[vowelnum][0]*in + + coeff[vowelnum][1]*memory[0] + + coeff[vowelnum][2]*memory[1] + + coeff[vowelnum][3]*memory[2] + + coeff[vowelnum][4]*memory[3] + + coeff[vowelnum][5]*memory[4] + + coeff[vowelnum][6]*memory[5] + + coeff[vowelnum][7]*memory[6] + + coeff[vowelnum][8]*memory[7] + + coeff[vowelnum][9]*memory[8] + + coeff[vowelnum][10]*memory[9]); + + memory[9]=memory[8]; + memory[8]=memory[7]; + memory[7]=memory[6]; + memory[6]=memory[5]; + memory[5]=memory[4]; + memory[4]=memory[3]; + memory[3]=memory[2]; + memory[2]=memory[1]; + memory[1]=memory[0]; + memory[0]=(double)res; + return res; +} + +static t_int *vowel_tilde_perform(t_int *w) +{ + t_vowel_tilde *x = (t_vowel_tilde *)(w[1]); + t_float *in = (t_float *)(w[2]); + t_float *out = (t_float *)(w[3]); + int n = (int)(w[4]); + float f, value; + while (n--) + { + f = *in++; + value = formant_filter(f, (int)x->x_vowelnum); + *out++ = value; + } + return (w+5); +} + +static void vowel_tilde_dsp(t_vowel_tilde *x, t_signal **sp) +{ + dsp_add(vowel_tilde_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); +} + +void vowel_tilde_setup(void) +{ + vowel_tilde_class = class_new(gensym("sp.vowel~"), (t_newmethod)vowel_tilde_new, 0, + sizeof(t_vowel_tilde), 0, A_DEFFLOAT, 0); + CLASS_MAINSIGNALIN(vowel_tilde_class, t_vowel_tilde, x_f); + class_addmethod(vowel_tilde_class, (t_method)vowel_tilde_dsp, gensym("dsp"), 0); + class_addmethod(vowel_tilde_class, (t_method)formant_filter, gensym("formant_filter"), A_GIMME, A_NULL); +} -- cgit v1.2.1