MidiMix {
- const <version = "0.1";
- const <name = \Mix101;
classvar ledValues;
- classvar instance = nil;
+ const <version = "0.1";
+ var <name;
+ var <channel = 5;
var <midiout, <idin;
var <>caro;
var <>joro, <>viro, <>wipu, <>wire;
var <>sewo, <>luwo, <>fewo, <>viwo;
var <>sypu, <>syre;
- *new {
- if (instance == nil) {
- ledValues = IdentityDictionary[
- \on -> 127,
- \light -> 127,
- true -> 127,
- \off -> 0,
- \dark -> 0,
- false -> 0
- ];
- instance = super.new.prInit;
- };
- ^instance
+ *initClass {
+ ledValues = IdentityDictionary[
+ \on -> 127,
+ \light -> 127,
+ true -> 127,
+ \off -> 0,
+ \dark -> 0,
+ false -> 0
+ ];
+ }
+
+ *new {|name=\Mix101|
+ ^super.newCopyArgs(name).prInit;
}
prInit {
// MIDI out channel selector (back of the device)
// velocity is the channel
MIDIdef.noteOn(\caro+name, {|...args|
+ channel = args[0];
caro.value(*args);
}, 14, srcID: idin);
MIDIdef.noteOn(\viwo+name, {|...args|
viwo.value(*args);
}, 20, srcID: idin);
+
+ // Starter message and animation
+ this.animate;
+ "Шаҫиху готов к использованию 😊".postln;
}
// == LED control
// pfl a
leda {|value=true|
value = ledValues[value] ? value;
- (0..15).do {|i|
- [i, value].postln;
- midiout.noteOn(i, 1, value);
- };
+ midiout.noteOn(channel, 1, value);
}
+
+ animate {|stretch=1|
+ {
+ ((1..4)++(7..9)++(17..20)).do {|i|
+ midiout.noteOn(channel, i, 127);
+ (0.1*stretch).wait;
+ };
+ stretch.wait;
+ ((1..4)++(7..9)++(17..20)).do {|i|
+ midiout.noteOn(channel, i, 0);
+ (0.1*stretch)
+ };
+ midiout.noteOn(channel, 17, 127);
+ }.fork();
+ }
+
}
\ No newline at end of file
)
~mix = MidiMix();
-~mix.leda(127);
-~mout = MIDIOut.newByName("Mix-101", "Mix-101").latency_(0);
-~mout.noteOn(5, 1, 127);
+~mix.ledb(\off);
+~mout = MIDIOut.newByName("Mix-101", "Mix-101 MIDI 1").latency_(0);
+~mix.
+~mout.noteOn(5, 20, 127);
+
+(
+(0..15).do {|i|
+ [i].postln;
+ ~mout.noteOn(i, 2, 0);
+};
+)
(
~mix.joro = {|...args|
args.postln;
};
-)
\ No newline at end of file
+)
+
+~mix = MidiMix()
\ No newline at end of file