«just a start with Livid BASE» by moncrey

on 22 Sep'14 15:05 in midiclasscontroller

getting livid base communicating.

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
LividBASE{
	classvar <>defKeys,<>defMap,<>base,<>baseOut,<>baseIn;

	*init{ arg settings;
		this.defKeys = [\slider1,\btn1,\scene1,\scene1LEDs,\pad1];
		this.defMap = Dictionary[
			\slider1 ->1,
			\btn1-> 10,
			\scene1 -> 18,
			\scene1LEDs -> #[18,26],
			\pad1 ->36
		];
		settings.do{|a|
			if(a != nil && a.size==2,
				{this.defMap.put(a[0],a[1])}
			)
		};
		this.initMIDI;

	}


	*initMIDI{
		var baseFound=false;

		if(MIDIClient.initialized==false,{MIDIClient.init});
		MIDIClient.sources.do{|a,b|
			if(
				baseFound==false &&
				a.device == "Base" &&
				a.name == "Controls",
				{
					baseFound=true;
					this.base = b;
					this.baseIn=MIDIIn(b);
					this.baseOut = MIDIOut.newByName("Base","Controls");
				}
			)
		};
		if(this.base == nil,
			{Post << "BASE not found! base=="<< this.base << Char.nl},
			{
				// generic midi func
				MIDIFunc.noteOn({arg val,num,chan,src; val.postln;"ooo".postln;});
				MIDIFunc.noteOff({arg val,num,chan,src; val.postln;});
				// MIDIFunc({},
				// give a confirmation light show
				//this.mapToNotes
				this.hiBASE;
			}
		);
	}
	/*
	"BASE FOUND!" LED sequence
	*/
	*hiBASE{
		var seq=Pbind(
			\type, \midi,
			\chan, 16,
			\midiout, this.baseOut,
			\midinote,Pseq(this.defMap.at(\pad1)+(0..31)),
			\dur,0.007//Pbrown(0.1,0.6,length:32)
		).play;
	}
}
raw 1387 chars (focus & ctrl+a+c to copy)
reception
comments