Skip to content

Commit

Permalink
Add some more visual ways to explore note velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Dec 2, 2024
1 parent db51895 commit f73099d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mididump.pike
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
int last_command = 0;
Stdio.Buffer data = Stdio.Buffer();
array notenames = "C C# D Eb E F F# G Ab A Bb B" / " ";
array colors = "1;31 1;35 1;34 1;36" / " ";
int lastvel = 64;
void parsemessage() {
while (sizeof(data)) {
Stdio.Buffer.RewindKey rewind = data->rewind_on_error();
Expand Down Expand Up @@ -33,7 +36,15 @@ void parsemessage() {
error("Meta event?? In a MIDI stream??\n");
}
rewind->release();
write("%{%02X %}\n", ev);
if (ev[0] < 0x90 || (ev[0] < 0xA0 && ev[2] == 0)) {
//write("Note off [%d] %s%d\n", (ev[0] & 15) + 1, notenames[ev[1] % 12], ev[1] / 12);
} else if (ev[0] < 0xA0) {
int delta = ev[2] - lastvel; lastvel = ev[2];
//write("Note on [%d] %s%d vel %d\n", (ev[0] & 15) + 1, notenames[ev[1] % 12], ev[1] / 12, ev[2]);
//write("Note on [%d] %s%d vel %+d\n", (ev[0] & 15) + 1, notenames[ev[1] % 12], ev[1] / 12, delta);
write("\e[%sm%4s %s\e[0m\n", colors[ev[0] & 15], notenames[ev[1] % 12] + (ev[1] / 12), "*" * ev[2]);
}
else write("Event: %{%02X %}\n", ev);
}
}

Expand Down

0 comments on commit f73099d

Please sign in to comment.