diff --git a/MIDI/tomaszpio_APC Pad Blinker (Sync to Transport).jsfx b/MIDI/tomaszpio_APC Pad Blinker (Sync to Transport).jsfx new file mode 100644 index 0000000..005f5c1 --- /dev/null +++ b/MIDI/tomaszpio_APC Pad Blinker (Sync to Transport).jsfx @@ -0,0 +1,57 @@ +desc: APC Pad Blinker (Sync to Transport) +author: tomaszpio +version: 1.0.0 +about: + APC Mini mk2: blink a chosen pad LED **once per quarter note** while the DAW is **playing**. + - Output is via **Note On velocity** (single-color LED). + - Tempo comes from host `tempo` (falls back to 120 BPM). + - Uses pad note numbers (APC pads are typically 0–63; script slider allows up to 77). + + Sliders: + 1) Pad MIDI Note (0–77) — which pad to blink + 2) Enable Blinking (Off/On) + 3) Pad Color (0–127) — velocity used when LED is ON + + MIDI out (LED): status `0x96` (Note On, ch. 7), data1 = pad note, data2 = color or 0. + +slider1:0<0,77,1>Pad MIDI Note (0-63) +slider2:1<0,1,1{Off,On}>Enable Blinking +slider3:3<0,127,1>Pad Color (0-127) + +@init +note = 0; +interval = 0.5; // seconds per beat (updated from tempo) +beat_timer = 0.0; +is_on = 0; // LED state toggle +should_blink = 1; // from slider2 +play_state = 0; // host transport state (read by JSFX) +color = 0; // from slider3 + +@slider +note = slider1; +should_blink = slider2; +color = slider3; + +@block +// Read host tempo (BPM); use 120 if unavailable +tempo = tempo > 0 ? tempo : 120; +interval = 60 / tempo; // quarter-note period + +// `play_state` is provided by host (nonzero when playing/recording) + +@sample +beat_timer += 1 / srate; + +velocity = 0; + +// Blink only when transport is active and blinking is enabled +(play_state ? ( + should_blink == 1 ? ( + beat_timer >= interval ? ( + beat_timer -= interval; + is_on = is_on == 0 ? 1 : 0; + velocity = is_on ? color : 0; + midisend(0, 0x96, note, velocity); // Note On LED update (ch. 7) + ); + ); +) : 0);