«Novation Launchpad Mini MK3 interface» by bla3kmatr1x

on 21 Apr'21 03:08 in interface

On the front, these boards have no writing or markings of the company, brand, model, etc... except for, in the far right corner, the basic two bars with all black border brand design, can, just like the 8x8 / 9x9 matrix... be fully modded LED 0-100 alpha-r-g-b

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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
(
// hit cmd/ctrl+enter anywhere... or (Menu) Language >> 'Evaluate File'

Server.supernova.default_(
	Server.internal
	// Server.local
).default.options_
(
	ServerOptions() // run ServerOptions.openCodeFile to see every option 
	.numAudioBusChannels_(2**10)
	.numControlBusChannels_(2**14)
	.numInputBusChannels_(0)
	.numOutputBusChannels_(2)
	.numBuffers_(2**10)
	.maxNodes_(2**12)
	.maxSynthDefs_(2**11)
	.protocol_(\udp) // \udp || \tcp
	.blockSize_(2**8)
	.memSize_(2**18) // default 2**13
	.numRGens_(2**8)
	.numWireBufs_(2**9)
	.memoryLocking_(false)
	.recChannels_(2)
)
.waitForBoot
{
	[
		(
			MIDIClient.init(verbose: false) // devices still show in the post window
		),
		(
			MIDIIn.disconnect
			(
				~inport =
				(
					MIDIClient.sources.indexOf
					(
						MIDIIn.findPort
						(
							"MIDIIN2 (LPMiniMK3 MIDI)",	"MIDIIN2 (LPMiniMK3 MIDI)"
						)
					)
				),
				~src_uid =
				(
					uid
					(
						MIDIClient.sources.at(~inport)
					)
				)
			)
			.connect
			(
				~inport, ~src_uid
			)
			.perform
			(
				\noteOnZeroAsNoteOff_, false // your choice, I prefer one MIDI definiton per action, with: if( velocity > 0) { downAction }{ upAction }
			)
		),
		(
			~send =
			(
				MIDIOut.newByName // the linux compatible method
				(
					"MIDIOUT2 (LPMiniMK3 MIDI)", "MIDIOUT2 (LPMiniMK3 MIDI)"
				)
			)
		),
		(
			~send.addUniqueMethod(\n, { |s, c, n, v| s.noteOn(c ? 0, n ? 0, v ? 0) }) // c 0 constant clear 1 constant select 2 pulse 2,1 flash
		),
		(
			~send.addUniqueMethod(\s, { |s, c, n, v| n.do{ |n| s.n(c, n, v) } } ) // ... no need to send control messages, they all respond to noteOn or control, equally
		),
		(
			~send.addUniqueMethod(\alpha, { |send, level| send.sysex(postln(Int8Array[240, 0, 32, 41, 2, 13, 8, 247].insert(7, level))) }) // brightness level
		),
		(
			[
				[\init, [14, 1]], // script mode
				[\live, [14, 0]], // 'live' mode, as in 'Ableton Live'
				[\erase, [7] ], // erase text from screen... see 'x' method below
				[\sleep, [9, 0]], // power off
				[\awaken, [9, 1]] // method 'awake' already exists for class Object... addUnqiueMethod will not over-ride existing ones
				
			].do
			{
				|sysex|
				
				~send.addUniqueMethod(sysex.first,
					{
						|send|
						// 240..13 is your necessary header, then cmd, then data, then 247 (or -9) footer... sysex msgs must always be type 8-bit Integer
						send.sysex(Int8Array[240, 0, 32, 41, 2, 13].addAll(sysex.last).add(247))
						
					}
				)
			}
		),
		(
			~send.addUniqueMethod(\x, // text rgb or pad rgb
				{
					|send, x ...rgb|
					
					send.erase.sysex
					(
						Int8Array[240, 0, 32, 41, 2, 13].addAll
						(
							switch (x.class)
							{ Integer } {
								[
									3, 3, x, rgb[0] ? 64, rgb[1] ? 0, rgb[2] ? 0
								]
							}
							{ String } {
								[
									7, ~loop ? 0, ~speed ? 8 // 0/1 is loop on/off, speed is in pads/second
								]
								.addAll
								(
									switch (rgb.size)
									{ 0 }{ [0, 3] } // default
									{ 1 }{ [0, rgb[0]] } // color palette index
									{ 2 }{ [1, rgb[0], rgb[1], 0] } // r & g only
									{ 3 }{ [1, rgb[0], rgb[1], rgb[2]]} // rgb
								)
								.addAll
								(
									x.ascii
								)
							}
						)
						.add
						(
							247
						)
					)
				}
			)
		),
		(
			~x = (..3).collect{ |x| x = ([( [11, 12, 21, 22] + (20 * x) )] + [0, 2, 4, 6]) } // ignore
		),
		(
			~x = Array.fillND(4 ! 3, { |...x| x  -> ~x.at(x[0]).at(x[1]).at(x[2]) }) // ignore
		),
		(
			~x = Dictionary.newFrom(~x.flat.asDict) // usage: ~x.at([3, 1, 3]]) returns hardware set msg# ... [0, 0, 0] is origin, [3, 3, 3] is invert origin
		),
		(
			~n = repeat(iter(n = (Array.iota(16, 4).choose[1..3].reverse.mirror1))) // selects from color palette, w/ 3 varying alpha (brightness) levels
		),
		(
			~eightX = Array2D.fromArray(8, 8, ~x.values.sort) // 8x8 matrix
		),
		(
			~nineX = Array2D.fromArray(9, 9, ~x.values.sort.asArray.reshape(8, 8).collect{ |x, n| x ++ (19, 29..89)[n] }.flat ++ ((91..99))) // 9x9 matrix
		),
		(
			MIDIdef(\eightX, { |...x| (\velocity -> x[0]).postln; (\note -> (x[1] -> ~x.findKeyForValue(x[1]))).postln }, ~eightX.array, (..15), \noteOn, ~src_uid).permanent_(true)
		),
		(
			MIDIdef(\nineX, { |v, n| ~send.n(0, n, if(v > 0){ ~n.next }{ 0 }) }, ~nineX.array, (..15), \noteOn, ~src_uid).permanent_(true)
		),
		(
			~send.init.alpha((..100).choose) // alpha (brightness) & rgb must always be in values from 0..100
		),
		(
			~send.s(0, (..127), 0) // clear the board
		),
		(
			/* to view color palette:
			
			(..63).do{ |x, n| ~send.n(0, ~eightX.array[n], x) } 
			
			(64..127).do{ |x, n| ~send.n(0, ~eightX.array[n], x) }
			
			*/
		),
		(
			// 3.do {
			play(
				Routine{ loop { var x; ~send.n((..2).wchoose([0.7, 0.15, 0.15]), x = ~nineX.array.choose, n.choose); 1.yield; ~send.n(0, x, 0); 1.yield } }
			)
			// }
		),
		
		Post << "right black switch #'s (bottom to top)" <<
		(
			~nineX.colAt(8)
		)
		<< $\n << "top black switch #'s (left to right)" <<
		(
			~nineX.rowAt(8)
		)
		<< $\n << "origin (lower left corner)"  <<
		[
			~eightX[0, 0]
		]
		<< $\n << "feel free to copy, mod, etc." << Char.nl <<
		(
			play(r{loop{ ~send.n(0, ~nineX[8, 8], (..127).choose); 0.15.yield }})
		)
	]
}
)
raw 5470 chars (focus & ctrl+a+c to copy)
reception
comments