[PD-cvs] externals/bassemu bassemu~.c, NONE, 1.1 bassemu~-help.pd, NONE, 1.1 bassemu~.pd_linux, NONE, 1.1 COPYING, NONE, 1.1 Makefile, NONE, 1.1 miniseq.pd, NONE, 1.1

Thomas O Fredericks mrtof at users.sourceforge.net
Wed Nov 14 22:12:45 CET 2007


Update of /cvsroot/pure-data/externals/bassemu
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28225

Added Files:
	bassemu~.c bassemu~-help.pd bassemu~.pd_linux COPYING Makefile 
	miniseq.pd 
Log Message:
Added bassemu to externals

--- NEW FILE: miniseq.pd ---
#N canvas 1395 150 977 618 10;
#X obj 319 388 metro 250;
#X obj 1 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 3473 1;
#X obj 11 236 i;
#X obj 319 416 i;
#X obj 323 521 sel 1;
#X msg 346 552 0;
#X obj 319 446 + 1;
#X floatatom 474 175 5 0 0 0 - - -;
#X obj 378 1 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 72 190 sel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
#X obj 27 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2480 1;
#X obj 37 236 i;
#X obj 53 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 4762 1;
#X obj 63 236 i;
#X obj 79 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 5854 1;
#X obj 89 236 i;
#X obj 105 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 3572 1;
#X obj 115 236 i;
#X obj 131 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2480 1;
#X obj 141 236 i;
#X obj 157 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 3770 1;
#X obj 167 236 i;
#X obj 183 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2084 1;
#X obj 193 236 i;
#X obj 209 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 4762 1;
#X obj 219 236 i;
#X obj 235 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 3473 1;
#X obj 245 236 i;
#X obj 261 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2580 1;
#X obj 271 236 i;
#X obj 287 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2084 1;
#X obj 297 236 i;
#X obj 313 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2977 1;
#X obj 323 236 i;
#X obj 339 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2282 1;
#X obj 349 236 i;
#X obj 365 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 3572 1;
#X obj 375 236 i;
#X obj 391 46 vsl 25 129 -1 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 2282 1;
#X obj 401 236 i;
#X obj 179 287 outlet;
#X floatatom 100 2 5 0 0 0 - - -;
#X obj 460 385 /;
#X obj 446 325 t b f;
#X msg 436 356 60000;
#X floatatom 170 2 5 1 16 0 - - -;
#X obj 601 395 t b f b b;
#X text 207 2 length;
#X text 137 2 BPM;
#X text 394 1 Run;
#X obj 484 233 == 1;
#X obj 1 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1;
#X obj 27 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 53 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 79 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 105 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 131 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 157 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 183 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 209 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 235 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 261 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 287 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 313 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 339 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 365 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 391 18 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 510 213 == 2;
#X obj 536 233 == 3;
#X obj 562 213 == 4;
#X obj 588 233 == 5;
#X obj 614 213 == 6;
#X obj 640 233 == 7;
#X obj 666 213 == 8;
#X obj 692 233 == 9;
#X obj 718 213 == 10;
#X obj 744 233 == 11;
#X obj 770 213 == 12;
#X obj 796 233 == 13;
#X obj 822 213 == 14;
#X obj 848 233 == 15;
#X obj 874 213 == 16;
#X obj 319 495 >= 16;
#X obj 462 409 / 4;
#X floatatom 259 1 5 1 4 0 - - -;
#X text 296 1 Steps/Beat;
#X obj 438 -7 loadbang;
#X msg 633 39 \$1;
#X msg 665 39 \$2;
#X msg 700 38 \$3;
#X msg 731 39 \$4;
#X msg 773 38 \$5;
#X msg 805 38 \$6;
#X msg 840 37 \$7;
#X msg 872 37 \$8;
#X msg 685 64 \$9;
#X msg 717 64 \$10;
#X msg 752 63 \$11;
#X msg 783 64 \$12;
#X msg 825 63 \$13;
#X msg 857 63 \$14;
#X msg 892 62 \$15;
#X msg 924 62 \$16;
#X obj 441 294 i;
#X obj 470 264 t b f;
#X msg 60 482 \$17;
#X msg 115 481 \$18;
#X msg 173 490 \$19;
#X msg 516 -2 34 24 47 58 35 24 37 20 47 34 25 20 29 22 35 22 110 16
4;
#X obj 633 104 inlet;
#X obj 792 137 inlet;
#X connect 0 0 3 0;
#X connect 1 0 2 1;
#X connect 2 0 40 0;
#X connect 3 0 6 0;
#X connect 4 0 5 0;
#X connect 5 0 3 1;
#X connect 6 0 3 1;
#X connect 6 0 7 0;
#X connect 6 0 82 0;
#X connect 7 0 9 0;
#X connect 7 0 50 0;
#X connect 7 0 67 0;
#X connect 7 0 68 0;
#X connect 7 0 69 0;
#X connect 7 0 70 0;
#X connect 7 0 71 0;
#X connect 7 0 72 0;
#X connect 7 0 73 0;
#X connect 7 0 74 0;
#X connect 7 0 75 0;
#X connect 7 0 76 0;
#X connect 7 0 77 0;
#X connect 7 0 78 0;
#X connect 7 0 79 0;
#X connect 7 0 80 0;
#X connect 7 0 81 0;
#X connect 8 0 0 0;
#X connect 9 0 2 0;
#X connect 9 1 11 0;
#X connect 9 2 13 0;
#X connect 9 3 15 0;
#X connect 9 4 17 0;
#X connect 9 5 19 0;
#X connect 9 6 21 0;
#X connect 9 7 23 0;
#X connect 9 8 25 0;
#X connect 9 9 27 0;
#X connect 9 10 29 0;
#X connect 9 11 31 0;
#X connect 9 12 33 0;
#X connect 9 13 35 0;
#X connect 9 14 37 0;
#X connect 9 15 39 0;
#X connect 10 0 11 1;
#X connect 11 0 40 0;
#X connect 12 0 13 1;
#X connect 13 0 40 0;
#X connect 14 0 15 1;
#X connect 15 0 40 0;
#X connect 16 0 17 1;
#X connect 17 0 40 0;
#X connect 18 0 19 1;
#X connect 19 0 40 0;
#X connect 20 0 21 1;
#X connect 21 0 40 0;
#X connect 22 0 23 1;
#X connect 23 0 40 0;
#X connect 24 0 25 1;
#X connect 25 0 40 0;
#X connect 26 0 27 1;
#X connect 27 0 40 0;
#X connect 28 0 29 1;
#X connect 29 0 40 0;
#X connect 30 0 31 1;
#X connect 31 0 40 0;
#X connect 32 0 33 1;
#X connect 33 0 40 0;
#X connect 34 0 35 1;
#X connect 35 0 40 0;
#X connect 36 0 37 1;
#X connect 37 0 40 0;
#X connect 38 0 39 1;
#X connect 39 0 40 0;
#X connect 41 0 103 0;
#X connect 42 0 83 0;
#X connect 43 0 44 0;
#X connect 43 1 42 1;
#X connect 44 0 42 0;
#X connect 45 0 46 0;
#X connect 46 0 8 0;
#X connect 46 1 82 1;
#X connect 46 2 5 0;
#X connect 46 3 8 0;
#X connect 50 0 51 0;
#X connect 67 0 52 0;
#X connect 68 0 53 0;
#X connect 69 0 54 0;
#X connect 70 0 55 0;
#X connect 71 0 56 0;
#X connect 72 0 57 0;
#X connect 73 0 58 0;
#X connect 74 0 59 0;
#X connect 75 0 60 0;
#X connect 76 0 61 0;
#X connect 77 0 62 0;
#X connect 78 0 63 0;
#X connect 79 0 64 0;
#X connect 80 0 65 0;
#X connect 81 0 66 0;
#X connect 82 0 4 0;
#X connect 83 0 0 1;
#X connect 84 0 104 0;
#X connect 86 0 108 0;
#X connect 87 0 1 0;
#X connect 88 0 10 0;
#X connect 89 0 12 0;
#X connect 90 0 14 0;
#X connect 91 0 16 0;
#X connect 92 0 18 0;
#X connect 93 0 20 0;
#X connect 94 0 22 0;
#X connect 95 0 24 0;
#X connect 96 0 26 0;
#X connect 97 0 28 0;
#X connect 98 0 30 0;
#X connect 99 0 32 0;
#X connect 100 0 34 0;
#X connect 101 0 36 0;
#X connect 102 0 38 0;
#X connect 103 0 43 0;
#X connect 104 0 103 0;
#X connect 104 1 83 1;
#X connect 105 0 41 0;
#X connect 106 0 45 0;
#X connect 107 0 84 0;
#X connect 108 0 87 0;
#X connect 108 0 88 0;
#X connect 108 0 89 0;
#X connect 108 0 90 0;
#X connect 108 0 91 0;
#X connect 108 0 92 0;
#X connect 108 0 93 0;
#X connect 108 0 94 0;
#X connect 108 0 95 0;
#X connect 108 0 96 0;
#X connect 108 0 97 0;
#X connect 108 0 98 0;
#X connect 108 0 99 0;
#X connect 108 0 100 0;
#X connect 108 0 101 0;
#X connect 108 0 102 0;
#X connect 108 0 107 0;
#X connect 108 0 106 0;
#X connect 108 0 105 0;
#X connect 109 0 87 0;
#X connect 109 0 88 0;
#X connect 109 0 89 0;
#X connect 109 0 90 0;
#X connect 109 0 91 0;
#X connect 109 0 92 0;
#X connect 109 0 93 0;
#X connect 109 0 94 0;
#X connect 109 0 95 0;
#X connect 109 0 96 0;
#X connect 109 0 97 0;
#X connect 109 0 98 0;
#X connect 109 0 99 0;
#X connect 109 0 100 0;
#X connect 109 0 101 0;
#X connect 109 0 102 0;
#X connect 109 0 105 0;
#X connect 109 0 106 0;
#X connect 109 0 107 0;
#X connect 110 0 87 0;
#X connect 110 0 88 0;
#X connect 110 0 89 0;
#X connect 110 0 90 0;
#X connect 110 0 91 0;
#X connect 110 0 92 0;
#X connect 110 0 93 0;
#X connect 110 0 94 0;
#X connect 110 0 95 0;
#X connect 110 0 96 0;
#X connect 110 0 97 0;
#X connect 110 0 98 0;
#X connect 110 0 99 0;
#X connect 110 0 100 0;
#X connect 110 0 101 0;
#X connect 110 0 102 0;
#X coords 0 0 1 1 417 180 1 0 0;

--- NEW FILE: bassemu~-help.pd ---
#N canvas 113 73 852 548 10;
#X obj 171 202 dac~;
#X obj 182 169 bassemu~;
#X text 358 100 CutOff;
#X text 412 100 Reso;
#X text 451 100 EnvMod;
#X text 501 100 Decay;
#X obj 372 55 loadbang;
#X obj 730 294 vradio 15 1 0 5 empty empty empty 0 -6 0 8 -262144 -1
-1 0;
#X msg 730 372 ext \$1;
#X obj 730 392 s bass_ctl;
#X obj 603 116 vsl 25 128 0 127 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 0 1;
#X msg 603 272 glide \$1;
#X obj 730 174 vradio 15 1 0 4 empty empty empty 0 -6 0 8 -262144 -1
-1 0;
#X obj 730 257 s bass_ctl;
#X msg 730 237 vco \$1;
#X obj 730 430 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 730 468 s bass_ctl;
#X msg 730 448 hpf \$1;
#X obj 467 396 vradio 15 1 0 3 empty empty empty 0 -6 0 8 -262144 -1
-1 0;
#X obj 467 464 s bass_ctl;
#X msg 467 444 limit \$1;
#X msg 729 113 tune \$1;
#X floatatom 729 95 5 0 0 0 - - -;
#X obj 729 135 s bass_ctl;
#X msg 729 72 440;
#X floatatom 21 178 5 0 0 0 - - -;
#X obj 182 101 r bass_ctl;
#X text 749 173 Saw;
#X text 749 189 Square;
#X text 749 205 Tri;
#X text 749 219 Sine;
#X text 750 431 VCO-HPF;
#X text 768 95 Tune;
#X text 747 292 Int.Only;
#X text 747 309 Ext.Only;
#X text 747 324 Int.+Ext.;
#X text 747 339 Ext.Only+HPF;
#X text 748 355 Int.+Ext.+HPF;
#X text 485 396 No limiting;
#X text 486 412 Hard Limiting;
#X text 486 427 Sine Limiting;
#X text 597 101 Glide;
#X msg 11 101 30 0.5 0.3 0.1 0.5;
#X obj 372 115 vsl 25 128 -1 1 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 9525 1;
#X obj 418 115 vsl 25 128 -1 2 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 7620 1;
#X obj 464 115 vsl 25 128 -1 2 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 7197 1;
#X obj 510 115 vsl 25 128 -1 1 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 6985 1;
#X obj 556 115 vsl 25 128 0 1 0 0 empty empty empty 0 -8 0 8 -262144
-1 -1 6350 1;
#X msg 372 72 0.5;
#X msg 418 72 0.8;
#X msg 464 72 0.7;
#X msg 510 72 0.1;
#X msg 556 72 0.5;
#X msg 21 242 -1;
#X text 6 74 <note> <reso> <envmod> <decay> <pulsewidth>;
#X text 7 61 Send Note-Events as List of Floats:;
#X text 21 224 -1 to turn Note Off;
#X text 9 85 All Parameters are optional;
#X obj 11 325 miniseq;
#X obj 11 511 s bass_ctl;
#X obj 11 268 s bass_ctl;
#X text 447 378 Output-Signal Limiting:;
#X text 729 158 VCO WaveSelect:;
#X text 728 57 VCO Tuning:;
#X text 729 279 SoundSource:;
#X text 729 414 Extra HiPass:;
#X msg 627 486 envinc \$1;
#X obj 627 506 s bass_ctl;
#X msg 627 347 8;
#X msg 627 364 64;
#X msg 627 381 256;
#X msg 627 398 1024;
#X msg 627 415 8192;
#X msg 627 449 32768;
#X msg 627 466 65536;
#X msg 627 432 16384;
#X text 21 147 Note-Number to;
#X text 21 160 play immediatly;
#X text 595 332 EnvGen Stepsize:;
#X text 8 5 bassemu~: a transistor bass emulation;
#X text 7 27 You can feed an external audio source to;
#X text 7 41 the leftmost inlet.;
#X msg 372 255 cutoff \$1;
#X msg 418 275 reso \$1;
#X obj 464 311 s bass_ctl;
#X msg 464 251 envmod \$1;
#X msg 510 271 decay \$1;
#X msg 556 251 pw \$1;
#X msg 189 132 reset;
#X text 233 121 Emergency Reset;
#X text 233 134 in case the filter;
#X text 233 146 goes mad;
#X text 401 4 Extreme settings here may;
#X text 402 20 bork up the Filter. Use the;
#X text 401 34 reset message to the bassemu then;
#X text 554 90 Rect;
#X text 551 100 Width;
#X obj 603 251 / 127;
#X msg 217 276 pitch \$1;
#X obj 220 218 hsl 129 15 0 128 0 0 empty empty empty -2 -6 0 8 -262144
-1 -1 6400 1;
#X obj 217 235 - 64;
#X obj 217 295 s bass_ctl;
#X obj 217 254 / 16;
#X msg 217 199 64;
#X obj 250 236 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10
-262144 -1 -1 0 256;
#X text 258 199 Pitch Bend;
#X connect 1 0 0 0;
#X connect 1 0 0 1;
#X connect 6 0 48 0;
#X connect 6 0 49 0;
#X connect 6 0 50 0;
#X connect 6 0 51 0;
#X connect 6 0 52 0;
#X connect 6 0 24 0;
#X connect 6 0 103 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 10 0 97 0;
#X connect 11 0 84 0;
#X connect 12 0 14 0;
#X connect 14 0 13 0;
#X connect 15 0 17 0;
#X connect 17 0 16 0;
#X connect 18 0 20 0;
#X connect 20 0 19 0;
#X connect 21 0 23 0;
#X connect 22 0 21 0;
#X connect 24 0 22 0;
#X connect 25 0 60 0;
#X connect 26 0 1 0;
#X connect 42 0 60 0;
#X connect 43 0 82 0;
#X connect 44 0 83 0;
#X connect 45 0 85 0;
#X connect 46 0 86 0;
#X connect 47 0 87 0;
#X connect 48 0 43 0;
#X connect 49 0 44 0;
#X connect 50 0 45 0;
#X connect 51 0 46 0;
#X connect 52 0 47 0;
#X connect 53 0 60 0;
#X connect 58 0 59 0;
#X connect 66 0 67 0;
#X connect 68 0 66 0;
#X connect 69 0 66 0;
#X connect 70 0 66 0;
#X connect 71 0 66 0;
#X connect 72 0 66 0;
#X connect 73 0 66 0;
#X connect 74 0 66 0;
#X connect 75 0 66 0;
#X connect 82 0 84 0;
#X connect 83 0 84 0;
#X connect 85 0 84 0;
#X connect 86 0 84 0;
#X connect 87 0 84 0;
#X connect 88 0 1 0;
#X connect 97 0 11 0;
#X connect 98 0 101 0;
#X connect 99 0 100 0;
#X connect 100 0 102 0;
#X connect 102 0 98 0;
#X connect 102 0 104 0;
#X connect 103 0 99 0;

--- NEW FILE: Makefile ---
NAME=bassemu~
CSYM=bassemu

current: pd_linux

# ----------------------- NT -----------------------

pd_nt: $(NAME).dll

.SUFFIXES: .dll

VC="C:\Programme\Microsoft Platform SDK"
VCC="C:\Programme\Microsoft Visual Studio 8"
PDPATH="C:\Programme\pd"
PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo


PDNTINCLUDE = /I. /I$(PDPATH)\tcl\include /I$(PDPATH)\src /I$(VC)\include /I$(LIBUSBPATH)\include

PDNTLDIR = $(VC)\lib
# --- PDNTLIB = $(PDNTLDIR)\libc.lib \
# --- PDNTLIB = $(PDNTLDIR)\oldnames.lib \
PDNTLIB = $(PDNTLDIR)\uuid.lib \
	$(PDPATH)\bin\pd.lib  \
	$(PDPATH)\bin\pthreadVC.lib

.c.dll:
	cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
	link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB)

# ----------------------- LINUX i386 -----------------------

pd_linux: $(NAME).pd_linux

.SUFFIXES: .pd_linux

LINUXCFLAGS = -DPD -O3 -funroll-loops -Wall -fomit-frame-pointer -fPIC \
    -Wall -W -Wshadow -Wstrict-prototypes \
    -Wno-unused -Wno-parentheses -Wno-switch $(CFLAGS)

LINUXINCLUDE =  -I../../src

.c.pd_linux:
	$(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
	ld -export_dynamic  -shared -o $*.pd_linux $*.o -lc -lm
	strip --strip-unneeded $*.pd_linux
	rm -f $*.o

# ----------------------- Mac OSX -----------------------

pd_darwin: $(NAME).pd_darwin

.SUFFIXES: .pd_darwin

DARWINCFLAGS = -DPD -O3 -funroll-loops -Wall -W -Wshadow -Wstrict-prototypes \
    -Wno-unused -Wno-parentheses -Wno-switch

.c.pd_darwin:
	$(CC) $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
	$(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
	rm -f $*.o

# ----------------------------------------------------------

clean:
	rm -f *.o *.pd_* so_locations

--- NEW FILE: bassemu~.pd_linux ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: COPYING ---
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Library General
Public License instead of this License.

--- NEW FILE: bassemu~.c ---
/* (c) 2006 Ch. Klippel
 * this software is gpl'ed software, read the file "COPYING" for details
 */

#include "m_pd.h"
#include "math.h"

/* -------------------------- bassemu~ ------------------------------ */
static t_class *bassemu_class;

#define VER_MAJ	0
#define VER_MIN	3
#define PI_2   	6.28218530717958647692
#define sinfact (2. * 6.28328)

typedef struct _bassemu
{
    t_object x_obj;
	float vco_inc, vco_actinc;
	float current_wave, ideal_wave, delta, vco_count;
	float pw;
	int   vco_type, hpf;
	float glide;
	float thisnote;
	float tune;
  	float vcf_cutoff, vcf_envmod, vcf_envdecay, vcf_reso, vcf_rescoeff;
	float vcf_a, vcf_b, vcf_c, vcf_c0, vcf_d1, vcf_d2, vcf_e0, vcf_e1;
	int  	vcf_envpos;
  	float vca_attack;
	float vca_decay;
	float vca_a;
	float vca_a0;
	int 	vca_mode;
	int		limit_type;
	int		ext_type;
	char	ext_pre;
	int		envinc;
	float decay;
	float pitch;
	float sr;
	float dummy;
} t_bassemu;


static t_int *bassemu_perform(t_int *ww)
{
    t_bassemu *x = (t_bassemu *)(ww[1]);
    t_float *inbuf = (t_float *)(ww[2]);
    t_float *outbuf = (t_float *)(ww[3]);
    int n = (int)(ww[4]);

	float w = 0, k=0, ts=0, is=0;

	// only compute if needed .......
	if (x->vca_mode != 2)
	{
		// begin bassemu dsp engine
		while(n--)
		{

			if (x->ext_type > 0)
			{
					is = (*inbuf++ * 0.48);
					if (is < -0.48) is = -0.48f;
					if (is > 0.48) is = 0.48f;
			}
			// update vcf
			if(x->vcf_envpos >= x->envinc) {
				w = x->vcf_e0 + x->vcf_c0;
				k = exp(-w/x->vcf_rescoeff);
				x->vcf_c0 *= x->vcf_envdecay;
				x->vcf_a = 2.0*cos(2.0*w) * k;
				x->vcf_b = -k*k;
				x->vcf_c = 1.0 - x->vcf_a - x->vcf_b;
				x->vcf_envpos = 0;
			}

			// update vco
			if (!x->glide) x->vco_actinc = x->vco_inc;  // handle glide
			else
			{
				if (x->vco_inc > x->vco_actinc)
					x->vco_actinc = (x->vco_actinc +
											((x->vco_inc -
											x->vco_actinc) /
											(x->glide * (x->sr/10.)) ) );

				if (x->vco_inc < x->vco_actinc)
					x->vco_actinc = (x->vco_actinc -
											((x->vco_actinc -
											x->vco_inc) /
											(x->glide * (x->sr/10.)) ) );
			}

			// select waveform
			switch((int)x->vco_type)
			{
				case 0 : 	// sawtooth
								x->ideal_wave = sin(x->vco_count);
								x->vco_count += x->vco_actinc;
							break;

				case 1 :  // rectangle
								if ((x->vco_count+0.5) <= x->pw)
									x->ideal_wave = -0.5;
								else
									x->ideal_wave = 0.5;
								x->vco_count += x->vco_actinc;
								break;

				case 2 :  // triangle
								if (x->vco_count == -0.5 )
									x->ideal_wave = (x->vco_count + 0.000001);
								else
								{
									if (x->vco_count <= 0.0 )
										x->ideal_wave = (x->ideal_wave + (x->vco_actinc * 2));
									else
										x->ideal_wave = (x->ideal_wave - (x->vco_actinc * 2));
								}
								x->vco_count += x->vco_actinc;
								break;

				case 3 : // sine
								x->ideal_wave = (sin(sinfact * (x->vco_count + 0.5)) / 2);
								x->vco_count += (x->vco_actinc / 2.);
								break;
				default : break;
			}


			// waveform rises faster than it falls
			if( x->vco_count <= 0.0 )
				x->current_wave = ( x->current_wave + ((x->ideal_wave - x->current_wave) *	0.95 ));
			else
				x->current_wave = ( x->current_wave + ((x->ideal_wave - x->current_wave) * 0.9 ));




			// recyle and end
			if (x->vco_count > 0.5)
				x->vco_count = (-0.5);

			// run external through VCO-HPF
			if(x->ext_pre)
				switch((int)x->ext_type)
				{
					case 1 :
									x->current_wave = is;
									break;
					case 2 :
									x->current_wave = ((x->current_wave + is) *0.5f);
									break;
					default : break;
				}

			ts = x->current_wave;

			// vco hpf function
			if( x->hpf )
			{
				x->delta = (x->delta * x->current_wave);
				x->delta = (x->delta * 0.99 );
				ts = ((x->delta*2)+0.5);
				x->delta = (x->delta - x->current_wave );
			}

			// update vca
			if(!x->vca_mode)
				x->vca_a += (x->vca_a0 - x->vca_a) * x->vca_attack;
			else if(x->vca_mode == 1)
			{
				x->vca_a *= x->vca_decay;
				if(x->vca_a < (1/65536.0))
				{
					x->vca_a = 0;
					x->vca_mode = 2;
				}
			}

			// mix external without filtering with VCO-HPF
			if(!x->ext_pre)
				switch((int)x->ext_type)
				{
					case 1 :
									ts = is;
									break;
					case 2 :
									ts = ((ts + is) * 0.5f);
									break;
					default : break;
				}


			// compute sample
			ts = x->vcf_a * x->vcf_d1 + x->vcf_b * x->vcf_d2 + x->vcf_c * ts * x->vca_a;
			x->vcf_d2 = x->vcf_d1;
			x->vcf_envpos++;
			x->vcf_d1 = ts;

			switch((int)x->limit_type)
			{
				case 1 :   //		 hard limit
									if (ts >  0.999) ts =  0.999;
									if (ts < -0.999) ts = -0.999;
									*outbuf++ = ts;
									break;

				case 2 :   //    sine limiting
									*outbuf++ = sin(ts);
									break;

				default :  //    no limiting et al
									*outbuf++ = ts;
									break;
			}

		}
	} //end vcamode != 2
	else
		while(n--)
		{
			*outbuf++ = 0.0f;
		}

	return (ww+5);
}

static void bassemu_dsp(t_bassemu *x, t_signal **sp)
{
	x->sr = sp[0]->s_sr;
	dsp_add(bassemu_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
}

static void recalc(t_bassemu *x)
{
  	x->vcf_e1 = exp(6.109 + 1.5876*(x->vcf_envmod) + 2.1553*(x->vcf_cutoff) - 1.2*(1.0-x->vcf_reso));
	x->vcf_e0 = exp(5.613 - 0.8*(x->vcf_envmod) + 2.1553*(x->vcf_cutoff) - 0.7696*(1.0-x->vcf_reso));
	x->vcf_e0 *=M_PI/x->sr;
	x->vcf_e1 *=M_PI/x->sr;
	x->vcf_e1 -= x->vcf_e0;
	x->vcf_envpos = x->envinc;
}

static void bassemu_note(t_bassemu *x, t_floatarg f)
{
// calculate note and trigger vca
	if(f != -1) { // note
		x->thisnote = x->pitch + f-57;
		x->vco_inc = ((x->tune/x->sr)*pow(2, (x->thisnote)*(1.0/12.0)) / 2.);
		x->vca_mode = 0;
		x->vcf_c0 = x->vcf_e1;
		x->vcf_envpos = x->envinc;
	}
	else x->vca_mode = 1;
}

static void bassemu_pitch(t_bassemu *x, t_floatarg f)
{

	x->thisnote -= x->pitch;
	x->pitch = f;
	x->thisnote += x->pitch;
	x->vco_inc = ((x->tune/x->sr)*pow(2, (x->thisnote)*(1.0/12.0)) / 2.);
}

static void bassemu_list(t_bassemu *x, t_symbol *s, int argc, t_atom *argv)
{
	if (argc >= 5)
	{
		// get decay
		if(argv[4].a_type == A_FLOAT && (atom_getfloatarg(4,argc,argv) != -1))
		{ // decay
			float d = atom_getfloatarg(4,argc,argv);
			x->decay = d;
			d = 0.2 + (2.3*d);
			d*=x->sr;
			x->vcf_envdecay = pow(0.1, 1.0/d * x->envinc);
		}
		recalc(x);
	}
	if (argc >= 4)
	{
		// get envelope modulation
		if(argv[3].a_type == A_FLOAT && (atom_getfloatarg(3,argc,argv) != -1))
		{ // envmod
			x->vcf_envmod = atom_getfloatarg(1,argc,argv);
		}
		recalc(x);
	}
	if (argc >= 3)
	{
		//get resonance
		if(argv[2].a_type == A_FLOAT && (atom_getfloatarg(2,argc,argv) != -1))
		{ // resonance
			x->vcf_reso = atom_getfloatarg(1,argc,argv);
			x->vcf_rescoeff = exp(-1.20 + 3.455*(x->vcf_reso));
		}
		recalc(x);
	}
	if (argc >= 2)
	{
		// get cutoff
		if(argv[1].a_type == A_FLOAT && (atom_getfloatarg(1,argc,argv) != -1))
		{ // cutoff
			x->vcf_cutoff = atom_getfloatarg(1,argc,argv);
		}
		recalc(x);
	}
	if (argc >= 1)
	{
		if(argv[0].a_type = A_FLOAT && (atom_getfloatarg(0,argc,argv) != -1))
		{ // note
			x->thisnote = atom_getfloatarg(0,argc,argv)-57;
			x->vco_inc = ((x->tune/x->sr)*pow(2, (x->thisnote)*(1.0/12.0)) / 2.);
			x->vca_mode = 0;
			x->vcf_c0 = x->vcf_e1;
			x->vcf_envpos = x->envinc;
		}
		else
			x->vca_mode = 1;
		recalc(x);
	}
}

static void bassemu_vco(t_bassemu *x, t_floatarg f)
{
	if ((f >= 0) && (f <= 8))
		x->vco_type = f;
	else
		x->vco_type = 0;
}

static void bassemu_hpf(t_bassemu *x, t_floatarg f)
{
	if ((f >= 0) && (f <= 1))
		x->hpf = f;
	else
		x->hpf = 0;
}

static void bassemu_glide(t_bassemu *x, t_floatarg f)
{
	if (f == 0)
		x->glide = 0;
	else
		x->glide = f;
}

static void bassemu_limit(t_bassemu *x, t_floatarg f)
{
	if ((f >= 0) && (f <=2)) x->limit_type = f;
}

static void bassemu_ext(t_bassemu *x, t_floatarg f)
{
	if ((f >= 0) && (f <=2)) { x->ext_type = f; x->ext_pre = 0; }
	if (f == 3) { x->ext_type = 1; x->ext_pre = 1; }
	if (f == 4) { x->ext_type = 2; x->ext_pre = 1; }
}

static void bassemu_tune(t_bassemu *x, t_floatarg f)
{
	x->tune = f;
	x->vco_inc = ((x->tune/x->sr)*pow(2, (x->thisnote)*(1.0/12.0)) / 2.0);
}

static void bassemu_envinc(t_bassemu *x, t_floatarg f)
{
	float d = x->decay;

	if (f >= 1) x->envinc = f;
	d = 0.2 + (2.3*d);
	d *= x->sr;
	x->vcf_envdecay = pow(0.1, 1.0/d * x->envinc);
}

static void bassemu_cutoff(t_bassemu *x, t_floatarg f)
{
	x->vcf_cutoff = f;
	recalc(x);
}

static void bassemu_reso(t_bassemu *x, t_floatarg f)
{
	x->vcf_reso = f;
	x->vcf_rescoeff = exp(-1.20 + 3.455*(x->vcf_reso));
	recalc(x);
}

static void bassemu_envmod(t_bassemu *x, t_floatarg f)
{
	x->vcf_envmod = f;
	recalc(x);
}

static void bassemu_decay(t_bassemu *x, t_floatarg f)
{
	float d = f;
	x->decay = d;
	d = 0.2 + (2.3*d);
	d*=x->sr;
	x->vcf_envdecay = pow(0.1, 1.0/d * x->envinc);
}

static void bassemu_pw(t_bassemu *x, t_floatarg f)
{
	x->pw = f;

	if (x->pw > 1.0)
		x->pw = 1.0;

	if (x->pw < 0.0)
		x->pw = 0.0;
}

static void bassemu_reset(t_bassemu *x, t_floatarg f)
{
	x->vco_inc = 0.0f;
	x->vco_actinc = 0.0f;
	x->current_wave = 0.0f;
	x->ideal_wave = 0.0f;
	x->delta = 0.0f;
	x->vco_count = 0.0f;
	x->pw = 0.5f;
	x->vco_type = 0;
	x->hpf = 0.0f;
	x->glide = 0.0f;
	x->tune = 440.0f;
	x->thisnote = 0;

	x->vcf_cutoff = 0.0;
	x->vcf_envmod = 0.0;
	x->vcf_envdecay = 0.0;
	x->vcf_reso = 0.0;
	x->vcf_rescoeff = 0.0f;
	x->vcf_a = 0.0;
	x->vcf_b = 0.0;
	x->vcf_c = 0.0;
	x->vcf_c0 = 0.0;
	x->vcf_d1 = 0.0;
	x->vcf_d2 = 0.0;
	x->vcf_e0 = 0.0;
	x->vcf_e1 = 0.0f;
	x->vcf_envpos = 64;
	x->vca_attack = (float)(1.0f - 0.94406088f);
	x->vca_decay  = (float)(0.99897516f);
	x->vca_a = 0.0f;
	x->vca_a0 = 0.5f;
	x->vca_mode = 2 ; // attack (0) / decay (1) / silent (2) mode

	x->limit_type = 2;

	x->ext_type = 0;
	x->ext_pre	= 0;

	x->envinc = 64;
	x->decay  = 0;
	x->pitch = 0;

}

static void *bassemu_new(t_symbol *s, int argc, t_atom *argv)
{
	unsigned int numargs;
    t_bassemu *x = (t_bassemu *)pd_new(bassemu_class);

	outlet_new(&x->x_obj, gensym("signal"));
	bassemu_reset(x,0);
	x->sr = 44100.;
    return (x);
}

static void bassemu_free(t_bassemu *x)
{
}


void bassemu_tilde_setup(void)
{
    bassemu_class = class_new(gensym("bassemu~"), (t_newmethod)bassemu_new,
        (t_method)bassemu_free, sizeof(t_bassemu), CLASS_DEFAULT, A_GIMME, 0);

    CLASS_MAINSIGNALIN(bassemu_class, t_bassemu, dummy);

    class_addmethod(bassemu_class, (t_method)bassemu_dsp,	gensym("dsp"), 0);
	class_addfloat (bassemu_class, (t_method)bassemu_note); // start/stop using a toggle
	class_addmethod(bassemu_class, (t_method)bassemu_list,	gensym("list"),		A_GIMME, 	0);
	class_addmethod(bassemu_class, (t_method)bassemu_vco,	gensym("vco"), 		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_hpf,	gensym("hpf"), 		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_glide,	gensym("glide"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_limit,	gensym("limit"), 	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_ext,	gensym("ext"), 		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_tune,	gensym("tune"),		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_envinc,gensym("envinc"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_reset,	gensym("reset"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_cutoff,gensym("cutoff"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_reso,	gensym("reso"),		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_envmod,gensym("envmod"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_decay,	gensym("decay"),	A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_pw,	gensym("pw"),		A_DEFFLOAT, 0);
	class_addmethod(bassemu_class, (t_method)bassemu_pitch,	gensym("pitch"),	A_DEFFLOAT, 0);

	post("bassemu~: transistor bass emulation");
	post("bassemu~: version %i.%i",VER_MAJ, VER_MIN);
	post("bassemu~: (c) 2006 Ch. Klippel - ck at mamalala.de");
	post("bassemu~: this is gpl'ed software, see README for details\n");
}






More information about the Pd-cvs mailing list