1 title:: Bundled Server Messages
2 summary:: Sending OSC message bundles
3 categories:: External Control>OSC, Server>Architecture
4 related:: Guides/ServerTiming
6 When using the Synth/Node/Group sclang objects there is often a need to construct bundles to send messages together. For example when you want to start a synth that should be mapped instantly to certain buses, or need to ensure that two synths start with precise synchronisation.
8 The simplest way to deal with this is through Server's automated bundling support. This allows you to open a bundle into which all osc messages will be collected until it is sent. See Server for details of makeBundle's arguments.
12 // send a synth def to server
13 SynthDef("tpulse", { arg out=0,freq=700,sawFreq=440.0;
14 Out.ar(out, SyncSaw.ar(freq, sawFreq,0.1) )
18 // all OSC commands generated in the function contained below will be added to a bundle
19 // and executed simultaneously after 2 seconds.
22 x = Synth.new("tpulse");
23 a = Bus.control.set(440);
31 b = s.makeBundle(false, {
32 x = { PinkNoise.ar(0.1) * In.kr(0, 1); }.play;
35 // now pass b as a pre-existing bundle, and start both synths synchronously
37 s.makeBundle(nil, { // nil executes ASAP
38 y = { SinOsc.kr(0.2).abs }.play(x, 0, 0, \addBefore); // sine envelope
44 To send a bundle with the default latency of the server, use the message bind:
48 SynthDef("tpulse2", { arg out=0, freq=700, sawFreq=440.0;
49 Out.ar(out, Pan2.ar(SyncSaw.ar(freq, sawFreq, 0.1), SinOsc.kr(8)) )
51 s.sync; // wait until synthdef is loaded
52 x = Synth.new("tpulse2");
53 a = Bus.control.set(440);
61 In addition to this there are a number of methods which return OSC messages which can be added to a bundle. These are detailed in the helpfiles for link::Classes/Node::, link::Classes/Synth::, and link::Classes/Group::.
65 c = Bus.control(s, 1).set(660);
66 x = Synth.basicNew("default", s); // Create without sending
68 b.add(x.mapMsg(\freq, c));
69 b.postln; // here's what it looks like
70 s.listSendBundle(1.0, b); // Execute after 1 second