Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////// NodeProxy //////////////////////
- // The following code may be suitable for live coding.
- // NodeProxy is a reference on a server. A proxy is a placeholder for something. A node proxy is a placeholder for something playing on a server. That something is typically a synth or an event stream that creates synths.
- // NodeProxy objects can be replaced, revised, and recombined while they play.
- // These objects can be used to build a larger structure and can be modified later on.
- // NodeProxy is used within ProxySpace. NodeProxy is a superclass of Ndef.
- // Important: NodeProxy plays on a private bus. For audible output, use the play and stop methods.
- // To free inner players, use the end method. To remove all inner settings, use the clear method.
- // The following example is based on the Help page.
- s.boot;
- s.plotTree; // I recommend refering to this, so you can see the Server's internal dialogue.
- s.meter; // A good reference for audio output and, more importantly, volume.
- s.scope; // I personally like to keep this visible.
- s.quit;
- a = NodeProxy.new.play; // Play to hardware output.
- a.fadeTime = 2; // FadeTime specifies crossfade. This line evaluates a crossfade of 2 seconds.
- // Set the source.
- a.source = {SinOsc.ar([350, 351.3], 0, 0.1)};
- a.source = {Pulse.ar([350, 351.3] / 4, 0.4) * 0.05};
- a.source = Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350));
- b = NodeProxy.new;
- a.source = {Ringz.ar(b.ar, [220, 221.5] * 8, 0.1) * 4};
- // When you evaluate this, after evaluating the new value name, "b", the a.source (in this case, the Ringz UGen, fades the previous sound by 2 seconds. Once you evaluable the b.source below, you have Ringz under an Impulse control.
- b.source = {Impulse.ar([5, 7]/2, [0, 0.5], 0.05)}; // Keep this at a very low amplitude!
- a.clear(3); // clear after 3 seconds
- b.clear(3); // this too clears after 3 seconds
- ////////////// The following code is based on Eli Fieldsteel's tutorial, Live Coding, Part 1. //////////////
- n = NodeProxy.new;
- n.isPlaying; // The result is false until we evaluate the play method.
- n.play; // The top Group is the reference of the source. The bottom Group is the Server's audio output.
- n.clear; // This is effectively a hard stop. It clears everything. Evaluate the play method, for when you want audio output.
- // Let's put in a source, which is designated for the top Group.
- n.source; // Result is "nil," if you've previously cleared the source.
- n.play;
- n.source = {PinkNoise.ar(0.1!2)}; // The current audio source is pink noise.
- n.source = {SinOsc.ar([220, 222], mul: 0.1) * LFPulse.kr([4, 5])}; // Instantly change the audio source.
- // It's up to you, if you prefer to write out consecutive sources and run them one at a time.
- // For live coding, I generally see people change the source in the same line of code.
- n.clear(4); // The clear method includes a fadeTime value. Here, it's a fade time of 4 seconds.
- n.play;
- n.source = {PinkNoise.ar(0.1!2) * LFTri.kr(4)};
- n.stop; // Not the most elegant way of releasing the synth. But you have this as an option.
- n.play;
- n.clear(4); // This has a release time of 4 seconds.
- // fadeTime
- n.play;
- n.source_({LPF.ar(Saw.ar([80, 82], mul: 0.05), 1000)});
- n.fadeTime; // Default fade time is 0.02 seconds.
- n.fadeTime_(3); // This acts as a crossfade between sources (that you change in real time).
- n.fadeTime; // See the result now in the Post Window.
- // For example, change the different paramters of the source below. Like the Saw's frequency values, or the Lowpass filter's cutoff value.
- n.source_({LPF.ar(Saw.ar([80, 81], mul: 0.05), 2000)});
- n.clear(8); // Clear the source with a release time of 8 seconds.
- // Just for musicality, let's use the midiratio method to change the Sawtooth wave in semitones.
- n.play;
- n.source_({LPF.ar(Saw.ar([80, 81] * 0.midiratio, mul: 0.05), 2000)});
- n.fadeTime_(2); // Note, this isn't the same as the clear method; it's a crossfade between sources playing.
- n.clear(2);
- // If you don't want to clear a source, but want to momentarily silence it, the following code works:
- n.source_({LPF.ar(Saw.ar([80, 81] * -5.midiratio, mul: 0.05), 1200)});
- n.play;
- n.source_({ });
- n.clear(1);
- // Think of the play and stop methods as a hard on and off switch.
- n.play;
- n.stop; // You'll see the Server removes the Group designated for audio output.
- // Evaluating "n.play" again with return to the last source value and play it. We also have the following.
- n.monitor.fadeTime_(5); // Think of this as a fade in and out feature. Go between stop and play.
- // This monitor method dictates the audio output Group (bottom Group).
- n.source_({LPF.ar(Saw.ar([80, 81] * -5.midiratio, mul: 0.05), 1200)});
- n.stop;
- n.play; // Evaluating this will instantaneously provide the audio output Group.
- // Note the difference between this and the NodeProxy's fade time.
- n.fadeTime_(5);
- n.release;
- n.send; // This reinstantiates the source object (in the top Group).
- // And "send" will return a random value within the Group. Let's try this with random semitones using the midiratio values method.
- n.source_({LPF.ar(Saw.ar([80, 81] * Rand(-5.0, 5.0).midiratio, mul: 0.05), 1200)});
- n.send; // Send can also reevaluate itself; You don't need to release it.
- n.release; // The realease time is whatever the fadeTime value is.
- // Make changes using the pause and resume methods. That is, if you don't want to hear the output as you make changes.
- n.pause;
- n.resume;
- n.stop;
- // Run more than one instance of NodeProxy.
- m = NodeProxy.new; // Note the new global variable letter.
- m.fadeTime_(8);
- m.play;
- m.source_({ Dust.ar(8!2, mul: 0.3) });
- m.source_({ Impulse.ar([8, 10], mul: 0.3) * SinOsc.kr(0.2, 3pi/2).exprange(0.25, 1)});
- m.clear(4);
- // To clear both NodeProxy instances, you can...
- (
- m.clear;
- n.clear;
- )
- // But what if you accidentally designate two sources to the same variable name (e.g. global variable, n)?
- // Answer: The most recent instance overwrites the first one.
- // Ndef is a more elegant way to do this.
- Ndef(\n).play;
- Ndef(\n).fadeTime_(2);
- Ndef(\n, { Dust.ar(8!2, mul: 0.3) }); // Now, you don't need to use the source method.
- Ndef(\n).release;
Add Comment
Please, Sign In to add comment