|
|
|
05-21-2017, 05:54 PM
|
#1
|
Banned
Join Date: Nov 2015
Posts: 406
|
Slightly better Midi Logger
Hacked the logger to decompose the messages a little better. JS sucks too much to put any real effort in to it(no offense). If we could use Lua to do FX we could have some very powerful analysis tools(both midi and audio) along with the ability to create audio and midi FX easily rather than write full blown VSTs.
Code:
desc:MIDI logger(Hacked)
@init
ext_noinit = 1.0; // Prevents running @init on playback and resetting midi state
ext_midi_bus = 1; // causes midi_bus to be used for send/recv and midirecv() receives on all buses
ent_time = 0;
ent_blockoffs = 1;
ent_midiinfo = 2;
ent_seq=3;
ent_bus = 4;
ent_size = 5;
hextab = 0;
noteTab = 100;
i=0;
loop(10,hextab[i] = $'0' + i; i+=1; );
loop(6,hextab[i] = $'a' + i - 10; i+=1; );
i = -1;
i += 1; noteTab[i%12] = "C";
i += 1; noteTab[i%12] = "C#";
i += 1; noteTab[i%12] = "D";
i += 1; noteTab[i%12] = "D#";
i += 1; noteTab[i%12] = "E";
i += 1; noteTab[i%12] = "F";
i += 1; noteTab[i%12] = "F#";
i += 1; noteTab[i%12] = "G";
i += 1; noteTab[i%12] = "G#";
i += 1; noteTab[i%12] = "A";
i += 1; noteTab[i%12] = "A#";
i += 1; noteTab[i%12] = "B";
hist = 1000;
hist_size = 0;
hist_max = 10000*ent_size;
hist_chunk = 1000*ent_size; // advance
seq=0;
log_active=1;
g_cap=0;
g_capst=0;
g_at_end = 1;
g_force_redraw=1;
gfx_clear=-1;
@block
log_active ? while (
midirecv(ts,msg1,msg23) ? (
(msg1 == 0xf8) ? (1;) :
(
hist_size >= hist_max ? (
memcpy(hist,hist+hist_chunk,hist_max-hist_chunk);
hist_size = hist_max - hist_chunk;
);
hist[hist_size+ent_time] = play_position;
hist[hist_size+ent_blockoffs] = ts;
hist[hist_size+ent_midiinfo] = msg1 + msg23*256;
hist[hist_size+ent_seq] = seq; seq+=1;
hist[hist_size+ent_bus] = midi_bus;
hist_size+=ent_size;
g_force_redraw=1;
midisend(ts,msg1,msg23);
1;
);
);
);
@gfx 600 400
top_margin=0;
g_histsize = ((hist_size/ent_size)|0);
g_viewsize = (((gfx_h-top_margin-1)/(gfx_texth+2))|0);
g_pos = g_histsize - g_viewsize;
g_at_end ? (
g_pos += 1;
g_scroll = g_pos;
) : (
g_pos > g_scroll ? g_pos = g_scroll;
);
g_pos < 0 ? g_pos=0;
top_margin = gfx_texth+4;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
g_cap ? (
g_capst=0;
g_cap == 1 ? (
g_pos = mouse_y;
g_scrollbar_offs >= 0 ? g_pos-= g_scrollbar_offs;
g_pos -= top_margin+1;
g_pos = g_histsize * g_pos / (gfx_h-top_margin-1);
g_scroll = (g_pos |= 0);
g_pos < 0 ? g_pos=0;
g_pos >= g_histsize-g_viewsize ? ( g_at_end=1; g_pos = g_histsize-g_viewsize; ) : g_at_end=0;
g_pos < 0 ? g_pos=0;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
) :
g_cap == 4 && mouse_y < top_margin && mouse_X >= g_logx && mouse_x <= g_logx_e ? (
!(mouse_cap&1)? log_active=!log_active;
g_capst=1;
) :
g_cap == 3 && mouse_y < top_margin && mouse_X >= g_clearx && mouse_x <= g_clearx_e ? (
!(mouse_cap&1) ? (
seq=hist_size=0;g_histsize=0;
g_pos=1; g_at_end=1;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize; );
g_capst=1;
);
!(mouse_cap&1) ? g_cap=0;
g_force_redraw=1;
) : (
(mouse_cap & 1) ? (
g_capst=1;
mouse_y > top_margin && mouse_x > gfx_w - top_margin ? (
g_scrollbar_offs = -1;
mouse_y >= g_scrollbar_top && mouse_y <= g_scrollbar_bot ? g_scrollbar_offs = mouse_y - g_scrollbar_top;
g_cap=1; // scrollbar
) : (
g_cap = 2;
mouse_y < top_margin ? (
mouse_x >= g_logx && mouse_x <= g_logx_e ? (
g_force_redraw=1;
g_cap=4;
) : mouse_x >= g_clearx && mouse_x <= g_clearx_e ? (
g_force_redraw=1;
g_cap=3;
);
);
);
) : g_cap=0;
);
gfx_w != g_lw || gfx_h != g_lh || g_force_redraw ? (
g_force_redraw=0;
g_lw=gfx_w; g_lh=gfx_h;
gfx_r=gfx_g=gfx_b=0; gfx_a=1;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,g_lh);
// draw first row(menu)
gfx_r=gfx_g=gfx_b=0.3;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,gfx_texth+4);
// Draw Column names
gfx_r=gfx_g=gfx_b=0.5; gfx_a=1;
gfx_x = 0;
gfx_y = 16;
gfx_rectto(gfx_w,30);
g_cap == 4 && g_capst ? (
gfx_r=1; gfx_g=gfx_b=0; gfx_x=0; gfx_y=0; gfx_rectto(gfx_x+3*8,top_margin);
);
gfx_r=gfx_g=gfx_b=log_active?1:0;
gfx_x=0;
gfx_y=2;
g_logx = gfx_x;
gfx_drawchar($'L');
gfx_drawchar($'O');
gfx_drawchar($'G');
g_logx_e = gfx_x;
gfx_x += 16;
g_cap == 3 && g_capst ? (
g_lx=gfx_x;
gfx_y=0; gfx_r=1; gfx_g=gfx_b=0; gfx_rectto(gfx_x+5*8,top_margin);
gfx_x=g_lx;
gfx_y=2;
);
gfx_r=gfx_g=gfx_b=1;
g_clearx = gfx_x;
gfx_drawchar($'C');
gfx_drawchar($'L');
gfx_drawchar($'E');
gfx_drawchar($'A');
gfx_drawchar($'R');
g_clearx_e = gfx_x;
gfx_y += 16;
gfx_x = 0; gfx_drawstr("Index");
gfx_x = 60; gfx_drawstr("Time");
gfx_x = 180; gfx_drawstr("Block");
gfx_x = 230; gfx_drawstr("Bus");
gfx_x = 300; gfx_drawstr("Raw");
gfx_x = 400; gfx_drawstr("Status");
gfx_x = 470; gfx_drawstr("Channel");
gfx_x = 550; gfx_drawstr("Data 1");
gfx_x = 620; gfx_drawstr("Data 2");
gfx_x = 700; gfx_drawstr("> Info");
g_clearx_e = gfx_x;
top_margin += 10;
// right scrollbar
gfx_r=0.0; gfx_g=gfx_b=0.3;
gfx_x=gfx_w-top_margin/2;
gfx_y=2*gfx_texth+1;
gfx_rectto(gfx_w,gfx_h);
gfx_r=0.0; gfx_g=gfx_b=0.7;
gfx_y = g_scrollbar_top;
gfx_x=gfx_w-gfx_texth+1;
gfx_rectto(gfx_w-1,g_scrollbar_bot);
gfx_r=gfx_g=gfx_b=1;
g_pos = (g_pos|0) * ent_size + hist;
gfx_y=gfx_texth*3+15;
hist_size ? while (
gfx_x=0;
gfx_drawnumber(g_pos[ent_seq],0);
gfx_x=60;
gfx_drawnumber(g_pos[ent_time] + g_pos[ent_blockoffs]/srate,4);
gfx_x=180;
gfx_drawnumber(g_pos[ent_blockoffs],0);
gfx_x=230;
gfx_drawchar($'B');
gfx_drawnumber(g_pos[ent_bus]+1,0);
gfx_x=300;
g_msg = g_pos[ent_midiinfo];
loop(3,
gfx_drawchar(hextab[(g_msg/16)&15]);
gfx_drawchar(hextab[g_msg&15]);
gfx_x+=8;
g_msg/=256;
);
g_msg = g_pos[ent_midiinfo];
_status = (g_msg/16)&15;
_channel = g_msg&15;
_data1 = (g_msg/256)&127;
_data2 = (g_msg/256/256)&127;
info = "";
gfx_x = 400; gfx_printf("%d", _status);
gfx_x = 470; gfx_printf("%d", _channel);
gfx_x = 550; gfx_printf("%d", _data1);
gfx_x = 620; gfx_printf("%d", _data2);
gfx_r=gfx_g=gfx_b=1;
gfx_x = 700;
// Note Off
(_status == $x8 || (_status == $x9 && _data2 == 0))
? (
gfx_r = 0.8; gfx_g = 0.75; gfx_b = 1; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 0.8; gfx_g = 0.9; gfx_b = 0.9; gfx_printf(" Note Off");
) :
(
// Note On
(_status == $x9) ?
(
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 1; gfx_g = 0.9; gfx_b = 0.6; gfx_printf(" Note On");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("(%d)", _data2);
) :
(
// Controller Change
(_status == $xB && _data1 < 120) ?
(
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Controller ");
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf(" - ");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("%d", _data2);
) :
(
// Channel Modes
(_status == $xB && _data1 >= 120) ?
(
(_data1 == 120) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Sound Off(CM)"); );
(_data1 == 121) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
(_data1 == 122) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Local Control(CM)"); );
(_data1 == 123) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Notes Off(CM)"); );
(_data1 == 124) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
);
// Program Change
(_status == $xC) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("Program Changed to (");
gfx_r = 0.1; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf(")");
);
// SysEx
(_status == $xF && _data >> 4 == 1) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("(SE)");
);
);
);
1;
);
gfx_r=gfx_g=gfx_b=1;
gfx_y += gfx_texth+2;
g_pos += ent_size;
gfx_y < gfx_h && g_pos < hist + hist_size;
);
g_at_end ? (
gfx_x=0;
gfx_drawchar($'_');
);
);
Last edited by Airal; 05-22-2017 at 12:59 PM.
|
|
|
05-22-2017, 09:04 AM
|
#2
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Hi Airal,
thanx for the hack.
Code copied from the message gives error on compiling, because of "smiley face" that replaced original code at that line (line 55 I think).
So here is fixed code, I hope, I also edited the desc of the Effect to not confuse with original keylogger:
Code:
desc:MIDI logger (slightly better - hacked)
@init
ext_noinit = 1.0; // Prevents running @init on playback and resetting midi state
ext_midi_bus = 1; // causes midi_bus to be used for send/recv and midirecv() receives on all buses
ent_time = 0;
ent_blockoffs = 1;
ent_midiinfo = 2;
ent_seq=3;
ent_bus = 4;
ent_size = 5;
hextab = 0;
noteTab = 100;
i=0;
loop(10,hextab[i] = $'0' + i; i+=1; );
loop(6,hextab[i] = $'a' + i - 10; i+=1; );
i = -1;
i += 1; noteTab[i%12] = "C";
i += 1; noteTab[i%12] = "C#";
i += 1; noteTab[i%12] = "D";
i += 1; noteTab[i%12] = "D#";
i += 1; noteTab[i%12] = "E";
i += 1; noteTab[i%12] = "F";
i += 1; noteTab[i%12] = "F#";
i += 1; noteTab[i%12] = "G";
i += 1; noteTab[i%12] = "G#";
i += 1; noteTab[i%12] = "A";
i += 1; noteTab[i%12] = "A#";
i += 1; noteTab[i%12] = "B";
hist = 1000;
hist_size = 0;
hist_max = 10000*ent_size;
hist_chunk = 1000*ent_size; // advance
seq=0;
log_active=1;
g_cap=0;
g_capst=0;
g_at_end = 1;
g_force_redraw=1;
gfx_clear=-1;
@block
log_active ? while (
midirecv(ts,msg1,msg23) ? (
(msg1 == 0xf8) ? (1;) :
(
hist_size >= hist_max ? (
memcpy(hist,hist+hist_chunk,hist_max-hist_chunk);
hist_size = hist_max - hist_chunk;
);
hist[hist_size+ent_time] = play_position;
hist[hist_size+ent_blockoffs] = ts;
hist[hist_size+ent_midiinfo] = msg1 + msg23*256;
hist[hist_size+ent_seq] = seq; seq+=1;
hist[hist_size+ent_bus] = midi_bus;
hist_size+=ent_size;
g_force_redraw=1;
midisend(ts,msg1,msg23);
1;
);
);
);
@gfx 870 400
top_margin=0;
g_histsize = ((hist_size/ent_size)|0);
g_viewsize = (((gfx_h-top_margin-1)/(gfx_texth+2))|0);
g_pos = g_histsize - g_viewsize;
g_at_end ? (
g_pos += 1;
g_scroll = g_pos;
) : (
g_pos > g_scroll ? g_pos = g_scroll;
);
g_pos < 0 ? g_pos=0;
top_margin = gfx_texth+4;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
g_cap ? (
g_capst=0;
g_cap == 1 ? (
g_pos = mouse_y;
g_scrollbar_offs >= 0 ? g_pos-= g_scrollbar_offs;
g_pos -= top_margin+1;
g_pos = g_histsize * g_pos / (gfx_h-top_margin-1);
g_scroll = (g_pos |= 0);
g_pos < 0 ? g_pos=0;
g_pos >= g_histsize-g_viewsize ? ( g_at_end=1; g_pos = g_histsize-g_viewsize; ) : g_at_end=0;
g_pos < 0 ? g_pos=0;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
) :
g_cap == 4 && mouse_y < top_margin && mouse_X >= g_logx && mouse_x <= g_logx_e ? (
!(mouse_cap&1)? log_active=!log_active;
g_capst=1;
) :
g_cap == 3 && mouse_y < top_margin && mouse_X >= g_clearx && mouse_x <= g_clearx_e ? (
!(mouse_cap&1) ? (
seq=hist_size=0;g_histsize=0;
g_pos=1; g_at_end=1;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize; );
g_capst=1;
);
!(mouse_cap&1) ? g_cap=0;
g_force_redraw=1;
) : (
(mouse_cap & 1) ? (
g_capst=1;
mouse_y > top_margin && mouse_x > gfx_w - top_margin ? (
g_scrollbar_offs = -1;
mouse_y >= g_scrollbar_top && mouse_y <= g_scrollbar_bot ? g_scrollbar_offs = mouse_y - g_scrollbar_top;
g_cap=1; // scrollbar
) : (
g_cap = 2;
mouse_y < top_margin ? (
mouse_x >= g_logx && mouse_x <= g_logx_e ? (
g_force_redraw=1;
g_cap=4;
) : mouse_x >= g_clearx && mouse_x <= g_clearx_e ? (
g_force_redraw=1;
g_cap=3;
);
);
);
) : g_cap=0;
);
gfx_w != g_lw || gfx_h != g_lh || g_force_redraw ? (
g_force_redraw=0;
g_lw=gfx_w; g_lh=gfx_h;
gfx_r=gfx_g=gfx_b=0; gfx_a=1;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,g_lh);
// draw first row(menu)
gfx_r=gfx_g=gfx_b=0.3;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,gfx_texth+4);
// Draw Column names
gfx_r=gfx_g=gfx_b=0.5; gfx_a=1;
gfx_x = 0;
gfx_y = 16;
gfx_rectto(gfx_w,30);
g_cap == 4 && g_capst ? (
gfx_r=1; gfx_g=gfx_b=0; gfx_x=0; gfx_y=0; gfx_rectto(gfx_x+3*8,top_margin);
);
gfx_r=gfx_g=gfx_b=log_active?1:0;
gfx_x=0;
gfx_y=2;
g_logx = gfx_x;
gfx_drawchar($'L');
gfx_drawchar($'O');
gfx_drawchar($'G');
g_logx_e = gfx_x;
gfx_x += 16;
g_cap == 3 && g_capst ? (
g_lx=gfx_x;
gfx_y=0; gfx_r=1; gfx_g=gfx_b=0; gfx_rectto(gfx_x+5*8,top_margin);
gfx_x=g_lx;
gfx_y=2;
);
gfx_r=gfx_g=gfx_b=1;
g_clearx = gfx_x;
gfx_drawchar($'C');
gfx_drawchar($'L');
gfx_drawchar($'E');
gfx_drawchar($'A');
gfx_drawchar($'R');
g_clearx_e = gfx_x;
gfx_y += 16;
gfx_x = 0; gfx_drawstr("Index");
gfx_x = 60; gfx_drawstr("Time");
gfx_x = 180; gfx_drawstr("Block");
gfx_x = 230; gfx_drawstr("Bus");
gfx_x = 300; gfx_drawstr("Raw");
gfx_x = 400; gfx_drawstr("Status");
gfx_x = 470; gfx_drawstr("Channel");
gfx_x = 550; gfx_drawstr("Data 1");
gfx_x = 620; gfx_drawstr("Data 2");
gfx_x = 700; gfx_drawstr("> Info");
g_clearx_e = gfx_x;
top_margin += 10;
// right scrollbar
gfx_r=0.0; gfx_g=gfx_b=0.3;
gfx_x=gfx_w-top_margin/2;
gfx_y=2*gfx_texth+1;
gfx_rectto(gfx_w,gfx_h);
gfx_r=0.0; gfx_g=gfx_b=0.7;
gfx_y = g_scrollbar_top;
gfx_x=gfx_w-gfx_texth+1;
gfx_rectto(gfx_w-1,g_scrollbar_bot);
gfx_r=gfx_g=gfx_b=1;
g_pos = (g_pos|0) * ent_size + hist;
gfx_y=gfx_texth*3+15;
hist_size ? while (
gfx_x=0;
gfx_drawnumber(g_pos[ent_seq],0);
gfx_x=60;
gfx_drawnumber(g_pos[ent_time] + g_pos[ent_blockoffs]/srate,4);
gfx_x=180;
gfx_drawnumber(g_pos[ent_blockoffs],0);
gfx_x=230;
gfx_drawchar($'B');
gfx_drawnumber(g_pos[ent_bus]+1,0);
gfx_x=300;
g_msg = g_pos[ent_midiinfo];
loop(3,
gfx_drawchar(hextab[(g_msg/16)&15]);
gfx_drawchar(hextab[g_msg&15]);
gfx_x+=8;
g_msg/=256;
);
g_msg = g_pos[ent_midiinfo];
_status = (g_msg/16)&15;
_channel = g_msg&15;
_data1 = (g_msg/256)&127;
_data2 = (g_msg/256/256)&127;
info = "";
gfx_x = 400; gfx_printf("%d", _status);
gfx_x = 470; gfx_printf("%d", _channel);
gfx_x = 550; gfx_printf("%d", _data1);
gfx_x = 620; gfx_printf("%d", _data2);
gfx_r=gfx_g=gfx_b=1;
gfx_x = 700;
// Note Off
(_status == $x8 || (_status == $x9 && _data2 == 0))
? (
gfx_r = 0.8; gfx_g = 0.75; gfx_b = 1; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 0.8; gfx_g = 0.9; gfx_b = 0.9; gfx_printf(" Note Off");
) :
(
// Note On
(_status == $x9) ?
(
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 1; gfx_g = 0.9; gfx_b = 0.6; gfx_printf(" Note On");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("(%d)", _data2);
) :
(
// Controller Change
(_status == $xB && _data1 < 120) ?
(
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Controller ");
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf(" - ");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("%d", _data2);
) :
(
// Channel Modes
(_status == $xB && _data1 >= 120) ?
(
(_data1 == 120) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Sound Off(CM)"); );
(_data1 == 121) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
(_data1 == 122) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Local Control(CM)"); );
(_data1 == 123) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Notes Off(CM)"); );
(_data1 == 124) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
);
// Program Change
(_status == $xC) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("Program Changed to (");
gfx_r = 0.1; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf(")");
);
// SysEx
(_status == $xF && _data >> 4 == 1) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("(SE)");
);
);
);
1;
);
gfx_r=gfx_g=gfx_b=1;
gfx_y += gfx_texth+2;
g_pos += ent_size;
gfx_y < gfx_h && g_pos < hist + hist_size;
);
g_at_end ? (
gfx_x=0;
gfx_drawchar($'_');
);
);
I also changed line @gfx 870 400 to @gfx 870 400 because not all slots were visible until you manually enlarged the window to the right. So now it should be displayed by default.
Anyway, Thanks :-)
akademie
Last edited by akademie; 05-22-2017 at 09:13 AM.
|
|
|
05-22-2017, 01:03 PM
|
#3
|
Banned
Join Date: Nov 2015
Posts: 406
|
Thanks, I should have put it in a code block. I updated the original too. If we were ever to get the ability to write FX's in Lua I'd write a far better midi logger/analyzer, etc. But the original was just to limited for my tastes(I don't wanna have to convert from hex, decode the data bytes, etc .
It can be improved(handle some of the midi messages better(I stopped after I got tired of jacking with it), filtering, etc). Maybe someone will take that up at some point.
|
|
|
05-22-2017, 01:59 PM
|
#4
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by Airal
Hacked the logger to decompose the messages a little better.
|
Better compared to what ?
-Michael
|
|
|
05-22-2017, 02:34 PM
|
#5
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Quote:
Originally Posted by mschnell
Better compared to what ?
-Michael
|
Maybe compared to stock JSFX "MIDI Logger" distributed in standard Reaper installation? ;-)
akademie
|
|
|
05-22-2017, 03:05 PM
|
#6
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
05-22-2017, 06:38 PM
|
#7
|
Banned
Join Date: Nov 2015
Posts: 406
|
Quote:
Originally Posted by DarkStar
|
Great minds think alike! Down to the color
|
|
|
05-29-2017, 03:28 AM
|
#8
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
MIDI-LOG - MIDI logger modded by akademie v0.8
Hi,
as Bri1 reported a kind of a bug, where MIDI channels were displayed as 0-15 instead of 1-16, so I fixed that and made some other corrections and edits. That's why I also split it from the Airal's one and gave it new filename and description name. Change-log/history is in the effect's file, so check out for more info.
akademie
Here is the code for MIDI-LOG - MIDI logger modded by akademie v0.8
Code:
desc:MIDI-LOG - MIDI logger modded by akademie v0.8
//hi-story:
//
//2017-05-21 : original "MIDI Logger" was "hacked" in some way by user "Airal" to show more columns etc.
//and was presented as "Slightly better MIDI Logger"
//see the reaper forum topic "http://forum.cockos.com/showthread.php?t=192197" for discussion
//
//2017-05-22 : user "akademie" fixed some errors in Airal's code (mainly due to forum formatting)
//and also fixes window size to see all columns ... (description edited as "MIDI logger (slightly better - hacked)"
//
//2017-05-29 : user "akademie" set new filename (MIDI-LOG-akademie-mod)
//and desc name (MIDI-LOG - MIDI Logger modded by akademie), also adds version numbering
//to differentiate against original and Airal effects
//assigned version number v0.8
//user "akademie" fixed bug where MIDI channel was diplayed as 0-15 instead of 1-16
//user "akademie" made a few code edits to properly show new events at the bottom of window (was offset by 2 lines, which were not displayed imiidiatelly, but afte another 2 event)
//
//
@init
ext_noinit = 1.0; // Prevents running @init on playback and resetting midi state
ext_midi_bus = 1; // causes midi_bus to be used for send/recv and midirecv() receives on all buses
ent_time = 0;
ent_blockoffs = 1;
ent_midiinfo = 2;
ent_seq=3;
ent_bus = 4;
ent_size = 5;
hextab = 0;
noteTab = 100;
i=0;
loop(10,hextab[i] = $'0' + i; i+=1; );
loop(6,hextab[i] = $'a' + i - 10; i+=1; );
i = -1;
i += 1; noteTab[i%12] = "C";
i += 1; noteTab[i%12] = "C#";
i += 1; noteTab[i%12] = "D";
i += 1; noteTab[i%12] = "D#";
i += 1; noteTab[i%12] = "E";
i += 1; noteTab[i%12] = "F";
i += 1; noteTab[i%12] = "F#";
i += 1; noteTab[i%12] = "G";
i += 1; noteTab[i%12] = "G#";
i += 1; noteTab[i%12] = "A";
i += 1; noteTab[i%12] = "A#";
i += 1; noteTab[i%12] = "B";
hist = 1000;
hist_size = 0;
hist_max = 10000*ent_size;
hist_chunk = 1000*ent_size; // advance
seq=0;
log_active=1;
g_cap=0;
g_capst=0;
g_at_end = 1;
g_force_redraw=1;
gfx_clear=-1;
@block
log_active ? while (
midirecv(ts,msg1,msg23) ? (
(msg1 == 0xf8) ? (1;) :
(
hist_size >= hist_max ? (
memcpy(hist,hist+hist_chunk,hist_max-hist_chunk);
hist_size = hist_max - hist_chunk;
);
hist[hist_size+ent_time] = play_position;
hist[hist_size+ent_blockoffs] = ts;
hist[hist_size+ent_midiinfo] = msg1 + msg23*256;
hist[hist_size+ent_seq] = seq; seq+=1;
hist[hist_size+ent_bus] = midi_bus;
hist_size+=ent_size;
g_force_redraw=1;
midisend(ts,msg1,msg23);
1;
);
);
);
@gfx 870 400
top_margin=0;
g_histsize = ((hist_size/ent_size)|0)+3;
g_viewsize = (((gfx_h-top_margin)/(gfx_texth+2))|0);
g_pos = g_histsize - g_viewsize;
g_at_end ? (
g_pos += 1;
g_scroll = g_pos;
) : (
g_pos > g_scroll ? g_pos = g_scroll;
);
g_pos < 0 ? g_pos=0;
top_margin = gfx_texth+4;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
g_cap ? (
g_capst=0;
g_cap == 1 ? (
g_pos = mouse_y;
g_scrollbar_offs >= 0 ? g_pos-= g_scrollbar_offs;
g_pos -= top_margin+1;
g_pos = g_histsize * g_pos / (gfx_h-top_margin-1);
g_scroll = (g_pos |= 0);
g_pos < 0 ? g_pos=0;
g_pos >= g_histsize-g_viewsize ? ( g_at_end=1; g_pos = g_histsize-g_viewsize; ) : g_at_end=0;
g_pos < 0 ? g_pos=0;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize;
) :
g_cap == 4 && mouse_y < top_margin && mouse_X >= g_logx && mouse_x <= g_logx_e ? (
!(mouse_cap&1)? log_active=!log_active;
g_capst=1;
) :
g_cap == 3 && mouse_y < top_margin && mouse_X >= g_clearx && mouse_x <= g_clearx_e ? (
!(mouse_cap&1) ? (
seq=hist_size=0;g_histsize=0;
g_pos=1; g_at_end=1;
g_scrollbar_top = top_margin+1 + g_pos * (gfx_h-top_margin-1) / g_histsize;
g_scrollbar_bot = top_margin + 1+ (g_pos + g_viewsize)*(gfx_h-top_margin-1)/g_histsize; );
g_capst=1;
);
!(mouse_cap&1) ? g_cap=0;
g_force_redraw=1;
) : (
(mouse_cap & 1) ? (
g_capst=1;
mouse_y > top_margin && mouse_x > gfx_w - top_margin ? (
g_scrollbar_offs = -1;
mouse_y >= g_scrollbar_top && mouse_y <= g_scrollbar_bot ? g_scrollbar_offs = mouse_y - g_scrollbar_top;
g_cap=1; // scrollbar
) : (
g_cap = 2;
mouse_y < top_margin ? (
mouse_x >= g_logx && mouse_x <= g_logx_e ? (
g_force_redraw=1;
g_cap=4;
) : mouse_x >= g_clearx && mouse_x <= g_clearx_e ? (
g_force_redraw=1;
g_cap=3;
);
);
);
) : g_cap=0;
);
gfx_w != g_lw || gfx_h != g_lh || g_force_redraw ? (
g_force_redraw=0;
g_lw=gfx_w; g_lh=gfx_h;
gfx_r=gfx_g=gfx_b=0; gfx_a=1;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,g_lh);
// draw first row(menu)
gfx_r=gfx_g=gfx_b=0.3;
gfx_x=gfx_y=0;
gfx_rectto(g_lw,gfx_texth+4);
// Draw Column names
gfx_r=gfx_g=gfx_b=0.5; gfx_a=1;
gfx_x = 0;
gfx_y = 16;
gfx_rectto(gfx_w,30);
g_cap == 4 && g_capst ? (
gfx_r=1; gfx_g=gfx_b=0; gfx_x=0; gfx_y=0; gfx_rectto(gfx_x+3*8,top_margin);
);
gfx_r=gfx_g=gfx_b=log_active?1:0;
gfx_x=0;
gfx_y=2;
g_logx = gfx_x;
gfx_drawchar($'L');
gfx_drawchar($'O');
gfx_drawchar($'G');
g_logx_e = gfx_x;
gfx_x += 16;
g_cap == 3 && g_capst ? (
g_lx=gfx_x;
gfx_y=0; gfx_r=1; gfx_g=gfx_b=0; gfx_rectto(gfx_x+5*8,top_margin);
gfx_x=g_lx;
gfx_y=2;
);
gfx_r=gfx_g=gfx_b=1;
g_clearx = gfx_x;
gfx_drawchar($'C');
gfx_drawchar($'L');
gfx_drawchar($'E');
gfx_drawchar($'A');
gfx_drawchar($'R');
g_clearx_e = gfx_x;
gfx_y += 16;
gfx_x = 0; gfx_drawstr("Index");
gfx_x = 60; gfx_drawstr("Time");
gfx_x = 180; gfx_drawstr("Block");
gfx_x = 230; gfx_drawstr("Bus");
gfx_x = 300; gfx_drawstr("Raw");
gfx_x = 400; gfx_drawstr("Status");
gfx_x = 470; gfx_drawstr("Channel");
gfx_x = 550; gfx_drawstr("Data 1");
gfx_x = 620; gfx_drawstr("Data 2");
gfx_x = 700; gfx_drawstr("> Info");
g_clearx_e = gfx_x;
top_margin += 10;
// right scrollbar
gfx_r=0.0; gfx_g=gfx_b=0.3;
gfx_x=gfx_w-top_margin/2;
gfx_y=2*gfx_texth+1;
gfx_rectto(gfx_w,gfx_h);
gfx_r=0.0; gfx_g=gfx_b=0.7;
gfx_y = g_scrollbar_top;
gfx_x=gfx_w-gfx_texth+1;
gfx_rectto(gfx_w-1,g_scrollbar_bot);
gfx_r=gfx_g=gfx_b=1;
g_pos = (g_pos|0) * ent_size + hist;
gfx_y=gfx_texth*3+15;
hist_size ? while (
gfx_x=0;
gfx_drawnumber(g_pos[ent_seq],0);
gfx_x=60;
gfx_drawnumber(g_pos[ent_time] + g_pos[ent_blockoffs]/srate,4);
gfx_x=180;
gfx_drawnumber(g_pos[ent_blockoffs],0);
gfx_x=230;
gfx_drawchar($'B');
gfx_drawnumber(g_pos[ent_bus]+1,0);
gfx_x=300;
g_msg = g_pos[ent_midiinfo];
loop(3,
gfx_drawchar(hextab[(g_msg/16)&15]);
gfx_drawchar(hextab[g_msg&15]);
gfx_x+=8;
g_msg/=256;
);
g_msg = g_pos[ent_midiinfo];
_status = (g_msg/16)&15;
_channel = (g_msg&15)+1;
_data1 = (g_msg/256)&127;
_data2 = (g_msg/256/256)&127;
info = "";
gfx_x = 400; gfx_printf("%d", _status);
gfx_x = 470; gfx_printf("%d", _channel);
gfx_x = 550; gfx_printf("%d", _data1);
gfx_x = 620; gfx_printf("%d", _data2);
gfx_r=gfx_g=gfx_b=1;
gfx_x = 700;
// Note Off
(_status == $x8 || (_status == $x9 && _data2 == 0))
? (
gfx_r = 0.8; gfx_g = 0.75; gfx_b = 1; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 0.8; gfx_g = 0.9; gfx_b = 0.9; gfx_printf(" Note Off");
) :
(
// Note On
(_status == $x9) ?
(
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%s%d", noteTab[(_data1 % 12)], _data1/12 - 1);
gfx_r = 0.7; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("(%d)", _data1);
gfx_r = 1; gfx_g = 0.9; gfx_b = 0.6; gfx_printf(" Note On");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("(%d)", _data2);
) :
(
// Controller Change
(_status == $xB && _data1 < 120) ?
(
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Controller ");
gfx_r = 0.9; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf(" - ");
gfx_r = 0.5; gfx_g = 0.9; gfx_b = 0.6; gfx_printf("%d", _data2);
) :
(
// Channel Modes
(_status == $xB && _data1 >= 120) ?
(
(_data1 == 120) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Sound Off(CM)"); );
(_data1 == 121) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
(_data1 == 122) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Local Control(CM)"); );
(_data1 == 123) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("All Notes Off(CM)"); );
(_data1 == 124) ? ( gfx_r = 1; gfx_g = 0.4; gfx_b = 0.5; gfx_printf("Reset(CM)"); );
);
// Program Change
(_status == $xC) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("Program Changed to (");
gfx_r = 0.1; gfx_g = 0.75; gfx_b = 0.7; gfx_printf("%d", _data1);
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf(")");
);
// SysEx
(_status == $xF && _data >> 4 == 1) ?
(
_data1 = _data1 - 120;
gfx_r = 1; gfx_g = 0.4; gfx_b = 1; gfx_printf("(SE)");
);
);
);
1;
);
gfx_r=gfx_g=gfx_b=1;
gfx_y += gfx_texth+2;
g_pos += ent_size;
gfx_y < gfx_h && g_pos < hist + hist_size;
);
g_at_end ? (
gfx_x=0;
gfx_drawchar($'_');
);
);
|
|
|
05-29-2017, 10:25 AM
|
#9
|
Banned
Join Date: Nov 2015
Posts: 406
|
Thanks.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:00 AM.
|