MIDI::Music

Perl interface to /dev/music
Download

MIDI::Music Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Seth David Johnson
  • Publisher web site:
  • http://search.cpan.org/~sethj/

MIDI::Music Tags


MIDI::Music Description

Perl interface to /dev/music MIDI::Music is a high-level Perl interface to /dev/music, and is designed to function on any *NIX system supported by Open Sound System v.3.8 or higher.Playback through internal and external MIDI devices is supported, as is the "recording" of events from an external device. Additional goals in designing MIDI::Music were: 1. to provide an API with as few methods necessary to satisfy 99% of MIDI programmers' purposes. 2. to provide easy integration with Sean M. Burke's MIDI-Perl suite by means of a common event specification.There are, at present, essentially three things you can do with MIDI::Music: 1. Play a MIDI file. 2. Play a series of events defined in an event structure, which is a LoL as described in the MIDI::Event documentation. 3. Read a series events from an external device. These events are returned as the same type of event structure as in .It is important to remember that MIDI::Music is not a "realtime" synthesizer interface in the strictest, unbuffered sense of the term. :) Rather, a series of events are written to an internal buffer (in playback-related methods, anyway) which is flushed periodically. The "playevents" function may have, for example, long since returned, while the user continues to hear notes being played.FWIW: The readevents() method is fast to be sure, but the time involved in the interpretation of data from the external synthesizer should be taken into account. This time will of course depend on how many messages are being processed at any given read, the speed of the machine doing the processing, etc.SYNOPSIS use MIDI::Music; my $mm = new MIDI::Music; # Play a MIDI file through the # first available device $mm->playmidifile('foo.mid') || die $mm->errstr;or: use MIDI::Music; use Fcntl; my $mm = new MIDI::Music; # Initialize device for writing $mm->init('mode' => O_WRONLY, 'timebase' => 96, 'tempo' => 60, 'timesig' => , ) || die $mm->errstr; # Play a C-major chord $mm->playevents(, , , , , , , , , ]) || die $mm->errstr; $mm->dumpbuf; $mm->close;or: use MIDI::Music; use MIDI; use Fcntl; my $opus = MIDI::Opus->new(); my $track = MIDI::Track->new(); my $mm = new MIDI::Music('tempo' => 120, # These parameters 'realtime' => 1, # can be passed to ); # the constructor # Record some MIDI data from # an external device.. $mm->init('mode' => O_RDONLY) || die $mm->errstr; for (;;) { > my $event_struct = $mm->readevents; push(@{ $track->events_r }, @$event_struct) if (defined $event_struct); } $mm->close; $opus->tracks($track); $opus->write_to_file('bar.mid'); Requirements: · Perl


MIDI::Music Related Software