«Simple GUI for WavesetsEvent» by IMF

on 16 Jul'20 11:44 in guigranular synthesiswavesetswavesetsevent

A simple GUI for Waveset Synthesis. Requires WavesetsEvent, which should be placed in your SC extensions folder. Most of the code came from the included help files.

https://github.com/musikinformatik/WavesetsEvent

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
/***************************************************
****************************************************

A simple GUI for Waveset Synthesis.

Requires WavesetsEvent, which should be placed in your
SC extensions folder.

Most of the code came from the included help files.
https://github.com/musikinformatik/WavesetsEvent

***************************************************
***************************************************/

(
s.waitForBoot{

var numSliders = 9;
var numButtons = 3;
var switchFile, sliders, buttons, actions, labels, controls, init;

WavesetsEvent.prepareSynthDefs;
~wavesets = ~wavesets ?? {
	WavesetsEvent.read(Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff")
};

Tdef(\ws, {
	inf.do{ |i|
		var event = ~wavesets.asEvent((
			start: ( i % ~wavesets.size) + ~shuf.rand, //from which waveset to start + waveset shuffle
			num: ~numWs, //how many wavesets to play
			repeats: ~repeats, // how many times to repeat the selected wavesets
			rate: ~playRate, //playback speed of the audio file
			rate2: ~playRate2, //end playback speed of the audio file (will create a linear glisson sweep)
			amp: if(~prob.coin, {~volume}, {0}), //scale the amplitude of the original sound + random waveset omission from 0 - 100%
			pan: ~pan, //stereo panorama position
			legato: ~legato //scales the duration, so that wavesets will overlap or have gaps between them.
			));
		event.play;
		event[\dur].wait;
	}
});


//gui
w = Window.new("wavesets", Rect(128, 64, 400, 400)).front;
w.addFlowLayout;
w.view.decorator.gap=5@5;

	labels = ["numWs", "repeats", "playRate", "playRate2", "volume", "pan",  "legato", "shuffle", "omission"];

controls = (
		numWs: [1, 50, \lin, 1],
		repeats: [1, 10, \lin, 1],
		playRate: [-10, 10, \lin],
		playRate2: [-10, 10, \lin],
		volumes: [0, 1, \lin],
		pan: [-1, 1, \lin],
		legato: [0.001, 2, \lin],
		shuffle: [0, 100, \lin, 1],
		omission: [0, 1, 'lin']
	);

init = [1, 2, 1, 1.5, 1, 0, 1, 0, 1];

actions = (
		numWs: {|v| ~numWs = v},
		repeats: {|v| ~repeats = v},
		playRate: {|v| ~playRate = v},
		playRate2: {|v| ~playRate2 = v},
		volume: {|v| ~volume = v},
		pan: {|v| ~pan = v},
		legato: {|v| ~legato = v},
		shuffle: {|v| ~shuf = v},
		omission: {|v| ~prob = v}
	);

//create buttons
buttons = numButtons.collect{|i|
	Button.new(w, 125@30);
};

//create sliders
sliders = numSliders.collect{|i|
		EZSlider.new(w, 390@30, labels[i], controls[labels[i].asSymbol], {|sl| actions[labels[i].asSymbol].(sl.value)}, init[i], true)
		.setColors(sliderBackground: Color.rand);
};

//new soundfile button
buttons[0]
.states_(
	[["Switch File", Color.black]]
)
.action_({|obj|
	Dialog.openPanel({ | path |
		var ws = WavesetsEvent.new;
		ws.readChannel(path, onComplete: { ~wavesets = ws; ~path = path })
	});
});

//start button
buttons[1]
.states_(
	[["Start", Color.black]]
)
.action_({|obj|
	Tdef(\ws).play;
});

//stop button
buttons[2]
.states_(
	[["Stop", Color.black]]
)
.action_({|obj|
	Tdef(\ws).stop;
});

}

)
raw 3093 chars (focus & ctrl+a+c to copy)
reception
comments