Created
December 3, 2022 14:16
-
-
Save creaktive/821c441614beb2eb2581a5e03ca5c123 to your computer and use it in GitHub Desktop.
simplest MIDI file writer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.036; | |
my $ch = 0; | |
my $division = 960; | |
my $note_off = 0x80; | |
my $note_on = 0x90; | |
my $track = ''; | |
$track .= pack('wC3', 23, $note_on + $ch, 69, 126); | |
$track .= pack('wC3', 5737, $note_off + $ch, 69, 64); | |
$track .= pack('wC2w', 0, 0xFF, 0x2F, 0); | |
binmode \*STDOUT; | |
print pack('NNnnn', 0x4D546864, 6, 0, 1, $division); | |
print pack('NN', 0x4D54726B, length $track); | |
print $track; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment