Dup Ver Goto 📝

MidiControlledGate1

PT2/music/reaper-jsfx does not exist
To
53 lines, 218 words, 987 chars Page 'MidiControlledGate1' does not exist.

This is a very simple midi controlled gate. Not robust. If you hold down a midi key, it opens, release, it closes. More robust is to use a synth to generate a control signal and a sidechained gate.

desc: jda midi controlled gate 1

in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output

@init
lvl = 0;
inc = 0.00;
t = sr/1000;
rate = 1/t;
onoffs = -1;
ofoffs = -1;

@block
onoffs = -1;
offoffs = -1;
splidx = 0;
while(midirecv(offset,msg1,msg2,msg3)) (
  status = msg1 >> 4;
  ( status == 0x9 && msg3 > 0 ) ? (
    onoffs = offset;
    offoffs = -1;
  ) : ( status == 0x8 || ( status == 0x9 && msg3 == 0 ) ) ? (
    offoffs = offset;
    onoffs = -1;
  );
);

@sample
( onoffs == splidx ) ? (
  inc = rate;
) : ( offoffs == splidx ) ? (
  inc = -rate;
);
( inc > 0 ) ? (
  lvl += inc;
  ( lvl >= 1.0 ) ? ( lvl = 1.0; inc = 0; );
) : ( inc < 0 ) ? (
  lvl += inc;
  ( lvl <= 0.0 ) ? ( lvl = 0.0; inc = 0; );
);

spl(0) *= lvl;
spl(1) *= lvl;

splidx += 1;