Hello! I'm new to pd and the mailing list. Just downloaded pd last week and had the chance to get into it tonight for about an hour or so. The attached file is what I came up with so far. It is an attempt to send MIDI notes and control messages to a softsynth (running in Buzz). It works, but I am sure that what I am trying to do could be done in a much better way. Basically, the thing is trying to use a sine wave to control the filter cutoff parameter...like an LFO sort of. I would be grateful if anyone could have a look at it and (without laughing) tell me what improvements should be made. Am I using the arrays and tabwrite/tabread correctly? Obviously, the way I am stepping through the indexes in the array is just stupid... any pointers you may have would be most welcome. thanks, spiffy
Do you Yahoo!? The New Yahoo! Shopping - with improved product search
#N canvas 14 0 784 500 12; #N canvas 0 0 468 318 graph15 0; #X coords 0 1 99 -1 0 0 1; #X restore 549 211 graph; #X obj 586 220 table arraybob; #X obj 90 269 tabread arraybob; #X floatatom 90 297 5 0 0 0 - - -; #X msg 118 239 set arraybob; #X floatatom 90 214 0 0 0 0 - - -; #X obj 90 188 + 1; #X msg -1 142 stop; #X obj 90 162 float; #X obj 90 110 trigger bang bang; #X floatatom 173 136 5 0 0 0 - - -; #X obj 339 407 makenote; #X obj 339 439 noteout; #X floatatom 339 376 5 0 0 0 - - -; #X floatatom 412 375 5 0 0 0 - - -; #X floatatom 434 405 5 0 0 0 - - -; #X msg 342 190 bang; #X msg 389 191 stop; #X floatatom 191 55 5 0 0 0 - - -; #X obj 90 136 metro; #X obj 105 438 ctlout 15 1; #X obj 90 321 moses 0; #X floatatom 149 390 5 0 0 0 - - -; #X floatatom 72 387 5 0 0 0 - - -; #X floatatom 568 39 5 0 0 0 - - -; #X obj 569 70 osc~ 1000; #X msg 288 259 ; pd dsp 1 ;; #X obj 569 164 tabwrite~ arraybob; #X msg 396 258 ; pd dsp 0 ;; #X obj -1 116 select 1000; #X obj 149 357 * 100; #X obj 72 355 * -100; #X floatatom 614 106 5 0 0 0 - - -; #X floatatom 374 322 5 0 0 0 - - -; #X obj 339 349 metro; #X obj 579 135 metro; #X text 240 376 note--> (53); #X text 479 405 <--duration (250); #X text 421 320 <--speed (200); #X text 458 373 <--velocity (90); #X text 238 54 <--speed (220); #X text 659 105 <--speed (61); #X connect 2 0 3 0; #X connect 3 0 21 0; #X connect 4 0 2 0; #X connect 5 0 2 0; #X connect 6 0 5 0; #X connect 6 0 8 1; #X connect 6 0 29 0; #X connect 7 0 19 0; #X connect 8 0 6 0; #X connect 9 0 19 0; #X connect 9 1 10 0; #X connect 10 0 8 1; #X connect 11 0 12 0; #X connect 11 1 12 1; #X connect 13 0 11 0; #X connect 14 0 11 1; #X connect 15 0 11 2; #X connect 16 0 26 0; #X connect 16 0 9 0; #X connect 16 0 34 0; #X connect 16 0 35 0; #X connect 17 0 9 0; #X connect 17 0 19 0; #X connect 17 0 28 0; #X connect 17 0 34 0; #X connect 18 0 19 1; #X connect 19 0 8 0; #X connect 21 0 31 0; #X connect 21 1 30 0; #X connect 22 0 20 0; #X connect 23 0 20 0; #X connect 24 0 25 0; #X connect 25 0 27 0; #X connect 29 0 7 0; #X connect 30 0 22 0; #X connect 31 0 23 0; #X connect 32 0 35 1; #X connect 33 0 34 1; #X connect 34 0 13 0; #X connect 35 0 27 0; #X coords 0 0 0.00127551 0.002 200 140 0;
good morning,
instead of writing to an array, you can get the value of an audio signal more directly, and convert it to a control signal. see [snapshot~] or [avg~] and [unsig~] (which i think are in the zexy library)
here's on idea on how you could go about it. it creates an sinewave LFO using [osc~] based on BPM, snaphost~'s it every 5 msecs, scales the value to something ctlout can use (0 - 127), and outputs it.
you might want to check my math on the scaling. ugh. algebra. i should have paid more attention in junior high.
and i thought i'd never say it. algebra serves a purpose? i guess you win this time, junior high school math teacher.
--eric
------ http://USFamily.Net/info - Unlimited Internet - From $8.99/mo! ------
#N canvas 0 0 590 558 12; #X obj 42 51 / 60; #X obj 42 105 osc~; #X obj 42 30 nbx 3 14 -1e+037 1e+037 0 1 empty empty empty 0 -6 0 10 -262144 -1 -1 130 256; #X obj 41 180 snapshot~; #X obj 56 133 loadbang; #X obj 41 243 + 1; #X obj 41 264 / 2; #X obj 41 312 * 127; #X text 120 180 ... convert from audio signal to control signal; #X text 89 104 <-- LFO; #X text 76 253 convert from (-1 to 1) to (0 to 1); #X text 83 312 convert from (0 ... 1) to (0 ... 127); #X obj 44 381 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 5600 1; #X text 87 50 LFO speed (in BPM , for a quarter note); #X obj 42 76 / 4; #X text 86 75 divide by 4 (for a measure); #X obj 41 333 int; #X text 83 335 convert to an integer; #X obj 41 355 change; #X text 83 356 only update when the number changes; #X obj 56 157 metro 5; #X text 118 160 every 5 msecs ...; #X floatatom 41 430 5 0 0 0 - - -; #X text 78 429 feed this to ctlout; #X obj 41 506 ctlout 15 1; #X floatatom 274 452 5 0 0 0 - - -; #X floatatom 362 451 5 0 0 0 - - -; #X obj 190 533 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 -1 -1 6500 1; #X obj 187 494 int; #X obj 187 470 expr ($f1 * ($f3 - $f2)) + $f2; #X text 308 452 min; #X text 396 451 max; #X text 273 413 set LFO range; #X msg 274 432 25; #X msg 362 432 115; #X obj 187 514 change; #X msg 42 12 130; #X connect 0 0 14 0; #X connect 1 0 3 0; #X connect 2 0 0 0; #X connect 3 0 5 0; #X connect 4 0 20 0; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 6 0 29 0; #X connect 7 0 16 0; #X connect 12 0 22 0; #X connect 14 0 1 0; #X connect 16 0 18 0; #X connect 18 0 12 0; #X connect 20 0 3 0; #X connect 22 0 24 0; #X connect 25 0 29 1; #X connect 26 0 29 2; #X connect 28 0 35 0; #X connect 29 0 28 0; #X connect 33 0 25 0; #X connect 34 0 26 0; #X connect 35 0 27 0; #X connect 36 0 2 0;
I find that the best way to think of scaling is to think of it as a linear mapping (see attached bmp)...
then you just work out the scale factor of the mapping, ie (range 2)/(range
{or ((max 2)-(min 2))/((max 1)-(min 1)) }
and then the offset. linear mapping is clearly the linear function y = mx +c, hence you've worked out m from the scale factor, and c from the offset.
BTW eric, I'll probably get those modified rhythm estimators to you soon, just that my home pooter is absolutely up sh1t creek...
cheers!
matt
-=-=-=-=-=-=-=-=-=-=-=-=- http://www.loopit.org/ -=-=-=-=-=-=-=-=-=-=-=-=-
good morning,
instead of writing to an array, you can get the value of an audio signal more directly, and convert it to a control signal. see [snapshot~] or [avg~] and [unsig~] (which i think are in the zexy library)
here's on idea on how you could go about it. it creates an sinewave LFO using [osc~] based on BPM, snaphost~'s it every 5 msecs, scales the value to something ctlout can use (0 - 127), and outputs it.
you might want to check my math on the scaling. ugh. algebra. i should have paid more attention in junior high.
and i thought i'd never say it. algebra serves a purpose? i guess you win this time, junior high school math teacher.
--eric
------ http://USFamily.Net/info - Unlimited Internet - From
$8.99/mo! ------