«Detuneable fat-saw with a pattern» by moncrey

on 14 Dec'13 17:47 in patternsynth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(
SynthDef(\fatsaw,
	{
		arg freq=440, amp=0.3, fat=0.0033, ffreq=2000, atk=0.001, dec=0.3, sus=0.5, rls=0.1,gate=1;

		var f1,f2,f3,f4,synth;

		f1=freq-(freq*fat);
		f2=freq-(freq*fat/2);
		f3=freq+(freq*fat/2);
		f4=freq+(freq*fat);

		synth = LFSaw.ar([f1,f2,f3,f4],[0,0.001,0.002,0.004,0.008]);
		synth = synth * EnvGen.kr(Env([0,1,sus,0],[atk,dec,rls],'lin',2),gate,doneAction:0);
		synth=Splay.ar(synth,0.7);
		synth=RLPF.ar(synth,ffreq*Linen.kr(gate,0.1,0.4,0.2,0),0.4);
		Out.ar([0,1],synth*amp);
},[0.1,0.3,4,2]).add;
)
(
TempoClock.default = TempoClock.new(2);
fork{

	z = Synth(\fatsaw,[\gate,0,\ffreq,500,\fat,0.5]);

	a=Pseq([0,7,12,5],inf).asStream; // musical degrees
	c = Pseq([40,38,45,47],inf).asStream; // root midi notes
	e = Pseq([0.825,0.375,0.25,0.25],inf).asStream; // note durations
	f = Pseq([1000,1500,2000,2500],inf).asStream; // filter freq value

	0.1.wait;
	z.set(\gate,1);

	//set first root note
	d = c.next;

	8.do{

		// move filter freq once every 4 notes
		z.set(\ffreq, f.next);
		4.do {
			z.set(\gate,1);
			z.set(\freq,(a.next + d).midicps);
			x=[0.451,0.45,0.449].choose;
			x.wait;
			z.set(\gate,0);

			e.next.wait;
		};

		d = c.next;
	};
	2.wait;
	z.free;
};
)
raw 1264 chars (focus & ctrl+a+c to copy)
reception
comments
moncrey user 15 Dec'13 00:02

Just learned about +.x adverb, could be used instead of the nested do

Fredrik Olofsson user 15 Dec'13 10:49

nice, but i would say this is wrong... Out.ar([0,1],synth*amp);

you're outputting to 3 channels (check with s.scope). 'synth' is already stereo so better to write it like this... Out.ar(0,synth*amp);

moncrey user 17 Dec'13 12:43

aha, much thanks for the tip.

hems user 24 Dec'13 09:42

for some reason i get no sound on this example, if i add "hello".postln; to the beggining of the fork it only gets executed once, and fails silently : (

Bryan Christophe Green user 16 Feb'15 16:43

If you don't set 'doneAction' to a value of '2' in your synth envelopes and you're using this SynthDef to play a tune (say, with a Pbind), you'll need adding nodes with each note which will eventually overload and crash the SC server...

Bryan Christophe Green user 16 Feb'15 16:44

*you'll be adding nodes