From dc662a180174f1bf560fd46a1746d55098f17af6 Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 1 Jan 2021 21:36:58 +0100 Subject: Guard setSynchronous classes/ZZZDevice.sc: Guard all .setSynchronous calls with a check for server.hasShmInterface. Set the default input amplitude of the gate to 1.0. Add all heuristics at the top of addTempo. --- classes/ZZZDevice.sc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'classes') diff --git a/classes/ZZZDevice.sc b/classes/ZZZDevice.sc index b10a6b0..60206ed 100644 --- a/classes/ZZZDevice.sc +++ b/classes/ZZZDevice.sc @@ -61,15 +61,18 @@ ZZZDevice : ZZZ{ if(tempo < 0.0, { ZZZError("ZZZDevice: The provided tempo is not valid (needs to be >= 0.0).").throw; }); + if(tempos.at(slot).notNil, { + ZZZError("ZZZDevice: Cannot add tempo "++ tempo ++" in slot "++ slot ++". There is a TempoBusClock already.").throw; + }); - if(tempos.at(slot).isNil, { - ("Create new TempoBusClock in slot "++ slot++" with tempo "++tempo).postln; - tempoBusses.add(slot -> Bus.control()); + ("Create new TempoBusClock in slot "++ slot++" with tempo "++tempo).postln; + tempoBusses.add(slot -> Bus.control()); + if(super.server.hasShmInterface,{ tempoBusses.at(slot).setSynchronous(tempo); - tempos.add(slot -> TempoBusClock.new(control: tempoBusses.at(slot))); },{ - ZZZError("ZZZDevice: Cannot add tempo "++ tempo ++" in slot "++ slot ++". There is a TempoBusClock already.").throw; + tempoBusses.at(slot).set(tempo); }); + tempos.add(slot -> TempoBusClock.new(control: tempoBusses.at(slot))); } removeTempo{|slot, playType = \beat, quant = 1| @@ -112,7 +115,11 @@ ZZZDevice : ZZZ{ ZZZError("ZZZDevice: Cannot set tempo "++ tempo ++" at slot "++ slot ++". There is no TempoBusClock.").throw; }); - tempoBusses.at(slot).setSynchronous(tempo); + if(super.server.hasShmInterface,{ + tempoBusses.at(slot).setSynchronous(tempo); + },{ + tempoBusses.at(slot).set(tempo); + }); } addClock{ |output, slot, type = \zeroFive, playType = \beat, quant = 1, replace = false| @@ -213,7 +220,7 @@ ZZZDevice : ZZZ{ this.addClock(output: output, slot: slot, playType: playType, quant: quant, replace: true, type: type); } - addGate{ |output, input = 0.9| + addGate{ |output, input = 1.0| if(output.isNil || output.isInteger.not, { ZZZError("ZZZDevice: The provided output number is not valid (needs to be >= 1).").throw; }); @@ -231,7 +238,12 @@ ZZZDevice : ZZZ{ }); gateBusses.add(output -> Bus.control()); - gateBusses.at(output).setSynchronous(input); + + if(super.server.hasShmInterface,{ + gateBusses.at(output).setSynchronous(input); + },{ + gateBusses.at(output).set(input); + }); gates.add( output -> Synth(\ZZZGate, [\out, this.outputOnHardware(output: output), \bus, gateBusses.at(output)]).onFree({ gateBusses.removeAt(output); -- cgit v1.2.3-70-g09d2