NAME

MIDI::Device - MIDI device metadata

VERSION

version 0.0300

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' }, ...]
my $found = $device->find('control_change', 'pan'); # [{ note => "Panpot (PAN knob)", number => 10 }]

DESCRIPTION

This module is a point of reference for other MIDI::Device::* modules. It contains device metadata. Currently, this is:

name
manufacturer
note_on
control_change
program_change
pitch_wheel_change

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
    note: "Bank Select"
  - number: 32
    note: "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, note => '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       # Yamaha
hpd-15      # Roland
kaoss-pad-v # Korg
microkorg   # Korg
se-02       # Roland
volca-drum  # Korg

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 notes.

List entries are typically of the form:

{ number => 1, note => 'Modulation' }

But these can also contain control value attributes:

{ number => 42, note => 'Switch', off => 0, on => 127 }

manufacturer

$manufacturer = $device->manufacturer;

Manufacturer of the device

new

$device = MIDI::Device->new(name => $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

pitch_bend

$pitch_bend = $device->pitch_bend;

The pitch_wheel_change 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

find

$found = $device->find('control_change', 'pan');

Search the device for an item.

SEE ALSO

MIDI::Device::DX7

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.