Bitwig meets ReaJS (for easy programmable MIDI manipulations)

Official support for: bitwig.com
Post Reply New Topic
RELATED
PRODUCTS

Post

Windows 98/ME/2K/XP/Vista/W7, WINE

http://www.reaper.fm/reaplugs/
http://www.reaper.fm/sdk/js/js.php

I've struggled the chord based MIDI manipulations, and IMO this is the easiest way

https://www.youtube.com/watch?v=L4ZCwrU7XYk

created the most basic 'hello world' like project for self education purpose, maybe it can help to able to start the work with it to somebody so share it

Code: Select all

desc:MIDI transpose

slider1:0<0, 3, 1>Octave offset

// enables processing optimizations
// MIDI-only FX should always have these lines.
in_pin:none
out_pin:none

@init

note_buffer = 0; // 4 entries per open note: orignote, channel, vel, transnote
buffer_length = 127;

@slider
octaveShift = slider1;

@block

octaveShift != last_octaveShift ?
  (i = 0;
   loop
     (buffer_length,
      midisend(0, $x80|last_channel, i); // clear the sustaining transposed note      
      note_buffer[i] = 0;
      i += 1;
      );
   last_octaveShift = octaveShift;   
   );
while 
(
  midirecv(offs, m1, m2) ?
  (
    in_channel = m1&$xF; // channel
    in_message = m1&$xF0;
    in_note = m2&$xFF; // original note
    velocity = (m2&$xFF00)/256; // velocity
    
    new_note = in_note + octaveShift * 12; // octave shift
    note_change = new_note - in_note; // difference between the two ones
    
    (in_message == $x80 ?  //note-off
      (note_buffer[new_note] = 0;
        m2 += note_change;
      )
      : 
     (in_message == $x90 ? // note-on or note-off
      (note_buffer[new_note] == 1 ?
         (midisend(0, $x80|in_channel, new_note);); // clear the sustaining transposed note            
       note_buffer[new_note] = 1;
       m2 += note_change;
       );
      );  
     ); 
    midisend(offs, m1, m2);
  );
);
easy as 1..2..3 the affected docs is here http://www.reaper.fm/sdk/js/midi.php#js_midi

have fun with it

ps. hello Bitwig developers a JS based similar one pls :)
You do not have the required permissions to view the files attached to this post.
"Where we're workarounding, we don't NEED features." - powermat

Post

I've need one so > a MIDI Polyphonic Splitter based on Phillip Cartwright's MIDI Polyphonic Splitter (ReaJS) so it needs ReaJS

https://www.youtube.com/watch?v=hzrf9yW3NLY

https://data.hu/get/10409152/ps_splitter.zip
"Where we're workarounding, we don't NEED features." - powermat

Post

xbitz, I downloaded the ps_splitter from the link you posted. When I tried to open it, got many "windows bad gateway" alerts. Have you been able to download and use this successfully?
https://www.reverbnation.com/toddsilva
Ryzen 9 5950x with 64G, i7 5820K with 32G DDR4, networked using AudioGridder, Bitwig, NI, U-he, and Arturia soft synths to name a few
Eurorack system https://www.modulargrid.net/e/racks/view/432465

Post

works for me, but here is the slightly modified ReaJS script

Code: Select all

desc: MIDI Polyphonic Splitter

slider1:1<1,16,1>Voice Number

@init

tmp = -1;
activeNotes = 1000;
activeVel = 2000;
activeCh = 3000;
activeNotes[-1] = -1;
activeVel[-1] = -1;
countNotes = 0;

priority = 0;
altPriority = 3;


i = 0;
loop(128,
    activeNotes[i] = -1;
    activeVel[i] = -1;
    activeCh[i] = -1;
    i += 1;
);
@slider 
voice = slider1 - 1;

@block

function SortNotes() local (i j)
(
    swap = 0;
    i = 0;
    while (i <= countNotes)(
        activeNotes[i] < activeNotes[i+1] ? (
            tmp = activeNotes[i];
            activeNotes[i] = activeNotes[i+1];
            activeNotes[i+1] = tmp;
            tmp = activeVel[i];
            activeVel[i] = activeVel[i+1];
            activeVel[i+1] = tmp;
            tmp = activeCh[i];
            activeCh[i] = activeCh[i+1];
            activeCh[i+1] = tmp;            i = 0;
            swap = 1;
        );
        swap == 0 ? i += 1;
        swap = 0;
    );
);

function GetNote()
(
    hNote = activeNotes[0];
    hVel = activeVel[0];
    lNote = activeNotes[countNotes-1];
    lVel = activeVel[countNotes-1];
    priority == 0 ? aNote = activeNotes[voice] : aNote = activeNotes[countNotes - voice - 1];
    priority == 0 ? aVel = activeVel[voice] : aVel = activeVel[countNotes - voice - 1];
    priority == 0 ? aCh = activeCh[voice] : aCh = activeCh[countNotes - voice - 1];
    priority == 0 ? nNote = activeNotes[voice + 1] : nNote = activeNotes[countNotes - voice - 2];
    priority == 0 ? nVel = activeVel[voice + 1] : nVel = activeVel[countNotes - voice - 2];
    priority == 0 ? nCh = activeCh[voice + 1] : nCh = activeCh[countNotes - voice - 2];
    
    aNote == -1 ? (
        altPriority == 0 ? (
          aNote = hNote;
          aVel = hVel;
          aCh = hCh;
        ) : altPriority == 1 ? (
          aNote = lNote;
          aVel = lVel;
          aCh = lCh;
        ) : altPriority == 2 ? (
          aNote = nNote;
          aVel = nVel;
          aCh = nCh;
        ) : altPriority == 3 ? (
          aNote = -1;
          aVel = -1;
          aCh = -1;
        );
    );
);

function AddNote(msg1, msg2, msg3) local (i j swap)
(
    i = 0;
    j = 0;
    while ((j == 0) && (i <= countNotes)) (
        activeNotes[i] == -1 ? (
            j = 1;
            activeNotes[i] = msg2;
            activeVel[i] = msg3;
            activeCh[i] = msg1 & 0x0F;               
        ): i += 1;
    );
);

function RemoveNote(msg2) local (i j)
(
    i = 0;
    loop(128,
     activeNotes[i] == msg2 ? (
      activeNotes[i] = -1;
      activeVel[i] = -1;
      activeCh[i] = -1;
     );
     i += 1;
    );
);

while (midirecv(ts,msg1,msg2,msg3)) (
   // if note on
  ((msg1 & 0xF0) == 0x90) && (msg3 > 0) ? (
    oNote = aNote;
    oCh = aCh;
    countNotes += 1;
    AddNote(msg1, msg2, msg3);
    SortNotes();
    GetNote();
    (aNote != oNote) ? (
        // send note off to old note
        midisend(ts,0x80+oCh,oNote,msg3);
        // send note on to new note
        midisend(ts,msg1,aNote,aVel);
      );
  // if note off  
  ) : (((msg1 & 0xF0) == 0x90) && (msg3 == 0)) ||
    ((msg1 & 0xF0) == 0x80) ? (
    midisend(ts,msg1,msg2,msg3);
    oNote = aNote;
    oCh = aCh;
    countNotes -= 1;
    RemoveNote(msg2);
    SortNotes();
    GetNote();
    ((aNote != oNote) )? (
        x = 1;
        // send note off to old note
        midisend(ts,0x80+oCh,oNote,msg3);
        // send note on to new note
        midisend(ts,msg1,aNote,aVel);
      );      
  ) : midisend(ts,msg1,msg2,msg3);
);

@gfx 200 120
k = 0;
gfx_x = 0;
gfx_y = 0;
gfx_r = 1;
gfx_b = 1;
gfx_g = 1;
gfx_drawstr("  Note  Velocity  Channel");
gfx_y += 10;
loop(8,
  gfx_x = 0;
  gfx_drawnumber(k+1,0);
  gfx_x +=15;
  gfx_drawnumber(activeNotes[k],0);
  gfx_x += 35;
  gfx_drawnumber(activeVel[k],0);
  gfx_x += 55;
  gfx_drawnumber(activeCh[k]+1,0);
  gfx_y += 10;
  k += 1;
);
gfx_b = 0;
gfx_y += 10;
should save into a ********.txt file into the X:\Users\XXXXX\AppData\Roaming\REAPER\Effects folder
"Where we're workarounding, we don't NEED features." - powermat

Post

I'm not a code guy at all, so now completely lost! :o

I was just looking for a device that could separate out MIDI notes from polyphony.

Thanks though xbitz, no biggie, I'm good for now.
https://www.reverbnation.com/toddsilva
Ryzen 9 5950x with 64G, i7 5820K with 32G DDR4, networked using AudioGridder, Bitwig, NI, U-he, and Arturia soft synths to name a few
Eurorack system https://www.modulargrid.net/e/racks/view/432465

Post

https://www.youtube.com/watch?v=wRHTjN2dzl8

after only should create some controls to it with Bitwig
"Where we're workarounding, we don't NEED features." - powermat

Post Reply

Return to “Bitwig”