Fix bpm for blinking in push / add simple animation
authorEugene Petkevich <nasedil.genio.code@gmail.com>
Sat, 7 May 2022 09:09:46 +0000 (12:09 +0300)
committerEugene Petkevich <nasedil.genio.code@gmail.com>
Sat, 7 May 2022 14:03:16 +0000 (17:03 +0300)
push-control.scd
test.scd

index 67d2785..9af48a4 100644 (file)
@@ -10,6 +10,8 @@
   var push = Environment[
     \version -> "33.7.2.5",
 
+    \tempo -> 2,
+
     \padColor -> IdentityDictionary[
       \white   ->  0,
       \red     ->  1,
     zi.pushOut.free;
   };
 
+  // todo — always send clocks, and separate start/stop from setting tempod
+  push.setTempo = { |zi, tempo|
+    {
+      zi.pushOut.start;
+      1.do({
+        24.do({
+          zi.pushOut.midiClock;
+          (1.0/zi.tempo/24).wait;
+        });
+      });
+      zi.pushOut.stop;
+    }.fork();
+  };
+
+  // Starter message and animation
+
+  {
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 1);
+      ~push.pushOut.control(0, i, 1);
+    });
+    1.wait;
+    (0..127).do({|i|
+      ~push.pushOut.noteOn(0, i, 0);
+      ~push.pushOut.control(0, i, 0);
+    });
+  }.fork();
+
+  "Џяпюӈи готов к использованию 😊".postln;
+
   push;
 };
 )
index 37c0aff..7fc28e6 100644 (file)
--- a/test.scd
+++ b/test.scd
@@ -104,12 +104,26 @@ MIDIdef.freeAll;
   ~col = (~col + delta).clip(0, 127);
   ~col.postln;
   (0..127).do({|i|
-    ~push.pushOut.noteOn(0, i, ~col);
+    ~push.pushOut.noteOn(13, i, ~col);
     ~push.pushOut.control(0, i, ~col);
   });
 };
 )
 
+(
+{
+  ~tempo = 40;
+  ~push.pushOut.start;
+  5.do({
+    24.do({
+      ~push.pushOut.midiClock;
+      (60/~tempo/24).wait;
+    });
+  });
+  ~push.pushOut.stop;
+}.fork();
+)
+
 ~push.pushOut
 
 m = MIDIClockOut("Ableton Push", "Ableton Push MIDI 2");
@@ -140,4 +154,6 @@ try { Exception.new().throw; ret = 1; } { ret = 2 };
 };
 )
 
-~test = ~factory.value;
\ No newline at end of file
+~test = ~factory.value;
+
+~push.setTempo(1);
\ No newline at end of file