«Cavern_Class» by Scott L Simon

on 18 Mar'19 07:46 in guiclasssynthesis

Experimental class - ambient cavern sounds (no effects yet). Class format is used here - needs to be saved as .sc file in the extensions and run with "Synth3.new" from the IDE. The class template comes from "mapping and visualization".

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
Synth3{
	
	
	var mInput;
	var mSynth;
	var mWin;
	var filter1, filter2, filter_2a, length;
	
	
	*new { arg xx;
		^super.new.init(xx);
	}
	
	init { arg xx;
		
		filter1 = 2000;
		filter2 = 2000;
		filter_2a =2000;
		length = 0.3;
		Server.default.waitForBoot({fork{
		
			Server.default.sync; 
			
			this.addSynthDef.value; 
			{ this.makeGui.value; }.defer; 
		}});
	}
	
	addSynthDef { 
		SynthDef(\testz, { arg out = 0, amp = 1,  bPassF = 2000, hPassF = 3000, 
			pan = 0, decay = 0.06, filtF = 400, amp_z =1;
			var z = BPF.ar(BrownNoise.ar(0.8.dup), bPassF, 0.2, mul: amp);
			var z2 = HPF.ar(z, hPassF, 0.2, mul: amp);
			var env = EnvGen.kr(Env.perc(0.01, decay), doneAction: 2);
			Out.ar(out, Pan2.ar(LPF.ar(z, filtF), pan, env*amp_z));
		}).add;
		
		SynthDef(\testz2, { arg out = 0, amp = 1,  bPassF2 = 2000, hPassF = 3000, 
			pan = 0, decay = 0.06, filtF2 = 400, amp_z =1;
			
			var z = BPF.ar(GrayNoise.ar(1.0.dup), bPassF2, 0.2, mul: amp);
			var z2 = HPF.ar(z, hPassF, 0.2, mul: amp);
			var env = EnvGen.kr(Env.perc(0.01, decay), doneAction: 2);
			Out.ar(out, Pan2.ar(LPF.ar(z2, filtF2), pan, env*amp_z));
		}).add;
		
		Server.default.sync;
	}
	
	makeGui{ 

		QtGUI.palette = QPalette.dark;
		
		// main window (for now)
		mWin = Window.new("Synther1",
			Rect( left:20, top:20,
				width: 300, height: 400 ),border: true);
		mWin.background = Color.blue(0.3,1);
		
		
		mWin.layout = HLayout(
			
			VLayout(
				
				StaticText().string_("Cavern_1"),
				Button()
				.states_([
					["OFF", Color.gray(0.2), Color.green(0.8)],
					["ON", Color.gray(0.8), Color.grey(0.2)] ])
				.mouseDownAction_({
					arg state;
					state.value.postln;
					if (state.value == 0) {
						mSynth = (
							
							Pbind(
\instrument,      Prand([\testz,\testz2],inf),
\bPassf,          Pwhite(100,12000, inf),
\bPassF2,         Pfunc{filter2},
\decay,           Pfunc{length},
\hPassf,          Pwhite(100,13000, inf),
\pan,             Pwhite(0.0, 1, inf),
\filtF,           Pfunc{filter1},
\filtF2,          Pwhite(80, 20000, inf),
\dur,             Pwhite(0.01,0.3,inf);
).play;)} {
						mSynth.stop;
					}
				})
				.minHeight_(70)
				.minWidth_(70),
				nil
			),
			
			VLayout(
				
				StaticText().string_("Filter"),
				Slider2D()
				.x_(0.05)
				.y_(0.05)
				.action_({ arg slider;
					
					filter1 = slider.y.value.linexp(0,1,300,20000,nil);
					filter2 = slider.x.value.linexp(0,1,30,20000,nil);
					
				}),
				StaticText().string_("Grain Length"),
				Slider(nil,Rect(0,0,50,10))
				.minHeight_(20)
				.thumbSize_(50)
				.action_({ arg slider2;
					
					length = slider2.value.linexp(0,1,0.06,0.5,nil);
					
				})
			),
		);
		
		mWin.front;
		mWin.alwaysOnTop = true;
		
		mWin.onClose_({
			mSynth.stop;
		})
		
		
		
		
		
	}
}
raw 2904 chars (focus & ctrl+a+c to copy)
reception
comments