NAME

MIDI::RtMidi::Util - Handy Utilities for Real-time MIDI

VERSION

version 0.0504

SYNOPSIS

use MIDI::RtMidi::Util qw(
  input_ports output_ports in_port out_port stop_device stop_all_notes
);

my $ports = input_ports(); # e.g. ['USB MIDI Interface', ...]
$ports = output_ports();

my $midi_in  = in_port('keyboard');
my $midi_out = out_port('usb');
# Do something cool ...

END {
  stop_device($midi_out);
  stop_all_notes($midi_out);
}

DESCRIPTION

MIDI::RtMidi::Util is a junk drawer for real-time MIDI utilities.

FUNCTIONS

in_port

$in_port = in_port($name);

Open and return a named MIDI::RtMidi::FFI::Device RtMidiIn device.

This function takes a unique part of an open MIDI port name as its argument.

out_port

$out_port = out_port($name);

Open and return a named MIDI::RtMidi::FFI::Device RtMidiOut device.

This function takes a unique part of an open MIDI port name as its argument.

stop_device

stop_device($device);

Stop an open MIDI::RtMidi::FFI::Device device.

stop_all_notes

stop_all_notes($device);

Send a note_off() message to all 16 channels and all 128 notes.

input_ports

$input_ports = input_ports();

Return an array-reference of open MIDI input port names.

output_ports

$output_ports = output_ports();

Return an array-reference of open MIDI output port names.

program_changer

program_changer($device, $program, $channel, $msb_bank, $lsb_bank);

Send bank select messages (CC#0 MSB and CC#32 LSB when given) followed by a program_change message. The program and channel arguments default to 0. The msb_bank and lsb_bank arguments default to undef.

Note that some devices remember the lsb_bank and so, in order for the program_change message to be recognized the lsb_bank must be changed from the previous setting.

SEE ALSO

MIDI::RtMidi::FFI::Device

AUTHOR

Gene Boggs <gene.boggs@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.