«Fragment IX» by coreyker

on 05 May'16 16:57 in dronebandcamp

Code to reproduce this piece: https://frankchannel.bandcamp.com/track/fragment-ix

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
(

/*
Code to reproduce this piece:
https://frankchannel.bandcamp.com/track/fragment-ix
*/

s.waitForBoot{

~maxharm = 14;
SynthDef(\textureSynth, { |freq=440, numharm=4, clip=1, amp=1, outbus=100|
	var out, src, env, amps;

	// mutes
	amps = {|i| i<numharm}!~maxharm;
	amps = amps.collect{|item, i| item/(i+1)};
	
	// envelope
	env = EnvGen.ar(Env([0,1,0.5,0.1,0.01], [0.1,1,0.1,1], [1,-4,-4,-1]), timeScale:Rand(2,6), levelScale:0.5, doneAction:2);
	
	// source
	src = PinkNoise.ar(0.5);	
	out = src * env; 	

	// filter
	out = RLPF.ar(out, (1..~maxharm)*freq, Rand(0.001, 0.01), mul:amps);
	out = Mix.new(out);
		
	// effects		
	out = (out*2).tanh;		
	out = out.clip2(clip);
	
	// spatialization
	out = Pan2.ar(out);
	Out.ar(outbus, amp * out);
}).add;

SynthDef(\bassSynth, { |freq, amp=1, timeScale=1, outbus=20| 
	var m1 = SinOsc.ar(8, mul:freq*(1-(2**(0.2/12))), add:freq);
	var m2 = SinOsc.ar(2, mul:0.5, add:0.75);
	var e = EnvGen.ar(Env([0, 1, 0.05, 0], [0.1, 1, 1], [1,-2,-4]), timeScale:timeScale, doneAction:2);
	var o = e * Blip.ar(m1, 6, mul:m2);
	//var o = e * Pulse.ar(m1, 0.2, mul:m2);
	o = RLPF.ar(o, 8*freq, 0.25);

	Out.ar(outbus, Pan2.ar(amp * o));
}).add;

SynthDef(\rev, {|inbus=0, outbus=0, roomsize=200, revtime=10, damping=0.5|
	var in = In.ar(inbus,2);
	var fx = GVerb.ar(in, roomsize, revtime, damping);
	Out.ar(outbus,fx);
}).add;

Server.default.sync;
	
~scale = [0,2,5,9,12,14];
~root = 38+12;

// ********
// sequence
// ********

~bassGroup = Group.new;
~bassVerb = Synth(\rev, [\inbus, 20, \revtime, 0.25], target:~bassGroup);

~bassPatA = Pbind(\instrument, \bassSynth,
	\freq, Pstutter(1, Pseq((26 + [0,2,5,9]).midicps,4)),
	\dur, 2,
	\timeScale, 2,
	\amp, 0.25,
	\group, ~bassGroup,
	\addActon, \addToHead);		

~textGroup = Group.new;
~textVerb = Synth(\rev, [\inbus, 100, \revtime, 6], target:~textGroup);

~textPatA = Pbind(\instrument, \textureSynth,
	\pat, Prand((0..~scale.size-1),60),
	\freq, Pcollect({|i| (~root + ~scale[i]).midicps}, Pstutter(1,Pkey(\pat))),
	\numharm, Prand((1..4), inf), 
	\dur, 1,
	\amp, 0.25,
	\clip, 1,
	\group, ~textGroup,
	\addAction, \addToHead);

~textPatB = Pbind(\instrument, \textureSynth,
	\pat, Prand((0..~scale.size-1),60),
	\freq, Pcollect({|i| (~root + ~scale[i]).midicps}, Pstutter(2,Pkey(\pat))),
	\numharm, Prand((4..8), inf), 
	\dur, 1,
	\amp, 0.25,
	\clip, 0.5,
	\group, ~textGroup,
	\addAction, \addToHead);

~textPatC = Pbind(\instrument, \textureSynth,
	\pat, Prand((0..~scale.size-1),60),
	\freq, Pcollect({|i| (~root + ~scale[i]).midicps}, Pstutter(1,Pkey(\pat))),
	\numharm, Prand((8..14), inf), 
	\dur, 1,
	\amp, 0.25,
	\clip, 0.25,
	\group, ~textGroup,
	\addAction, \addToHead);
		
Pdef(\bass, Pseq([~bassPatA],8)).play;
Pdef(\text, Pseq([~textPatA, ~textPatB, ~textPatC, ~textPatA], 1)).play;
};
)
raw 2902 chars (focus & ctrl+a+c to copy)
reception
comments
p.dupuis user 05 May'16 21:58

Thanks for sharing. Sounds great!

g_montel user 06 May'16 10:46

Excellent ! Thanks a lot. May I ask you what the \pat key is for ? I've never seen it before \pat, Prand((0..~scale.size-1),60),

coreyker user 08 May'16 09:21

\pat is just a made up name to assign a symbol to a pattern, which is latter referenced from Pkey. It's not really necessary here. You could just replace the Pstutter(2,Pkey(\pat)) with Pstutter(2,Prand((0..~scale.size-1),60)) and everything should work the same. Using PKey is sometimes useful though, if you want to re-use a pattern more than once, and perhaps multiply/add a factor to it.