«A QuNeo's Sampler melodic and expressive with different scales» by sebastienclara

on 20 Oct'13 18:49 in samplerlooperquneo
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
/* Sébastien Clara - octobre 2013
// QuNeoSamplerMelodic  v201310


You NEED to install and configure the QuNeo library on Quarks.


A QuNeo's Sampler melodic and expressive with different scales.

  Usage :
Horizontal pad => second for heptatonic scale.
Vertical pad => third for heptatonic scale.
For change the configuration, see variable padsDegree.

pad X => frequency of the vibrato.
pad Y => amplitude of the vibrato.

circles[0] => change the scale.


If you have a problem with the 15 pad, see http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/QuNeo-Quark-tp7598479p7603927.html
*/

(
s.waitForBoot({
////////////////////////////////////////////////////////////////////////
// Initialisation
	var window, scalePopUp, scalesIndexTxt, selectSampleButton;
	var scale, padsDegree = [0,1,2,3, 2,3,4,5, 4,5,6,7, 6,7,8,9];
	var scalesIndex = 51, locMoinsUn = 1;
	var sampler = Array.fill(padsDegree.size, {nil});
	var buffer = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");

	SynthDef(\looper, { arg out=0, buffer, rate=1, amp=0.5, vibFreq=7, vibAmp=0;
		var signal;

		signal =  PlayBuf.ar(1, buffer, BufRateScale.kr(buffer)*rate, loop:1);
		signal = signal * SinOsc.kr(vibFreq*15, mul:vibAmp, add:1);
		signal = signal * amp * EnvGate.new(curve:\welch);

		Out.ar(out, signal.dup);
	}).add;

	// QuNeo's functions
	padsDegree.size.do({ |i|
		~quNeo.pads[i].note.onFunc = {
			sampler[i] = Synth(\looper, [\buffer,buffer,
				\rate, scale.degreeToRatio(padsDegree[i], 0),
				\amp, ~quNeo.pads[i].press.map,
				\vibFreq, ~quNeo.pads[i].x.map,
				\vibAmp, ~quNeo.pads[i].y.map
			])
		};

		~quNeo.pads[i].note.offFunc = {
			sampler[i].set(\fadeTime,0.02, \gate,0);
		};
	});
	~quNeo.circles[0].loc.func = {
		case
		{((~quNeo.circles[0].loc.value*10).round > locMoinsUn).and(scalesIndex < (scalePopUp.items.size-1))}
		{scalesIndex = scalesIndex + 1}

		{((~quNeo.circles[0].loc.value*10).round < locMoinsUn).and(scalesIndex > 0)}
		{scalesIndex = scalesIndex - 1};

		if (locMoinsUn != (~quNeo.circles[0].loc.value*10).round, {
			locMoinsUn = (~quNeo.circles[0].loc.value*10).round;
			{scalePopUp.valueAction = (scalesIndex)}.defer;
		});
//		postf("scalesIndex = %  --  loc = %  --  loc-1 = %\n", scalesIndex, (~quNeo.circles[0].loc.value*10).round, locMoinsUn  );
	};
////////////////////////////////////////////////////////////////////////
// Gui
	window = Window("A QuNeo's Sampler", Rect(500, 700, 250, 50));

	selectSampleButton = Button(window).states_([["Select a sample"]]);
	scalePopUp = PopUpMenu(window).items_(ScaleInfo.scales.keys.asArray.sort);
	scalesIndexTxt = StaticText(window).align_(\center);

	window.layout_( VLayout(
		selectSampleButton,
		HLayout(scalePopUp, scalesIndexTxt)
	) ).front;

////////////////////////////////////////////////////////////////////////
// Actions
	scalePopUp.action = { arg menu;
		scale = ScaleInfo.at(menu.item);
//		postf("\t*** Using scale: ---> %\n", menu.item.asString);
		scalesIndex = menu.value;
		scalesIndexTxt.string = menu.value.asString;
	};
	scalePopUp.valueAction = (scalesIndex);

	selectSampleButton.action = {
		Dialog.openPanel({ arg pathFile;
			("sample =>" + pathFile).postln;
			buffer = Buffer.read(s, pathFile);
		});
	};

	window.onClose = {
		padsDegree.size.do({ |i|
			~quNeo.pads[i].note.onFunc = nil;
			~quNeo.pads[i].note.offFunc = nil;
		});
		~quNeo.circles[0].loc.func = nil;
//		"Clear QuNeo's functions.\n".postln;
	};
})
)
raw 3578 chars (focus & ctrl+a+c to copy)
reception
comments