114 lines
2 KiB
Text
114 lines
2 KiB
Text
|
class:: NodeMap
|
||
|
summary:: store control values and bus mappings
|
||
|
categories:: Libraries>JITLib>NodeProxy, Server>Nodes, Server>Abstractions
|
||
|
related:: Classes/Bus
|
||
|
|
||
|
description::
|
||
|
Object to store control values and bus mappings independently of a specific node.
|
||
|
|
||
|
code::
|
||
|
a = NodeMap.new;
|
||
|
a.set(\freq, [446, 662], \amp, 0.2, \out, Bus.audio(s));
|
||
|
a.asOSCArgArray;
|
||
|
::
|
||
|
|
||
|
InstanceMethods::
|
||
|
|
||
|
method::set
|
||
|
set arguments of a node
|
||
|
|
||
|
method::unset
|
||
|
remove settings
|
||
|
|
||
|
method::unmap
|
||
|
remove mappings
|
||
|
|
||
|
method::at
|
||
|
return setting at that key.
|
||
|
|
||
|
method::sendToNode
|
||
|
apply a setting to a node by sending a bundle
|
||
|
|
||
|
method::send
|
||
|
apply a setting to a node by sending a bundle
|
||
|
|
||
|
method::addToBundle
|
||
|
add all my messages to the bundle
|
||
|
|
||
|
method::addToEvent
|
||
|
add all my values to the event
|
||
|
|
||
|
method::asOSCArgArray
|
||
|
returns the arguments for an OSC message.
|
||
|
|
||
|
method::unmapArgsToBundle
|
||
|
returns the arguments for an OSC message to unmap any mapped controls.
|
||
|
|
||
|
method::setMsg
|
||
|
returns the OSC message for setting a synth
|
||
|
argument:: target
|
||
|
a group, synth, or server to use as a nodeID to set.
|
||
|
|
||
|
method::setn, map, mapn
|
||
|
These are kept for backward compatibility. They redirect to link::#-set::.
|
||
|
|
||
|
method::get
|
||
|
Kept for backward compatibility.
|
||
|
|
||
|
method::clear
|
||
|
Remove all settings and clear cache
|
||
|
|
||
|
|
||
|
private::updateArgs, upToDate
|
||
|
|
||
|
Examples::
|
||
|
|
||
|
code::
|
||
|
|
||
|
s.boot;
|
||
|
|
||
|
(
|
||
|
SynthDef("modsine",
|
||
|
{ arg freq=320, amp=0.2;
|
||
|
Out.ar(0, SinOsc.ar(freq, 0, amp));
|
||
|
}).add;
|
||
|
SynthDef("lfo",
|
||
|
{ arg rate=2, busNum=0;
|
||
|
Out.kr(busNum, LFPulse.kr(rate, 0, 0.1, 0.2))
|
||
|
}).add;
|
||
|
)
|
||
|
|
||
|
//start nodes
|
||
|
(
|
||
|
b = Bus.control(s,1);
|
||
|
x = Synth("modsine");
|
||
|
y = Synth.before(x, "lfo", [\busNum, b]);
|
||
|
)
|
||
|
|
||
|
//create some node maps
|
||
|
(
|
||
|
h = NodeMap.new;
|
||
|
h.set(\freq, 800);
|
||
|
h.map(\amp, b);
|
||
|
|
||
|
k = NodeMap.new;
|
||
|
k.set(\freq, 400);
|
||
|
k.unmap(\amp);
|
||
|
)
|
||
|
|
||
|
//apply the maps
|
||
|
|
||
|
h.sendToNode(x); //the first time a new bundle is made
|
||
|
k.sendToNode(x);
|
||
|
|
||
|
h.sendToNode(x); //the second time the cache is used
|
||
|
k.sendToNode(x);
|
||
|
|
||
|
h.set(\freq, 600);
|
||
|
|
||
|
h.sendToNode(x); //when a value was changed, a new bundle is made
|
||
|
|
||
|
//free all
|
||
|
x.free; b.free; y.free;
|
||
|
::
|