MM – Multichannel expansion inside a SynthDef

This will show how you can multiply oscillators with slight variations using multichannel expansions and also use Splay to play them in 2 channel.

// MM Multichannel expansion inside a SynthDef.
//This is useful to create "unison" synths with a slight pitch deviation, as well as meandering pitches. This technique can be used for other parameters, not just pitch, but for now we'll use only pitch.

//My interface options. Change at will.

(
Server.local.options.device = "ASIO : ASIO PreSonus FireStudio";
Server.local.options.sampleRate=48000;
Server.local.options.hardwareBufferSize=128;
Server.local.options.numOutputBusChannels=8;//This in order to crate and see 8 channels to see what happens in the meters. Not really needed.
s.meter
)

//Compare this. 
// It will only create one instance of the synth each time you evaluate.

(
SynthDef(\tri, {
	|gate=1, amp=0.2, freq=200, panpos=0, envdur=4|
	var sig;
	sig=LFTri.ar(freq+Rand(1,100));
	sig=sig*EnvGen.ar(Env([0,amp,0],[0.001,envdur],-4),gate,doneAction:2);
	Out.ar(0, sig!2);
}).add;
)

//Test your synth.
Synth(\tri, [\panpos, 0])

//To this.
//It will create 8 instances (or as many as you want) each time you evaluate. Note the key elements that make this possible in the comments below.
(
SynthDef(\tri, {
	|gate=1, amp=0.3, freq=200, panpos=0, envdur=4|
	var sig;
	sig=LFTri.ar({freq+Rand(1,100)}!8); //Here the oscillator has been expanded (multiplied) 8 times.
	sig=sig*EnvGen.ar(Env([0,amp,0],[0.001,envdur],-4),gate,doneAction:2);
	sig=Splay.ar(sig,center:panpos);//Splay joins all expansions and spreads them into a stereo signal. Also serves as panner. Comment this out and watch the meters.
	Out.ar(0, sig);
}).add;
)

//Test your synth.
Synth(\tri, [\panpos, 0])
Author
418 PM
  • Platform:
  • Category: Utility
  • Revision: 1.0
  • License: GNU General Public License family
  • Views: 109
  • Modified: 5 months ago
Chat about this patch on Discord!
Appreciate

Leave a Reply