Last active
March 20, 2026 13:56
-
-
Save ology/e64e8ed751a3dbd854dcdbba58c39c9d to your computer and use it in GitHub Desktop.
start/stop the sequence of a midi device
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 v5.36; | |
| use MIDI::RtMidi::FFI::Device (); | |
| use Time::HiRes qw(sleep); | |
| my $name = shift || 'SE-02'; # MIDI sequencer device | |
| my $bpm = shift || 120; | |
| my $interval = 60 / $bpm / 24; | |
| my $midi_out = RtMidiOut->new; | |
| $midi_out->open_virtual_port('RtMidiOut'); | |
| $midi_out->open_port_by_name(qr/\Q$name/i); | |
| $midi_out->start; | |
| $SIG{INT} = sub { | |
| say "\nStop"; | |
| $midi_out->stop; | |
| exit; | |
| }; | |
| while (1) { | |
| $midi_out->clock; | |
| sleep($interval); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment