NAME
Peta::MIDI::Device::In - a MIDI input as MIDI::RtMidi::FFI::Device::In has it
VERSION
version 0.2610180
SYNOPSIS
my $in = Peta::MIDI::Device::In->new(name => 'listener', ignore_timing => 0);
$in->open_port_by_name(qr/keyboard/i);
# Callbacks: in an event loop, or while waiting in dispatch.
$in->set_callback_decoded(sub ($dt, $msg, $event) { say "@$event" });
AnyEvent->condvar->recv; # or EV::run, or Coro waiting; or $in->dispatch(60)
# A handle for an event loop of one's own.
my $fh = $in->get_fh;
# Or the queue.
while (my $event = $in->get_event) { ... }
DESCRIPTION
Messages come in whole, each with the seconds since the one before. System exclusive, timing (clock, MIDI time code) and active sensing are ignored unless ignore_sysex, ignore_timing, ignore_sensing are given false. Decoded, events are [ name, fields ... ] as Peta::MIDI::Event lists them, in MIDI::Event's names unless remap_event_names is false.
RtMidi calls a callback from a thread of its own; here it runs whenever the program's event loop runs (AnyEvent's, and through it EV, Event, IO::Async or Coro), or while the program waits in dispatch.
METHODS
new
new(name => ..., ignore_sysex => 1, ignore_timing => 1, ignore_sensing => 1, enable_14bit_cc => 0, retain_events => 1, bufsize => 4096, remap_event_names => 1) (queue_size_limit is bufsize: the messages the queue holds).
set_callback, set_callback_decoded, cancel_callback
set_callback(sub ($dt, $message) {...}), set_callback_decoded(sub ($dt, $message, $event) {...}).
get_fh
A non-blocking handle the messages' bytes are written to as they come (pumped by the event loop; needs AnyEvent).
dispatch
dispatch($seconds): waits, handing the messages out as they come; how many there were. Not RtMidi's: for a program without an event loop.
get_message, get_message_decoded, get_event, decode_message, decode, decoder
The next message's bytes, or its event; an event of a message's bytes; the decoder (Peta::MIDI::Decoder).
ignore_types, ignore_sysex, ignore_timing, ignore_sensing, bufsize
ignore_types($sysex, $timing, $sensing), or each alone.
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.