Skip to content

Commit

Permalink
One Small Step v0.1 (initial release) (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTalagan authored Feb 7, 2024
1 parent 33ec24c commit d47571a
Show file tree
Hide file tree
Showing 21 changed files with 1,604 additions and 0 deletions.
19 changes: 19 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Change note len modifier.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local modifier = select(2, reaper.get_action_context()):match("%- ([^%s]*)%.lua$");

local engine_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Engine lib";


if modifier == 'Triplet' then
engine_lib.setNoteLenModifier(engine_lib.NoteLenModifier.Triplet);
elseif modifier == 'Dotted' then
engine_lib.setNoteLenModifier(engine_lib.NoteLenModifier.Dotted);
elseif modifier == 'Straight' then
engine_lib.setNoteLenModifier(engine_lib.NoteLenModifier.Straight);
end
11 changes: 11 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Change note len.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local note_len = select(2, reaper.get_action_context()):match("%- ([^%s]*)%.lua$");

local engine_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Engine lib";
engine_lib.setNoteLen(note_len);
12 changes: 12 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Cleanup helper JSFXs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local helper_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Helper lib";

reaper.Undo_BeginBlock();
helper_lib.cleanupAllTrackFXs();
reaper.Undo_EndBlock("One Small Step - Cleanup helper JSFXs",-1);
9 changes: 9 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Commit.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local engine_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Engine lib";
engine_lib.reaperActionCommit();
9 changes: 9 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Decrease note len.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local engine_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Engine lib";
engine_lib.decreaseNoteLen();
9 changes: 9 additions & 0 deletions MIDI Editor/talagan_OneSmallStep Increase note len.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path;

local engine_lib = require "talagan_OneSmallStep/talagan_OneSmallStep Engine lib";
engine_lib.increaseNoteLen();
399 changes: 399 additions & 0 deletions MIDI Editor/talagan_OneSmallStep.lua

Large diffs are not rendered by default.

143 changes: 143 additions & 0 deletions MIDI Editor/talagan_OneSmallStep/One Small Step Helper.jsfx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
noindex: true
desc: One Small Step Helper
version: 0.1
author: Ben 'Talagan' Babut

slider1:0<0,3153600000,0.001>Sustain Pedal Activity
slider2:0<0,127,1>Notes in buffer

// Generate sliders for held notes
<?
note_buffer_size = 32;
note_slider_offset = 10;
ni = 0;
while(ni < note_buffer_size) (
printf("slider%d:<0,127,1>Note %d Pitch\n", note_slider_offset + 3*ni + 0, ni);
printf("slider%d:<0,15,1> Note %d Channel\n", note_slider_offset + 3*ni + 1, ni);
printf("slider%d:<0,127,1>Note %d Velocity\n", note_slider_offset + 3*ni + 2, ni);

ni += 1;
);
?>

@init

last_slider_update = 0;

// Use a buffer to retain note states, and update sliders in @block
// Instead of updating sliders directly.
// This avoid glitches due to undo operations that could restore FX params
// And we don't want that

MAX_NOTE = 32;
note_buf = 0;
note_cnt = 0;

function spitch(note_num) ( (10 + 3*note_num + 0) );
function schan(note_num) ( (10 + 3*note_num + 1) );
function svel(note_num) ( (10 + 3*note_num + 2) );

// Only note_buf is used so free the memory after it.
freembuf(32 * 3 + 1);

function addRemoveNoteFromBuffer(m1,m2,m3)
local(s,c,n,v,t,i,j,init_buflen)
(
init_buflen = note_cnt;

s = m1&$xF0;
n = m2; // note
c = m1&$xF; // channel
v = m3; // velocity

i = -1;
while // look for this note|channel already in the buffer
(
i = i+1;
i < note_cnt && i < MAX_NOTE && (notebuf[3*i]|0 != n || notebuf[3*i + 1]|0 != c);
);

(i == MAX_NOTE)?(
-1;
):(

(s == $x90 && v > 0) ?
(

// note-on, add to buffer
notebuf[3*i+0] = n;
notebuf[3*i+1] = c;
notebuf[3*i+2] = v;

i == note_cnt ? note_cnt = note_cnt+1;
):
(

// note-off, remove from buffer
i < note_cnt ?
(
j = i;
while(j < note_cnt)
(
// Shift all sliders to delete current entry
notebuf[3*j+0] = notebuf[3*(j+1)+0];
notebuf[3*j+1] = notebuf[3*(j+1)+1];
notebuf[3*j+2] = notebuf[3*(j+1)+2];
j = j + 1;
);
while(j < MAX_NOTE)
(
notebuf[3*j+0] = 0;
notebuf[3*j+1] = 0;
notebuf[3*j+2] = 0;
j = j + 1;
);

note_cnt = note_cnt - 1;
);
);
);

note_cnt==init_buflen ? -1; //return value for nothing added/removed
);

@block

function updateSliders() (
i = 0;
while(i < MAX_NOTE) (
slider(spitch(i)) = note_buf[3*i+0];
slider(schan(i)) = note_buf[3*i+1];
slider(svel(i)) = note_buf[3*i+2];
i = i+1;
);
slider2 = note_cnt;
);

function main()
local(offset,msg1,msg2,msg3)
(
while (midirecv(offset,msg1,msg2,msg3))
(
(msg1&$xF0==$x90) ?
addRemoveNoteFromBuffer(msg1,msg2,msg3);

(msg1&$xF0==$x80) ?
addRemoveNoteFromBuffer(msg1,msg2,msg3);

(msg1&$xF0==$xB0 && msg2 == 64 && msg3 > 0) ?
slider1 = time_precise();

(msg1&$xF0==$xB0 && msg2 == 64 && msg3 == 0) ?
slider1 = 0;

midisend(offset,msg1,msg2,msg3);
)
);

main();
t = time_precise();
(t - last_slider_update > 0.05)?(
updateSliders();
last_slider_update = t;
);
55 changes: 55 additions & 0 deletions MIDI Editor/talagan_OneSmallStep/images/note_1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- @noindex
-- @author Ben 'Talagan' Babut
-- @license MIT
-- @description This is part of One Small Step

return "\z
\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x1E\x00\x00\x00\x1E\x08\x06\x00\x00\x00\x3B\x30\xAE\xA2\x00\x00\x00\x09\x70\x48\x59\z
\x73\x00\x00\x0B\x13\x00\x00\x0B\x13\x01\x00\x9A\x9C\x18\x00\x00\x06\xA1\x69\x54\x58\x74\x58\x4D\x4C\x3A\x63\x6F\x6D\x2E\x61\x64\x6F\x62\x65\x2E\x78\x6D\x70\x00\z
\x00\x00\x00\x00\x3C\x3F\x78\x70\x61\x63\x6B\x65\x74\x20\x62\x65\x67\x69\x6E\x3D\x22\xEF\xBB\xBF\x22\x20\x69\x64\x3D\x22\x57\x35\x4D\x30\x4D\x70\x43\x65\x68\x69\z
\x48\x7A\x72\x65\x53\x7A\x4E\x54\x63\x7A\x6B\x63\x39\x64\x22\x3F\x3E\x20\x3C\x78\x3A\x78\x6D\x70\x6D\x65\x74\x61\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x3D\x22\x61\x64\z
\x6F\x62\x65\x3A\x6E\x73\x3A\x6D\x65\x74\x61\x2F\x22\x20\x78\x3A\x78\x6D\x70\x74\x6B\x3D\x22\x41\x64\x6F\x62\x65\x20\x58\x4D\x50\x20\x43\x6F\x72\x65\x20\x39\x2E\z
\x30\x2D\x63\x30\x30\x31\x20\x37\x39\x2E\x31\x34\x65\x63\x62\x34\x32\x66\x32\x63\x2C\x20\x32\x30\x32\x33\x2F\x30\x31\x2F\x31\x33\x2D\x31\x32\x3A\x32\x35\x3A\x34\z
\x34\x20\x20\x20\x20\x20\x20\x20\x20\x22\x3E\x20\x3C\x72\x64\x66\x3A\x52\x44\x46\x20\x78\x6D\x6C\x6E\x73\x3A\x72\x64\x66\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x77\z
\x77\x77\x2E\x77\x33\x2E\x6F\x72\x67\x2F\x31\x39\x39\x39\x2F\x30\x32\x2F\x32\x32\x2D\x72\x64\x66\x2D\x73\x79\x6E\x74\x61\x78\x2D\x6E\x73\x23\x22\x3E\x20\x3C\x72\z
\x64\x66\x3A\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x20\x72\x64\x66\x3A\x61\x62\x6F\x75\x74\x3D\x22\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x6D\x70\x3D\x22\x68\z
\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F\x62\x65\x2E\x63\x6F\x6D\x2F\x78\x61\x70\x2F\x31\x2E\x30\x2F\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x64\x63\x3D\x22\x68\z
\x74\x74\x70\x3A\x2F\x2F\x70\x75\x72\x6C\x2E\x6F\x72\x67\x2F\x64\x63\x2F\x65\x6C\x65\x6D\x65\x6E\x74\x73\x2F\x31\x2E\x31\x2F\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x70\z
\x68\x6F\x74\x6F\x73\x68\x6F\x70\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F\x62\x65\x2E\x63\x6F\x6D\x2F\x70\x68\x6F\x74\x6F\x73\x68\x6F\x70\x2F\z
\x31\x2E\x30\x2F\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x6D\x70\x4D\x4D\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F\x62\x65\x2E\x63\x6F\x6D\x2F\x78\z
\x61\x70\x2F\x31\x2E\x30\x2F\x6D\x6D\x2F\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x73\x74\x45\x76\x74\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F\x62\x65\z
\x2E\x63\x6F\x6D\x2F\x78\x61\x70\x2F\x31\x2E\x30\x2F\x73\x54\x79\x70\x65\x2F\x52\x65\x73\x6F\x75\x72\x63\x65\x45\x76\x65\x6E\x74\x23\x22\x20\x78\x6D\x70\x3A\x43\z
\x72\x65\x61\x74\x6F\x72\x54\x6F\x6F\x6C\x3D\x22\x41\x64\x6F\x62\x65\x20\x50\x68\x6F\x74\x6F\x73\x68\x6F\x70\x20\x32\x34\x2E\x32\x20\x28\x4D\x61\x63\x69\x6E\x74\z
\x6F\x73\x68\x29\x22\x20\x78\x6D\x70\x3A\x43\x72\x65\x61\x74\x65\x44\x61\x74\x65\x3D\x22\x32\x30\x32\x33\x2D\x31\x32\x2D\x30\x36\x54\x31\x37\x3A\x30\x34\x3A\x30\z
\x35\x2B\x30\x31\x3A\x30\x30\x22\x20\x78\x6D\x70\x3A\x4D\x6F\x64\x69\x66\x79\x44\x61\x74\x65\x3D\x22\x32\x30\x32\x34\x2D\x30\x32\x2D\x30\x32\x54\x31\x36\x3A\x34\z
\x33\x3A\x30\x34\x2B\x30\x31\x3A\x30\x30\x22\x20\x78\x6D\x70\x3A\x4D\x65\x74\x61\x64\x61\x74\x61\x44\x61\x74\x65\x3D\x22\x32\x30\x32\x34\x2D\x30\x32\x2D\x30\x32\z
\x54\x31\x36\x3A\x34\x33\x3A\x30\x34\x2B\x30\x31\x3A\x30\x30\x22\x20\x64\x63\x3A\x66\x6F\x72\x6D\x61\x74\x3D\x22\x69\x6D\x61\x67\x65\x2F\x70\x6E\x67\x22\x20\x70\z
\x68\x6F\x74\x6F\x73\x68\x6F\x70\x3A\x43\x6F\x6C\x6F\x72\x4D\x6F\x64\x65\x3D\x22\x33\x22\x20\x78\x6D\x70\x4D\x4D\x3A\x49\x6E\x73\x74\x61\x6E\x63\x65\x49\x44\x3D\z
\x22\x78\x6D\x70\x2E\x69\x69\x64\x3A\x33\x30\x65\x32\x39\x36\x34\x61\x2D\x32\x31\x33\x38\x2D\x34\x38\x66\x62\x2D\x61\x65\x32\x34\x2D\x63\x33\x30\x32\x65\x63\x62\z
\x61\x66\x38\x35\x30\x22\x20\x78\x6D\x70\x4D\x4D\x3A\x44\x6F\x63\x75\x6D\x65\x6E\x74\x49\x44\x3D\x22\x61\x64\x6F\x62\x65\x3A\x64\x6F\x63\x69\x64\x3A\x70\x68\x6F\z
\x74\x6F\x73\x68\x6F\x70\x3A\x32\x32\x34\x31\x39\x64\x37\x35\x2D\x37\x35\x31\x35\x2D\x31\x63\x34\x63\x2D\x61\x32\x34\x35\x2D\x38\x64\x33\x63\x32\x63\x36\x35\x35\z
\x31\x65\x64\x22\x20\x78\x6D\x70\x4D\x4D\x3A\x4F\x72\x69\x67\x69\x6E\x61\x6C\x44\x6F\x63\x75\x6D\x65\x6E\x74\x49\x44\x3D\x22\x78\x6D\x70\x2E\x64\x69\x64\x3A\x32\z
\x35\x61\x34\x61\x62\x32\x37\x2D\x39\x35\x66\x36\x2D\x34\x36\x39\x61\x2D\x61\x35\x62\x66\x2D\x39\x66\x34\x64\x38\x31\x65\x31\x66\x63\x32\x38\x22\x3E\x20\x3C\x78\z
\x6D\x70\x4D\x4D\x3A\x48\x69\x73\x74\x6F\x72\x79\x3E\x20\x3C\x72\x64\x66\x3A\x53\x65\x71\x3E\x20\x3C\x72\x64\x66\x3A\x6C\x69\x20\x73\x74\x45\x76\x74\x3A\x61\x63\z
\x74\x69\x6F\x6E\x3D\x22\x63\x72\x65\x61\x74\x65\x64\x22\x20\x73\x74\x45\x76\x74\x3A\x69\x6E\x73\x74\x61\x6E\x63\x65\x49\x44\x3D\x22\x78\x6D\x70\x2E\x69\x69\x64\z
\x3A\x32\x35\x61\x34\x61\x62\x32\x37\x2D\x39\x35\x66\x36\x2D\x34\x36\x39\x61\x2D\x61\x35\x62\x66\x2D\x39\x66\x34\x64\x38\x31\x65\x31\x66\x63\x32\x38\x22\x20\x73\z
\x74\x45\x76\x74\x3A\x77\x68\x65\x6E\x3D\x22\x32\x30\x32\x33\x2D\x31\x32\x2D\x30\x36\x54\x31\x37\x3A\x30\x34\x3A\x30\x35\x2B\x30\x31\x3A\x30\x30\x22\x20\x73\x74\z
\x45\x76\x74\x3A\x73\x6F\x66\x74\x77\x61\x72\x65\x41\x67\x65\x6E\x74\x3D\x22\x41\x64\x6F\x62\x65\x20\x50\x68\x6F\x74\x6F\x73\x68\x6F\x70\x20\x32\x34\x2E\x32\x20\z
\x28\x4D\x61\x63\x69\x6E\x74\x6F\x73\x68\x29\x22\x2F\x3E\x20\x3C\x72\x64\x66\x3A\x6C\x69\x20\x73\x74\x45\x76\x74\x3A\x61\x63\x74\x69\x6F\x6E\x3D\x22\x73\x61\x76\z
\x65\x64\x22\x20\x73\x74\x45\x76\x74\x3A\x69\x6E\x73\x74\x61\x6E\x63\x65\x49\x44\x3D\x22\x78\x6D\x70\x2E\x69\x69\x64\x3A\x35\x63\x35\x35\x31\x64\x38\x63\x2D\x34\z
\x39\x66\x38\x2D\x34\x30\x30\x64\x2D\x62\x64\x32\x63\x2D\x61\x65\x39\x63\x39\x64\x33\x33\x64\x65\x62\x65\x22\x20\x73\x74\x45\x76\x74\x3A\x77\x68\x65\x6E\x3D\x22\z
\x32\x30\x32\x34\x2D\x30\x32\x2D\x30\x32\x54\x31\x32\x3A\x34\x36\x3A\x35\x35\x2B\x30\x31\x3A\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3A\x73\x6F\x66\x74\x77\x61\x72\z
\x65\x41\x67\x65\x6E\x74\x3D\x22\x41\x64\x6F\x62\x65\x20\x50\x68\x6F\x74\x6F\x73\x68\x6F\x70\x20\x32\x34\x2E\x32\x20\x28\x4D\x61\x63\x69\x6E\x74\x6F\x73\x68\x29\z
\x22\x20\x73\x74\x45\x76\x74\x3A\x63\x68\x61\x6E\x67\x65\x64\x3D\x22\x2F\x22\x2F\x3E\x20\x3C\x72\x64\x66\x3A\x6C\x69\x20\x73\x74\x45\x76\x74\x3A\x61\x63\x74\x69\z
\x6F\x6E\x3D\x22\x73\x61\x76\x65\x64\x22\x20\x73\x74\x45\x76\x74\x3A\x69\x6E\x73\x74\x61\x6E\x63\x65\x49\x44\x3D\x22\x78\x6D\x70\x2E\x69\x69\x64\x3A\x33\x30\x65\z
\x32\x39\x36\x34\x61\x2D\x32\x31\x33\x38\x2D\x34\x38\x66\x62\x2D\x61\x65\x32\x34\x2D\x63\x33\x30\x32\x65\x63\x62\x61\x66\x38\x35\x30\x22\x20\x73\x74\x45\x76\x74\z
\x3A\x77\x68\x65\x6E\x3D\x22\x32\x30\x32\x34\x2D\x30\x32\x2D\x30\x32\x54\x31\x36\x3A\x34\x33\x3A\x30\x34\x2B\x30\x31\x3A\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3A\z
\x73\x6F\x66\x74\x77\x61\x72\x65\x41\x67\x65\x6E\x74\x3D\x22\x41\x64\x6F\x62\x65\x20\x50\x68\x6F\x74\x6F\x73\x68\x6F\x70\x20\x32\x34\x2E\x32\x20\x28\x4D\x61\x63\z
\x69\x6E\x74\x6F\x73\x68\x29\x22\x20\x73\x74\x45\x76\x74\x3A\x63\x68\x61\x6E\x67\x65\x64\x3D\x22\x2F\x22\x2F\x3E\x20\x3C\x2F\x72\x64\x66\x3A\x53\x65\x71\x3E\x20\z
\x3C\x2F\x78\x6D\x70\x4D\x4D\x3A\x48\x69\x73\x74\x6F\x72\x79\x3E\x20\x3C\x2F\x72\x64\x66\x3A\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x3E\x20\x3C\x2F\x72\x64\z
\x66\x3A\x52\x44\x46\x3E\x20\x3C\x2F\x78\x3A\x78\x6D\x70\x6D\x65\x74\x61\x3E\x20\x3C\x3F\x78\x70\x61\x63\x6B\x65\x74\x20\x65\x6E\x64\x3D\x22\x72\x22\x3F\x3E\x30\z
\xBF\x9D\x5A\x00\x00\x00\x84\x49\x44\x41\x54\x48\x89\xED\xD6\x41\x0D\x84\x30\x10\x05\xD0\x5F\xB2\x67\x08\x8E\x58\x07\x20\x05\x05\x48\x40\x0A\x16\x70\x80\x84\x5D\z
\x07\x0C\xFD\x02\xCA\x65\x04\x30\x84\x84\xCB\xFF\x97\x69\x9A\xB6\x6F\xDA\x53\x53\x29\x05\x6F\xA4\x7A\x45\x15\x2C\x58\xB0\x60\xC1\x82\x05\x0B\xBE\x1C\x23\x7B\x23\z
\x7F\x46\x6E\x46\xCE\x46\x16\x1F\xF7\x51\xF8\x13\x5C\xBF\x78\xFD\xB6\x75\xBD\xEE\x39\x1F\x00\x26\x9F\x4F\x91\x83\xEE\x3E\x75\xE7\x75\xBD\xB9\x3F\x7C\xE3\x01\xC0\z
\x0C\x60\xDA\x73\x6E\xBC\x81\x3F\x80\x31\x0A\x27\x7D\x6F\x05\x0B\x7E\x2A\x27\x25\xD2\x2C\x60\x73\x66\x31\xC3\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82"
;
Loading

0 comments on commit d47571a

Please sign in to comment.