The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MIDI::Util - MIDI Utilities

VERSION

version 0.0901

SYNOPSIS

  use MIDI::Util qw(midi_dump midi_format set_chan_patch set_time_sig setup_score);

  my $dump = midi_dump('volume'); # length, etc.
  print Dumper $dump;

  my $size = dura_size('dqn');

  my $score = setup_score( bpm => 120, etc => '...', );

  set_time_sig( $score, '5/4' );

  set_chan_patch( $score, 0, 1 );

  my @notes = midi_format('C','C#','Db','D'); # C, Cs, Df, D

  $score->n('wn', @notes);         # MIDI::Simple functionality
  $score->write_score('some.mid'); # MIDI::Simple functionality

DESCRIPTION

MIDI::Util comprises handy MIDI utilities.

Nothing is exported by default.

FUNCTIONS

setup_score

  $score = setup_score;  # Use defaults

  $score = setup_score(  # Override defaults
    lead_in   => $beats,
    volume    => $volume,
    bpm       => $bpm,
    channel   => $channel,
    patch     => $patch,
    octave    => $octave,
    signature => $signature,
  );

Set basic MIDI parameters and return a MIDI::Simple object. If given a lead_in, play a hi-hat for that many beats. Do not include a lead_in by passing 0 as its value.

Named parameters and defaults:

  lead_in:   4
  volume:    120
  bpm:       100
  channel:   0
  patch:     0
  octave:    4
  signature: 4/4

set_chan_patch

  set_chan_patch( $score, $channel );  # Just set the channel

  set_chan_patch( $score, $channel, $patch );

Set the MIDI channel and patch.

Positional parameters and defaults:

  score:   undef (required)
  channel: 0
  patch:   undef

midi_dump

  $dump = midi_dump($list_name);

Return sorted array references of the following MIDI, MIDI::Simple, and MIDI::Event internal lists:

  Volume
  Length
  TICKS
  Note
  note2number
  number2note
  patch2number
  number2patch
  notenum2percussion
  percussion2notenum
  All_events
  MIDI_events
  Meta_events
  Text_events
  Nontext_meta_events

midi_format

  @formatted = midi_format(@notes);

Change sharp # and flat b, in the list of named notes, to the MIDI::Simple s and f respectively.

set_time_sig

  set_time_sig( $score, $signature );

Set the score time_signature based on the given string.

dura_size

  $size = dura_size($duration);

Return the duration size based on the MIDI::Simple Length value (e.g. hn, ten) or number of ticks (if given as d###).

SEE ALSO

The t/01-functions.t test file in this distribution

MIDI

MIDI::Simple

Music::Tempo

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 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.