Music::Duration - Add 32nd, 64th, 128th and tuplet durations to MIDI-Perl
version 0.0901
use Music::Duration; # 5 divisions in place of an eighth note triplet: Music::Duration::tuplet( 'ten', 'Z', 5 ); # Add an arbitrary duration: Music::Duration::add_duration( phi => 1.618 ); # Now inspect the known lengths: my %x = %MIDI::Simple::Length; print Dumper [ map { "$_ => $x{$_}" } sort { $x{$a} <=> $x{$b} } keys %x ]; # Use the new durations in a composition: my $black_page = MIDI::Simple->new_score(); $black_page->Channel(9); # ... $black_page->n( 'Zten', 38 ) for 1 .. 5; $black_page->n( 'phi', 38 ) for 1 .. 4;
This module adds 32nd, 64th, and 128th notes, triplet and dotted divisions to %MIDI::Simple::Length. It also computes and inserts a fractional note division of an existing duration. Additionally, this module will insert any named note duration to the length hash.
%MIDI::Simple::Length
32nd durations added:
xn: thirty-second note dxn: dotted thirty-second note ddxn: double dotted thirty-second note txn: thirty-second note triplet
64th durations added:
yn: sixty-fourth note dyn: dotted sixty-fourth note ddyn: double dotted sixty-fourth note tyn: sixty-fourth note triplet
128th durations added:
zn: 128th note dzn: dotted 128th note ddzn: double dotted 128th note tzn: 128th note triplet
Music::Duration::tuplet( 'qn', 'Z', 5 ); # $score->n( 'Zqn', ... ); Music::Duration::tuplet( 'wn', 'Z', 7 ); # $score->n( 'Zwn', ... );
Add a fractional division to the MIDI::Simple Length hash for a given name and duration.
Length
Musically, this creates a series of notes in place of the given duration.
A triplet is a "3-tuplet."
So in the first example, instead of a quarter note, we instead play 5 beats - a 5-tuple. In the second, instead of a whole note (of four beats), we instead play 7 beats.
Music::Duration::add_duration( $name => $duration );
This function just adds a named duration length to %MIDI::Simple::Length so that it can be used to add notes or rests to the score.
The code in t/01-functions.t and eg/* in this distribution
The %Length hash in MIDI::Simple
%Length
https://www.scribd.com/doc/26974069/Frank-Zappa-The-Black-Page-1-Melody-Score
https://en.wikipedia.org/wiki/Tuplet
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2022 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.
To install Music::Duration, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Music::Duration
CPAN shell
perl -MCPAN -e shell install Music::Duration
For more information on module installation, please visit the detailed CPAN module installation guide.