NAME

MIDI::Praxis::Variation - Variation techniques used in music composition

VERSION

version 0.0606

SYNOPSIS

  use MIDI::Praxis::Variation ':all';

  # Or import individually by function name:
  # use MIDI::Praxis::Variation qw(augmentation diminution etc);

  my @notes = qw(C5 E5 G5);
  my @dura = qw(qn qn);

  my @x = augmentation(@dura);
  @x = diminution(@dura);
  my $y = dur('qn');
  @x = inversion('B4', @notes);
  $y = note2num('C5');
  @x = ntup(2, @notes);
  @x = notes2nums(@notes);
  $y = raugmentation(1.5, @dura);
  $y = rdiminution(1.5, @dura);
  @x = retrograde(@notes);
  @x = retrograde_inversion('B4', @notes);
  @x = transposition(-12, @notes); # Transpose an octave down
  $y = tie_durations(@dura);

DESCRIPTION

Melodic variation techniques, as implemented here, expect MIDI::Simple style note names or durations as input. They return MIDI note numbers or duration values in ticks (where one quarter note = 96 ticks).

FUNCTIONS

note_name_to_number, note2num

  $x = note_name_to_number($note_name);
  $x = note2num($note_name);

Map a single note name to an equivalent MIDI note number (or -1 if not known).

original, notes2nums

  @x = original(@array);
  @x = notes2nums(@array);

Map a list of note names to MIDI note numbers.

retrograde

  @x = retrograde(@array);

Form the retrograde of an array of note names as MIDI note numbers.

transposition

  @x = transposition($distance, @array);

Form the transposition of an array of notes or MIDI note numbers.

Arguments:

  $distance - An integer giving distance and direction.

  @array    - An array of note names OR MIDI note numbers.

For example, 8 indicates 8 semitones up while -7 asks for 7 semitones down.

inversion

  @x = inversion($axis, @array);

Form the inversion of an array of notes.

Arguments:

  $axis  - A note to use as the axis of this inversion.

  @array - An array of note names.

Expects to see a MIDI note name followed by an array of such names. These give the axis of inversion and the notes to be inverted.

retrograde_inversion

  @x = retrograde_inversion($axis, @array);

Form the retrograde inversion of an array of notes.

Arguments:

  $axis  - A note to use as the axis of this inversion.

  @array - An array of note names.

Inverts about the supplied axis.

dur

  $x = dur($dur_or_len);

Compute duration of a note in MIDI ticks.

Arguments:

  $dur_or_len - A string consisting of a MIDI tick numeric
  duration spec (e.g. d48, or d60) or length spec (e.g. qn or dhn)

tye, tie_durations

  $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. (The odd spelling is used to avoid conflict with the perl reserved word tie.)

Arguments:

  @dur_or_len - A list of strings consisting of MIDI tick
  numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn
  or dhn)

raugmentation

  $x = raugmentation($ratio, @dur_or_len);

Augment duration of notes, multiplying them by $ratio.

Arguments:

  $ratio - Multiplier

  @dur_or_len - A list of MIDI tick numeric duration specs
  (e.g. d48, or d60) or length specs (e.g. qn or dhn)

rdiminution

  $x = rdiminution($ratio, @dur_or_len);

Diminish duration of notes, dividing them by $ratio.

Arguments:

  $ratio - Divisor

  @dur_or_len - A list of MIDI tick numeric duration specs
  (e.g. d48, or d60) or length specs (e.g. qn or dhn)

augmentation

  @x = augmentation(@dur_or_len);

Augment duration of notes multiplying them by 2, (i.e. double) and return each in an array reference.

Arguments:

  @dur_or_len - A list of strings consisting of MIDI tick
  numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn
  or dhn)

diminution

  @x = diminution(@dur_or_len);

Diminish durations of notes dividing them by 2, (i.e. halve) and return each in an array reference.

Arguments:

  @dur_or_len - A list of strings consisting of MIDI tick
  numeric duration specs (e.g. d48, or d60) or length specs (e.g. qn
  or dhn)

ntup

  @x = ntup($nelem, @subject);

Catalog and return tuples of length $nelem in @subject.

Arguments:

  $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 ();

SEE ALSO

The eg/* and t/01-functions.t files in this distribution

Exporter

MIDI::Simple

MAINTAINER

Gene Boggs <gene@cpan.org>

AUTHOR

Craig Bourne <cbourne@cpan.org>

COPYRIGHT AND LICENSE

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.