💾 Archived View for thrig.me › music › midi › synth-shutup.pl captured on 2024-05-10 at 12:10:57.
⬅️ Previous capture (2024-03-21)
-=-=-=-=-=-=-
#!/usr/bin/perl # synth-shutup - when the synth gets stuck and you need to make it quiet... use 5.36.0; my $ALL_SOUNDS_OFF = 120; my $ALL_NOTES_OFF = 123; my $CONTROL_CHANGE = 11 << 4; my $midi_dev = shift // '/dev/rmidi0'; open my $midfh, '>', $midi_dev or die "could not open MIDI device '$midi_dev': $!\n"; binmode $midfh; $midfh->autoflush(1); # 0 is a pretty common channel, and 9 is where the drums usually go # (music people are weird and number the channels counting from 1 not # 0), so deal with those first for my $channel ( 0, 9, 1 .. 8, 10 .. 15 ) { printf $midfh "%c%c%c", $CONTROL_CHANGE | $channel, $ALL_NOTES_OFF, 0; printf $midfh "%c%c%c", $CONTROL_CHANGE | $channel, $ALL_SOUNDS_OFF, 0; # ... and in the event the synth don't grok the prior, also spam # note_off at all the pitches for my $pitch ( 0 .. 127 ) { printf $midfh "\x80%c%c", $pitch, 0; } }