[PD] arpeggiator

Roman Haefeli reduzierer at yahoo.de
Wed Sep 12 20:07:02 CEST 2007


On Wed, 2007-09-12 at 18:17 +0200, Atte André Jensen wrote:

> Ok, I could go on and do my second external (since I would be able to 
> write this up in C in no time), but I'm wondering:
> 
> 1) Is there a similar wheel out there?

there probably many ways to do it. i personally think, that the
abstraction way is the more preferrable one, for reasons frank has
already outlined. 

> 2) Would it be not-so-tricky to do as an abstraction? Newbie-me wouldn't 
> know how to a) hold onto a grab-bag of notes played on one channel

i believe, that for you as a c programmer it should also doable easily
within pd as well. the main culprit is probably, that you might don't
know already, which objects to use and also how to use certain design
patterns in pd, that you might know from other languages. i tried to
make a little sketch, how this could look like in pd (see attachment). i
also used the bag metaphor, that you mentioned. when you see the patch,
there is the bag on one hand and (i call them) "bag methods" on the
other hand: [pd add_notes], [pd remove_notes] and [pd get_notes]. by
using this design pattern, you can add easily as much methods to the bag
as you want. 

>  and 
> b) select them according to the selected mode. Which data structure 
> would be nice to store/retrieve from in such a case (should dynamically 
> grow/shrink)?
> 

the problem with my approach is, that the single notes are sorted by
their noteon-time (or is this a feature? i don't know), whereas with the
approach frank barknecht mentioned (the one using a table to store the
state of each note) notes can easily sorted by their pitch, what probaby
makes it easier to create different modes for your arpeggiator. 

anyway, i think this task is a good example to get in contact with the
logic of pd a bit. i encourage you to go on and ask the list again, if
you need specific help.

roman

 



-------------- next part --------------
#N canvas 412 10 558 488 10;
#X obj 8 91 list;
#X obj 8 39 r \$0.bag.i0;
#X obj 31 63 r \$0.bag.i1;
#N canvas 869 418 336 263 add_notes 0;
#X obj 15 14 inlet;
#X obj 15 48 t b b a;
#X obj 37 73 s \$0.bag.i0;
#X obj 15 117 list;
#X text 143 84 get actual content;
#X obj 15 172 list append;
#X text 144 176 add new note;
#X obj 15 218 s \$0.bag.i1;
#X text 139 217 put result back to bag;
#X obj 38 94 r \$0.bag.o0;
#X connect 0 0 1 0;
#X connect 1 0 3 0;
#X connect 1 1 2 0;
#X connect 1 2 5 1;
#X connect 3 0 5 0;
#X connect 5 0 7 0;
#X connect 9 0 3 1;
#X restore 198 157 pd add_notes;
#N canvas 582 70 366 593 remove_notes 0;
#X obj 12 69 t b b a;
#X obj 12 135 list;
#X obj 46 233 until;
#X obj 46 258 list append;
#X obj 159 252 bang;
#X obj 62 438 list prepend;
#X obj 170 442 t a;
#X obj 12 507 list;
#X obj 12 183 t b a;
#X obj 46 208 t b a b;
#X obj 12 35 inlet;
#X obj 34 92 s \$0.bag.i0;
#X obj 34 112 r \$0.bag.o0;
#X obj 46 281 list split 1;
#X obj 46 337 sel;
#X text 27 6 this is a bit more complicated....;
#X text 153 103 get content of bag;
#X text 149 153 __________;
#X text 148 309 __________;
#X text 150 388 __________;
#X text 147 475 __________;
#X obj 12 533 s \$0.bag.i1;
#X text 179 209 serialize content;
#X text 185 350 filter out note;
#X text 209 443 back to list again;
#X text 151 526 put result back to bag;
#X connect 0 0 1 0;
#X connect 0 1 11 0;
#X connect 0 2 14 1;
#X connect 1 0 8 0;
#X connect 2 0 3 0;
#X connect 3 0 13 0;
#X connect 4 0 2 1;
#X connect 5 0 6 0;
#X connect 5 0 7 1;
#X connect 6 0 5 1;
#X connect 7 0 21 0;
#X connect 8 0 7 0;
#X connect 8 1 9 0;
#X connect 9 0 2 0;
#X connect 9 1 3 1;
#X connect 9 2 5 1;
#X connect 9 2 7 1;
#X connect 10 0 0 0;
#X connect 12 0 1 1;
#X connect 13 0 14 0;
#X connect 13 1 3 1;
#X connect 13 2 4 0;
#X connect 14 1 5 0;
#X restore 154 181 pd remove_notes;
#X obj 8 115 s \$0.bag.o0;
#X obj 49 372 s \$0.bag.i0;
#X obj 48 392 r \$0.bag.o0;
#X obj 25 414 list;
#X obj 25 348 t b b;
#X obj 25 326 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 48 325 <- print content of bag;
#X obj 264 329 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 294 327 panic: erase bag content;
#X obj 264 352 s \$0.bag.i1;
#X text 21 296 _________________________________________________________
;
#N canvas 700 221 395 373 get_notes 0;
#X obj 43 78 s \$0.bag.i0;
#X obj 43 98 r \$0.bag.o0;
#X obj 20 26 inlet;
#X obj 20 121 list;
#X obj 20 54 t b b a;
#X obj 20 165 t a a;
#X text 142 88 get bag content;
#X text 125 137 ______________;
#X obj 75 234 mod;
#X obj 91 212 list length;
#X text 130 317 ______________;
#X obj 20 261 list split;
#X obj 20 294 list split 1;
#X obj 20 347 outlet;
#X text 135 178 getting a certain note from list;
#X connect 1 0 3 1;
#X connect 2 0 4 0;
#X connect 3 0 5 0;
#X connect 4 0 3 0;
#X connect 4 1 0 0;
#X connect 4 2 8 0;
#X connect 5 0 11 0;
#X connect 5 1 9 0;
#X connect 8 0 11 1;
#X connect 9 0 8 1;
#X connect 11 1 12 0;
#X connect 12 0 13 0;
#X restore 377 157 pd get_notes;
#X obj 154 45 notein;
#X obj 154 68 pack f f;
#X msg 154 90 \$2 \$1;
#X obj 154 113 route 0;
#X text 9 12 bag:;
#X msg 198 134 \$2;
#X obj 25 436 print BAGCONTENT;
#X obj 377 94 f;
#X obj 419 98 + 1;
#X obj 377 121 mod 1000;
#X text 140 14 store and remove notes:;
#X text 376 17 play them:;
#X obj 377 45 loadbang;
#N canvas 535 301 268 378 synth 0;
#X obj 19 22 inlet;
#X obj 19 51 unpack;
#X obj 56 119 / 127;
#X msg 56 141 \$1 20 \, 0 100 20;
#X obj 56 165 vline~;
#X obj 19 157 osc~;
#X obj 18 196 *~;
#X obj 18 232 dac~;
#X obj 19 125 mtof;
#X obj 19 73 stripnote;
#X connect 0 0 1 0;
#X connect 1 0 9 0;
#X connect 1 1 9 1;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 4 0 6 1;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 6 0 7 1;
#X connect 8 0 5 0;
#X connect 9 0 8 0;
#X connect 9 1 2 0;
#X restore 377 255 pd synth;
#X obj 377 226 pack;
#X obj 377 203 makenote 80 1;
#X obj 377 69 metro 100;
#X connect 0 0 5 0;
#X connect 1 0 0 0;
#X connect 2 0 0 1;
#X connect 7 0 8 1;
#X connect 8 0 23 0;
#X connect 9 0 8 0;
#X connect 9 1 6 0;
#X connect 10 0 9 0;
#X connect 12 0 14 0;
#X connect 16 0 32 0;
#X connect 17 0 18 0;
#X connect 17 1 18 1;
#X connect 18 0 19 0;
#X connect 19 0 20 0;
#X connect 20 0 4 0;
#X connect 20 1 22 0;
#X connect 22 0 3 0;
#X connect 24 0 26 0;
#X connect 25 0 24 1;
#X connect 26 0 25 0;
#X connect 26 0 16 0;
#X connect 29 0 33 0;
#X connect 31 0 30 0;
#X connect 32 0 31 0;
#X connect 32 1 31 1;
#X connect 33 0 24 0;


More information about the Pd-list mailing list