NAME

MIDI::RtMidi::ScorePlayer - Play a MIDI score in real-time

VERSION

version 0.0107

SYNOPSIS

use MIDI::RtMidi::ScorePlayer ();
use MIDI::Util qw(setup_score);

my $score = setup_score();

my %common = (score => $score, seen => {}, etc => '...',);

sub treble {
    my (%args) = @_;
    ...; # Setup things
    my $treble = sub {
        $args{score}->n('...');
        ...; # See MIDI::Simple for the n() & r() methods
    };
    return $treble;
}
sub bass {
    ...; # As above
}

MIDI::RtMidi::ScorePlayer->new(
    score    => $score, # required MIDI score object
    parts    => [ \&treble, \&bass ], # required part functions
    common   => \%common, # arguments given to the part functions
    repeats  => 4, # number of repeated synched parts (default: 1)
    sleep    => 2, # number of seconds to sleep between loops (default: 1)
    loop     => 4, # loop limit if finite (default: 1)
    infinite => 0, # loop infinitely (default: 1)
)->play;

DESCRIPTION

MIDI::RtMidi::ScorePlayer plays a MIDI score in real-time.

Hints

Linux: If your distro does not install a service, you can use timidity in daemon mode: timidity -iAD. Also, FluidSynth is an alternative.

MacOS: You can get General MIDI via DLSMusicDevice within Logic or Garageband. You will need a soundfont containing drum patches in '~/Library/Audio/Sounds/Banks/' and DLSMusicDevice open in Garageband or Logic with this soundfont selected. See the MIDI::RtMidi::FFI::Device docs for more info. Alternatively you can use FluidSynth: fluidsynth -a coreaudio -m coremidi -g 1.0 ~/Music/some-soundfont.sf2. Also, you can use timidity too.

For Windows, this should just work out of the box.

METHODS

new

Instantiate a new MIDI::RtMidi::ScorePlayer object.

play

Play a given MIDI score in real-time.

SEE ALSO

Examples can be found in the eg/* files in this distribution.

MIDI::RtMidi::FFI::Device

MIDI::Util

Time::HiRes

AUTHOR

Gene Boggs <gene.boggs@gmail.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2024 by Gene Boggs.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)