This page was generated from examples/supercollider-objects/bus-examples.ipynb.
Bus
[ ]:
import sc3nb as scn
[ ]:
sc = scn.startup()
Using a Control Bus
[ ]:
bus = scn.Bus('control')
bus
[ ]:
bus.get()
[ ]:
syn = scn.Synth("s2")
map the frequency of the synth to the bus value
[ ]:
syn.map("freq", bus)
[ ]:
bus.set(120) # changes synths frequency
[ ]:
bus.set(440)
Set the frequency value to remove the mapping
[ ]:
syn.set("freq", 220)
[ ]:
bus.set(440) # no change
[ ]:
syn.free()
Free the bus to mark the bus id as available again
[ ]:
bus.free()
Use multiple Control Buses
[ ]:
synth_name = scn.SynthDef("busMulti", """{ |out, freqs=#[200, 400], rates=#[1, 2] |
Out.ar(out, Splay.ar(SinOsc.ar(freqs) * Decay2.ar(Impulse.ar(rates), 0.001, 0.1)) * 0.5);
}""").add()
[ ]:
buses = scn.Bus("control", 2)
buses
[ ]:
buses.get()
[ ]:
syn = scn.Synth(synth_name)
[ ]:
syn.map("rates", buses)
[ ]:
buses.set(1, 1)
[ ]:
buses.set(1, 2)
[ ]:
buses.get()
[ ]:
syn.free()
[ ]:
buses.free()
[ ]:
sc.server.free_all()
[ ]:
sc.exit()
[ ]: