NAME
MIDI::Device - MIDI device access
VERSION
version 0.0102
SYNOPSIS
use MIDI::Device ();
my $device = MIDI::Device->new(name => 'midi-device-name'); # e.g. 'hpd-15'
print 'Device: ', join(", ", $device->name, $device->manufacturer), "\n";
my $ccs = $device->cc; # [ { number => 1, name => 'Modulation' }, ... ]
DESCRIPTION
Point of reference for MIDI::Device::* modules. Contains device metadata and control change messages.
It is my hope to add more useful metadata and methods...
Extending
Make a YAML file named for the device (preferably in lower-case). Save it in the distribution share directory. Make a package to instantiate the device object.
YAML file share/my-device.yml:
name: "My Device"
manufacturer: "My Company, Inc."
port:
in: "My MIDI Port In" # "generic" for a non-class-compliant device
out: "My MIDI Port Out"
control_change:
- number: 0
name: "Bank Select"
- number: 32
name: "Bank Select"
...
Perl module lib/MIDI/Device/My_Device.pm:
package MIDI::Device::My_Device;
# ABSTRACT: My Device MIDI device metadata
our $VERSION = '0.0100';
use Moo;
extends 'MIDI::Device';
=encoding utf8
=head1 SYNOPSIS
use MIDI::Device::My_Device ();
my $device = MIDI::Device::My_Device->new;
print "Device: ", join(", ", $device->name, $device->manufacturer), "\n";
my $ccs = $device->cc; # [ { number => 0, name => 'Bank Select' }, ... ]
=head1 DESCRIPTION
My device metadata.
=cut
=head1 ATTRIBUTES
=head2 module
The name of this module: C<'MIDI::Device::My_Device'>.
=cut
has module => (
is => 'ro',
default => 'MIDI::Device::My_Device',
);
=head2 name
Device name: C<my_device>
=cut
has name => (
is => 'ro',
default => 'my_device',
);
=head1 METHODS
=head2 new
$device = MIDI::Device::My_Device->new;
Return a new C<MIDI::Device::My_Device> object.
=cut
1;
ATTRIBUTES
name
$name = $device->name;
Name of the device
Known device names:
ez-ag
hpd-15
kaoss-pad-v
microkorg
se-02
volca-drum
module
$module = $device->module;
Name of the module. This is the name of a subclass, like 'MIDI::Device::DX7'.
Default: MIDI::Device
shared
$shared = $device->shared;
Name of the device shared directory
METHODS
cc
$ccs = $device->cc;
List of control change numbers and names
List entries are typically of the form:
{ number => 1, name => 'Modulation' }
But these can also contain control value attributes:
{ number => 42, name => 'Switch', off => 0, on => 127 }
manufacturer
$manufacturer = $device->manufacturer;
Manufacturer of the device
new
$device = MIDI::Device->new($port_name)
Return a new MIDI::Device object given a port name of an available MIDI device on the system.
note_on
$note_on = $device->note_on;
The note_on section of the device
port_in
$port_in = $device->port_in;
Input port name of the device
port_out
$port_out = $device->port_out;
Output port name of the 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.