!/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;

}

}

Proxy Information
Original URL
gemini://thrig.me/music/midi/synth-shutup.pl
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
1067.97512 milliseconds
Gemini-to-HTML Time
0.705234 milliseconds

This content has been proxied by September (ba2dc).