VC(\symbol) -- VoiCer -- automatic creation
A placeholder for a voicer.
A Voicer object by itself does not have any room to store resources that it depends on. But, as noted in the Fact help file, the factory can create those supporting resources and keep them together with the voicer proper in a VC. The VC keeps track of supporting resources by retaining a copy of the Factory's environment in the instance variable env.
The chuck operation Fact => VC does the following:
1. Make a copy of the factory environment.
2. Enter the environment (.use) and run the Factory's make function. Any resources that this function creates and assigns into environment variables are stored in the copy of the environment.
3. Save the fully populated environment copy in the VC.
The voicer object is accessible through the value variable. Supporting objects are available through the environment, env.
See help for Fact for an example of passing parameters into the factory at chuck time.
(keys: [\master], make: {
// master is used as the target mixer's output
~target = MixerChannel("ghostly", s, 1, 2, level:0.1, outbus: ~master);
Instr("analog.ghostly", { arg freq, gate, freqlag, attacktime, decaytime, env, vsense, mul;
var amp;
amp = Sensitivity.kr(1, Latch.kr(gate, gate), vsense);
Mix.ar(Formlet.ar(PinkNoise.ar([0.2, 0.2]), freq*2, attacktime, decaytime, mul))
* EnvGen.kr(env, gate, doneAction:2, levelScale:amp*2.5)
}, [\freq, [0, 1], [0, 2], [0.001, 2, \exponential], [0.001, 2, \exponential],
EnvSpec(Env.adsr(0.01, 1, 0.75, 0.1)), [0, 1], [0, 1]]);
Voicer(10, Instr("analog.ghostly"), [\attacktime, `0.002, \decaytime, `0.9186, \vsense, `0.787, \mul, `0.535], target:~target).latency_(0.5)
},
free: {
~target.free
}, type: \voicer) => Fact(\ghost);
Fact(\ghost) => VC(\ghost); // creates the voicer and its mixerchannel
VC(\ghost).value;
VC(\ghost).v; // short form of .value
VC(\ghost).env.target; // returns target MixerChannel
VC(\ghost).free; // frees Voicer and MixerChannel together