MIDI::Praxis::Variation - Variation techniques used in music composition
version 0.0600
use MIDI::Praxis::Variation ':all'; my @notes = qw(C5 E5 G5); my @dura = qw(qn qn); my @x = augmentation(@dura); @x = diminution(@dura); my $x = dur('qn'); @x = inversion('B4', @notes); $x = note_name_to_number('C5'); $x = note2num('C5'); # Alias for note_name_to_number() @x = ntup(2, @notes); @x = original(@notes); @x = notes2nums(@notes); # Alias for original() $x = raugmentation(1.5, @dura); $x = rdiminution(1.5, @dura); @x = retrograde(@notes); @x = retrograde_inversion('B4', @notes); @x = transposition(@notes); $x = tye(@dura); $x = tie_durations(@dura); # Alias for tye()
Melodic variation techniques, as implemented here, expect MIDI::Simple style note names or durations as input. They return an array of MIDI note numbers or duration values.
$x = note_name_to_number($note_name); $x = note2num($note_name);
Map a single note name to a MIDI note number.
Returns: An equivalent MIDI note number or -1 if not known.
@x = original(@array); @x = notes2nums(@array);
Map note names to MIDI note numbers.
Returns: An equivalent array of MIDI note numbers.
Argument:
@array - An array of note names.
@x = retrograde(@array);
Form the retrograde of an array of note names.
Returns: The retrograde equivalent array as MIDI note numbers.
@x = transposition($distance, @array);
Form the transposition of an array of notes.
Returns: MIDI note numbers equivalent by transposition from an array of note names OR MIDI note numbers.
Arguments:
$distance - An integer giving distance and direction. @array - An array of note names OR MIDI note numbers.
Expects to see an integer followed an array of MIDI::Simple style note names OR MIDI note numbers. The integer specifies the direction and distance of transposition. For example, 8 indicates 8 semitones up while -7 asks for 7 semitones down. The array argument specifies the notes to be transposed.
@x = inversion($axis, @array);
Form the inversion of an array of notes.
Returns: MIDI note numbers equivalent by inversion to an array of note names.
$axis - A note to use as the axis of this inversion. @array - An array of note names.
Expects to see a MIDI::Simple style note name followed by an array of such names. These give the axis of inversion and the notes to be inverted.
@x = retrograde_inversion($axis, @array);
Form the retrograde inversion of an array of notes.
Returns: MIDI note numbers equivalent by retrograde inversion to an array of note names.
Inverts about the supplied $axis.
$x = dur($dur_or_len);
Compute duration of a note.
Returns: Duration as an integer.
$dur_or_len - A string consisting of a MIDI::Simple style numeric duration spec (e.g. d48, or d60) or length spec (e.g. qn or dhn)
Note that string input is expected and integer output is returned.
$x = tye(@dur_or_len); $x = tie_durations(@dur_or_len);
Compute the sum of the durations of notes. As with a tie in music notation. This odd spelling is used to avoid conflict with the perl reserved word tie.
@dur_or_len - A list of strings consisting of MIDI::Simple style numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn or dhn)
$x = raugmentation($ratio, @dur_or_len);
Augment duration of notes, multiplying them by $ratio.
$ratio - An integer multiplier @dur_or_len - A list of MIDI::Simple style numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn or dhn)
$x = rdiminution($ratio, @dur_or_len);
Diminish duration of notes, dividing them by $ratio.
$ratio - An integer divisor @dur_or_len - A list of MIDI::Simple style numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn or dhn)
@x = augmentation(@dur_or_len);
Augment duration of notes multiplying them by 2, (i.e. double).
@x = diminution(@dur_or_len);
Diminish durations of notes dividing them by 2, (i.e. halve).
The returned integer is the approximate result of dividing the original durations by 2.
@x = ntup($nelem, @subject);
Catalog tuples of length $nelem in @subject.
Returns: An array of tuples of length $nelem.
$nelem - Number of elements in each tuple @subject - Subject array to be scanned for tuples
Scan begins with the 0th element of @subject looking for a tuple of length $nelem. Scan advances by one until it has found all tuples of length $nelem. For example: given the array @ar = qw(1 2 3 4) and $nelem = 2, then ntup(2, @ar) would return qw(1 2 2 3 3 4). Note that if $nelem equals -1, 0, or a value greater than the size of @subject, this function will return ();
@ar = qw(1 2 3 4)
$nelem = 2
ntup(2, @ar)
qw(1 2 2 3 3 4)
()
The eg/* and t/01-functions.t files in this distribution
MIDI::Simple
Gene Boggs <gene@cpan.org>
Craig Bourne <cbourne@cpan.org>
This software is copyright (c) 2020 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 MIDI::Praxis::Variation, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MIDI::Praxis::Variation
CPAN shell
perl -MCPAN -e shell install MIDI::Praxis::Variation
For more information on module installation, please visit the detailed CPAN module installation guide.