How to modulate a control bus with multiple signals?


Let`s say I have a SynthDef named exampleSynth, which has the arguments freq and freqAdd.
		arg freq=440, freqAdd=0;
		var sig, freqModded;
		freqModded = freq + freqAdd );
		sig = freqModded );
		sig = sig *; [ 0, 1 ], sig );

Now this SynthDef is played by a Pbind and freqAdd is controlled by a Control Bus named freqAddBus

~freqAddBus = Bus.control;

	\instrument,  	\example_synth,
	\degree,      	Pseq([1,3,1,5], inf),
	\freqAdd, 	    ~freqAddBus.index

I want to have multiple signals affecting the value of the freqAddBus.

Let`s say I have a signal on bus ~b1, another one on bus ~b2, a value ~gui1 that is set by a GUI-slider and a value ~midi1, that is set by a MIDIFunc.
After every control rate cycle the value of the ~freqAddBus should be ( ( ~b1 + ~b2 ) * ~gui1 ) - ~midi1

My question is:
How do I set the value of the ~freqAddBus for each control rate cycle?

My idea was to have a list of all the modulations that should happen to the bus. For this example it would look like this:

  1. Add ~b1
  2. Add ~b2
  3. Mul ~gui1
  4. Subtract ~midi1

And then have a Routine that runs a function every control cycle, which first gets the value of the ~freqAddBus, then performs all the calculations in the list on this value and in the end, sets the value of the bus to the result of the calculation.

Is this the right way to do it?
Is a Routine the right class to perform calculations every control cycle?

All the best and thank you,

Do it in the server with a Synth node for only that purpose.

“Every control cycle” is really the server’s job – I’d strongly advise against trying to do this in the language.


1 Like

Thank you for your answer!