1class:: Monitor 2summary:: link between busses 3categories:: JITLib>NodeProxy, Live Coding 4related:: Reference/playN, Classes/NodeProxy, Classes/Bus 5 6description:: 7A general purpose class for monitoring or crosslinking between busses. It supports multichannel expansion and crossfading between settings. It provides optimizations for playing contiguous channels to other contiguous busses (link::#-play::) and for more complex routings, such as splitting, spreading etc to multiple channels (link::#-playN::). Monitor uses the existing set of link::Classes/SystemSynthDefs:: to do this. 8 9code:: 10{ Out.ar(87, SinOsc.ar(MouseX.kr(240, 1000, 1) * [1, 2, 3], 0, 0.2)) }.play; // play three sine tone on channels 87, 88, and 89 11x = Monitor.new; // create a new monitor 12x.play(fromIndex: 87, fromNumChannels: 3, toIndex:0, toNumChannels:2); // play them back to the stereo hardware channels 13:: 14 15ClassMethods:: 16 17private::warnPlayN 18 19 20InstanceMethods:: 21 22method::play 23Plays from a bus index with a number of channels to another index with a number of channels, within a target group, or a server. 24 25argument::fromIndex 26bus index from which to read 27 28argument::fromNumChannels 29number of channels to read from. 30 31argument::toIndex 32bus index to which to write. 33 34argument::toNumChannels 35number of channels to write. If this number is larger or smaller than fromNumChannels, wrap around. If nothing is given, uses fromNumChannels. 36 37argument::target 38where to send the synths to (default: server default group) 39 40argument::multi 41keep old links and add new one: this allows you to add layer after layer, otherwise free ther previous mapping (false by default). 42 43argument::volume 44volume at which to monitor 45 46argument::fadeTime 47specifies the fade in and fade out time 48 49argument::addAction 50where, relative to the target to place the monitor group. 51 52code:: 53s.boot; 54s.scope(16); 55 56{ Out.ar(87, SinOsc.ar(MouseX.kr(40, 10000, 1) * [1, 2, 3], 0, 0.2)) }.play; 57x = Monitor.new; 58x.play(87, 3, 1, 2); 59x.out = 0; 60x.stop(3.0); 61x.play(87, 1, 0, 1); // in > out : now mixes down (wrapping) 62x.play(89, 1, 0, 2); // in < out : now distributes to 2 channels 63x.stop; 64 65// multiple play 66x.play(87, 1, 0, 2, multi:true); 67x.play(88, 1, 0, 2, multi:true); 68x.play(89, 1, 0, 2, multi:true); 69x.stop; 70:: 71 72 73 74method::playN 75Plays from an array of bus indices to another array of bus indices with an array of amplitudes, within a target group, or a server. 76 77note:: 78The arguments strong::out::, strong::amp:: and strong::in:: can be nested arrays. see also link::Reference/playN:: 79 80The three arguments out, amp, and in will wrap if they do not have the same size, like this: 81code:: [[0, 1], [0.1], [3, 4, 5]].flop :: 82:: 83 84argument::out 85array of destination channels. 86 87argument::amp 88array of amplitudes for each channel 89 90argument::in 91array of source channels 92 93argument::vol 94global scaling value for amplitudes 95 96argument::fadeTime 97specifies the fade in and fade out time 98 99argument::target 100where to play (default: server default group) 101 102argument::addAction 103where, relative to the target to place the monitor group. 104 105argument::multi 106keep old links and add new one: this allows you to add layer after layer, otherwise free ther previous mapping (false by default). 107 108code:: 109// examples: args are // outs, amps, ins, vol, fadeTime 110 111{ Out.ar(87, SinOsc.ar(MouseX.kr(40, 10000, 1) * [1, 2, 3], 0, 0.2)) }.play; 112x = Monitor.new; 113 114( 115x.playN( 116 [0, 1, 4], // to these outs 117 [0.1, 0.4, 0.3], // with these volumes 118 [87, 88, 89] // from these ins 119); 120) 121( 122x.playN( 123 [0, [1, 3, 2], 4], // outs can be nested: 87 -> 0, 88 -> [1, 3, 2], 89 -> 4 124 [0.1, [0.4, 0.2, 0.1], 0.3], // with nested volumes 0.1, [0.4, 0.2, 0.1], and 0.3 125 [87, 88, 89]); // reading from these ins 126) 127// can also set global volume and fadetime 128x.playN(vol: 0.0, fadeTime:4); 129:: 130 131 132method::stop 133Stops within the fadeTime. 134note::this keeps all the settings, so when using code::play:: next time, it will play in the same configuration, overriding only values provided.:: 135code:: 136{ Out.ar(87, SinOsc.ar(MouseX.kr(340, 1000, 1) * [1, 2, 3], 0, 0.2)) }.play; 137x = Monitor.new.play(87, 3, 0, fadeTime: 3); 138x.stop; 139x.play; 140:: 141 142argument::argFadeTime 143The time for fading out all routing synths. 144 145method::clear 146Stops within the fadeTime. 147note::unlike code::stop::, this removes all the settings.:: 148 149 150method::vol 151Set the volume. 152code:: 153{ Out.ar(87, SinOsc.ar(MouseX.kr(340, 1000, 1) * [1, 2, 3], 0, 0.2)) }.play; 154x = Monitor.new.play(87, 3, 0, fadeTime: 3); 155x.vol = 0.3; 156x.stop; 157:: 158 159 160method::out 161Set or get the first output index. 162 163method::outs 164Set or get the array of output bus indices. 165 166method::ins 167Set or get the array of input bus indices. 168 169method::amps 170Set the array of amplitudes. 171 172method::fadeTimes 173Set or get the array of fadeTimes. 174 175method::fadeTime 176Set one single fadeTime for the next transition (may be a stop or a new play). 177 178method::isPlaying 179Returns true if the group is still playing. 180 181method::group 182Return the group in which all mapping synths are running. 183 184method::numChannels 185Return the number of input channels. 186 187method::copy 188Return a copy of the receiver, with the same channel setting, but not running. You can run it with the settings by sending it the link::#-play:: message, and pass in any modifications you want to make. 189 190 191method::playToBundle 192Adds all playing osc messages to a bundle, passed as an argument. The bundle object should implement the method strong::.add:: 193 194private::hasSeriesOuts, newGroupToBundle, playNBusToBundle, playNToBundle, stopToBundle, updateDefault, usedPlayN 195