«Scribble Squiggle» by 56228375

on 09 Aug'17 09:40 in squigglerecordplay

Alternative way of squiggling: instead of modeling the squiggle with math formulas you can also just draw it by mouse, record it and then play it back (after optionally transforming it) to drive some synths.

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
// part one: record squiggle
(
// start time
var startTime = thisThread.seconds ;
~allPoints = [] ;
~diffPoints = [] ;
w = Window.new.front;

q = UserView.new(w,w.view.bounds);

q.mouseDownAction_({
	| view, x, y, modifiers, buttonNumber, clickCount |
	~allPoints = [];
});
q.mouseMoveAction_({
	| view, x, y, modifiers, buttonNumber, clickCount |
	~allPoints = ~allPoints.add([x, y, thisThread.seconds-startTime].postln );
});
q.animate_(true);
q.drawFunc_({
	~allPoints.do({
		|pos, index|
		if ((index > 0), {
			Pen.fillColor = "000000";
			Pen.line( Point(~allPoints[index-1][0], ~allPoints[index-1][1]), Point(pos[0], pos[1]));
			Pen.stroke;
		});
	});
});
)

// part two: perform squiggle
(
s.waitForBoot({

SynthDef(\doSomething,  {
		| out=0, freq=440, xval, yval |
		var sig = 0.05*(VarSaw.ar(freq*yval.linlin(0,350,2,1), width:xval.linlin(0,350,0.2,0.9)));
		var env = EnvGen.ar(Env.perc(0.1),doneAction:2);
		sig = env*sig;
		Out.ar(out, sig!2);
}).add;

s.sync;

Pdef(\playRecorded,
	Pbind(\instrument, \doSomething,
		  \firstOrder, Pseq(~allPoints, 1),
		  \secondOrder, Pseq([[0,0,0], Pseq(~allPoints.differentiate.shift(-1), 1)], 1),
		  \degree, 5,
		  \xval,  Pfunc({ | ev | ev[\firstOrder][0]; }), // xval somewhere between 0 and 350
		  \yval,  Pfunc({ | ev | ev[\firstOrder][1]; }), // yval somewhere between 0 and 350
		  \dur,  Pfunc({ | ev | ev[\secondOrder][2]; })
));
Pdef(\playRecorded).play;

});

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