«Re: Launchpad Spiral» by grirgz

on 21 May'16 20:07 in code fork

For the challenge, let's make the path algorithmically =)

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
(
MIDIClient.init;
MIDIIn.connectAll;
~lpChan = 0;
~lpIn = MIDIClient.sources.select({arg item, i; (item.name == "Launchpad Mini")})[0]; //Pick the first launcpad mini you find
~lpOut = MIDIOut.newByName("Launchpad Mini", "Launchpad Mini");
~lpNoteNums = Array.fill([8,8], {|i,j| j+(i*16) });
)

(
var path = {
	var dir = [1,0];
	var list = List.new;
	var idx = [-1,0];
	var size = 8;
	size.do { arg x;
		if(x==0, 1, 2).do {
			(size-x).do {
				idx = idx + dir;
				list.add(idx);
			};
			dir = [ -1 * dir[1], dir[0] ]; // rotate 
		};
	};
	list;
}.value.collect({ arg x; x[0]+(x[1]*16) });

r = Routine({
	inf.do{
		var velocity = [127, 120, 107].choose;
		path.do{|note, i|
			~lpOut.noteOn(~lpChan, note, velocity);
			0.015.wait;
			~lpOut.noteOff(~lpChan, note, velocity);
		}
	}
});
TempoClock.default.sched(0, r);
)
raw 862 chars (focus & ctrl+a+c to copy)
reception
comments
Schemawound user 24 May'16 21:07

My original plan was to try to do that for the path but I did the whole thing on lunch break so I said brute force is good enough :)