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;