// title: how to use the SynthDef's default argument in an Event? // author: julian.rohrhuber // description: // One answer to the question "how to use the SynthDef's default argument in an Event?" // code: // This question comes up sometimes. // one way to do it is to define an event type: ( Event.addEventType(\dnote, { |server| var instrument = ~instrument.asDefName; var synthLib = ~synthLib ?? { SynthDescLib.global }; var desc = synthLib.at(instrument); if (desc.notNil) { desc.controls.do { |x| x.defaultValue !? { x.name.asSymbol.envirPut(x.defaultValue) } }; // for efficiency, get this now ~hasGate = desc.hasGate; ~msgFunc = desc.msgFunc; }; ~type = \note; currentEnvironment.play; }); ) ( SynthDef(\test, { |out, freq = 1000| Out.ar(out, Line.ar(0.1, 0, 0.1, doneAction:2) * SinOsc.ar(freq)) }).add ) Pbind(\type, \dnote, \instrument, \test, \dur, 0.3).play;