hi all,
i'm trying to make a patch that includes as a creation argument, a file to be loaded into playsf~ (but my question is valid for a symbol argument for anything i think). in addition, i also want a default file loaded if no creation argument is supplied. i've included a patch that accomplishes everything i need. what i'm wondering is if there is a more elegand solution. as i'm getting more fluent with pd, i'm trying to learn the best practices i can.
note that this uses [init] from iem, but i think this is fairly commonly distributed with pd these days? thanks for any ideas.
matt
#N canvas 142 91 399 364 10; #X msg 171 204 set open $1; #X msg 170 227 open stevie.aif; #X obj 207 56 ii stevie.aif; #X msg 207 102 set $1; #X msg 155 142 stevie.aif; #X obj 77 19 ii $1; #X obj 77 40 route 0; #X obj 207 78 pack s; #X msg 151 111 set $1; #X obj 121 62 t b a; #X obj 151 87 pack s; #X obj 171 178 pack s; #X obj 106 275 readsf~ 2; #X connect 0 0 1 0; #X connect 1 0 12 0; #X connect 2 0 7 0; #X connect 3 0 4 0; #X connect 4 0 11 0; #X connect 5 0 6 0; #X connect 6 0 4 0; #X connect 6 1 9 0; #X connect 7 0 3 0; #X connect 8 0 4 0; #X connect 9 0 4 0; #X connect 9 1 10 0; #X connect 10 0 8 0; #X connect 11 0 0 0;
matthew shanley wrote:
hi all,
i'm trying to make a patch that includes as a creation argument, a file to be loaded into playsf~ (but my question is valid for a symbol argument for anything i think). in addition, i also want a default file loaded if no creation argument is supplied. i've included a patch that accomplishes everything i need. what i'm wondering is if there is a more elegand solution. as i'm getting more fluent with pd, i'm trying to learn the best practices i can.
the problem with your patch is, that it is dependent on the execution order of the 2 [init] objects. you shouldn't have 2 competing [loadbang]s ([init] is just a special case of [loadbang]) in one patch. it breaks your patch if you re-instantiate the [ii stevie.aif] - you will load stevie.aif no matter what you type into your object.
rather use [trigger] to schedule it. the attached derivation of your patch fixes this (and is only about half of the size)
mfg.asd.r IOhannes
#N canvas 68 83 251 293 10; #X msg 82 157 set open $1; #X obj 82 60 route 0; #X obj 82 256 readsf~ 2; #X obj 82 39 ii $1; #X obj 82 115 symbol stevie.aif; #X obj 82 83 t b; #X obj 82 189 t b a; #X msg 82 225; #X connect 0 0 6 0; #X connect 1 0 5 0; #X connect 1 1 4 0; #X connect 3 0 1 0; #X connect 4 0 0 0; #X connect 5 0 4 0; #X connect 6 0 7 0; #X connect 6 1 7 0; #X connect 7 0 2 0;
Hallo, IOhannes m zmoelnig hat gesagt: // IOhannes m zmoelnig wrote:
rather use [trigger] to schedule it. the attached derivation of your patch fixes this (and is only about half of the size)
You even can get rid of the last trigger as well, because it's redundant. See attached patch (using print instead of readany~ for clarity).
Frank Barknecht _ ______footils.org__