NAME

Peta::MIDI::Device - MIDI devices as MIDI::RtMidi::FFI::Device has them, on the ALSA sequencer

VERSION

version 0.2610180

SYNOPSIS

use Peta::MIDI::Device;

my $out = Peta::MIDI::Device->new(type => 'out', name => 'my program');
$out->print_ports;
$out->open_port_by_name(qr/FLUID/i);
$out->program_change(0, 19);
$out->note_on(0, 60, 100);

my $in = Peta::MIDI::Device->new(type => 'in');
$in->open_virtual_port('my input');
$in->set_callback_decoded(sub ($dt, $msg, $event) { say "@$event" });
$in->dispatch(10);

DESCRIPTION

The devices and ports of MIDI::RtMidi::FFI::Device, its methods and their behaviour, built on the ALSA sequencer through its device with no library (Peta::MIDI::ALSA), so on perl5 and pperl alike, on Linux. An input is Peta::MIDI::Device::In, an output Peta::MIDI::Device::Out. Ports are numbered as the sequencer lists them (the readable ones for an input, the writable for an output) and named client:port c:p.

METHODS

new

new(type => 'in' or 'out', name => ..., api_name => 'alsa'); Peta::MIDI::Device::In->new and ::Out->new without type.

get_port_count, get_port_name, get_all_port_nums, get_all_port_names, get_ports_by_name, print_ports

The ports there are: how many, a number's name, { number => name } and { name => number }, the numbers whose names are a name, match a pattern or any of a list, all printed.

open_port, open_port_by_name, open_virtual_port, close_port

open_port($number, $name): a port of the device's own, named $name, connected to that port; open_port_by_name($which, $name) the first that matches; open_virtual_port($name) a port others connect to; close_port parts and removes it.

name, port_name, connected_to, connected_to_name, ok, msg, get_current_api, get_compiled_api

The device's name, its port's, the port it is connected to (number and name); ok (true) and msg (empty) as RtMidi has them; the API, alsa.

name_to_midi_event, name_from_midi_event

MIDI::Event's names for events, and back.

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.