The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Music::AtonalUtil - Perl extension for atonal music analysis and composition

SYNOPSIS

  use Music::AtonalUtil;
  my $atu = Music::AtonalUtil->new;

Then see below for methods.

DESCRIPTION

This module contains a variety of routines suitable for atonal music composition and analysis. "SEE ALSO" has links to documentation on atonal analysis.

METHODS

By default, a 12-tone system is assumed. Input values are not checked whether they reside inside this space. Most methods accept a pitch set (an array reference consisting of a list of pitch numbers), and most return new array references containing the results of the operation. Some basic sanity checking is done on the input, which may cause the code to croak if something is awry. Elements of the pitch sets are not checked whether they reside inside the 12-tone basis (pitch numbers 0 through 11), so input data may need to be first reduced as follows:

  my $atu = Music::AtonalUtil->new;

  my $pitch_set = [25,18,42,5];
  for my $p (@$pitch_set) { $p %= $atu->scale_degrees }

  say "Result: @$pitch_set";      # Result: 1 6 6 5

Results from the various methods should reside within the 12-tone basis.

new parameter pairs ...

Constructor. The degrees in the scale can be adjusted via:

  Music::AtonalUtil->new(DEG_IN_SCALE => 17);

or some other positive integer greater than one, to use a non-12-tone basis for subsequent method calls. This value can be set or inspected via the scale_degrees call.

circular_permute pitch set

Takes a pitch set, returns an array reference of pitch set references:

  $atu->circular_permute([1,2,3]);   # [[1,2,3],[2,3,1],[3,1,2]]

This is used by the normal_form method, internally. This permutation is identical to inversions in tonal theory, but different from the invert method offered by this module.

complement pitch set

Returns the pitches of the scale degrees not set in the passed pitch set.

  $atu->complement([1,2,3]);    # [0,4,5,6,7,8,9,10,11]
interval_class_content pitch set

Given a pitch set with at least two elements, returns an array reference (and in list context also a hash reference) representing the interval- class vector information. Pitch sets with similar ic content tend to sound the same (see also zrelation).

invariance_matrix pitch set

Returns reference to an array of references that comprise the invarience under Transpose(N)Inversion operations on the given pitch set. (With code, probably easier to iterate through all the T and T(N)I operations than learn how to read this table.)

invert pitch set optional axis

Inverts the given pitch set, by default around the 0 axis, within the degrees in scale. Returns resulting pitch set as an array reference.

normal_form pitch set

Returns the normal form of the passed pitch set, via a "packed from the right" method outlined in the www.mta.ca link, below, so may return different normal forms than the Allen Forte method. There is stub code for the Allen Forte method in this module, though I lack enough information to verify if that code is correct.

pitch2intervalclass pitch

Returns the interval class a given pitch belongs to (0 is 0, 11 maps down to 1, 10 down to 2, ... and 6 is 6 for the standard 12 tone system). Used internally by the interval_class_content method.

prime_form pitch set

Returns the prime form of a given pitch set (via normal_form and various other operations on the passed pitch set).

scale_degrees optional integer

Without arguments, returns the number of scale degrees (12 by default). If passed a positive integer greater than two, sets the scale degrees to that. Note that changing this will change the results from almost all the methods this module offers, and would only be used for calculations involving a subset of the Western 12 tone system, or some exotic scale with more than 12 tones.

transpose pitch set integer

Transposes the given pitch set by the given integer value, returns that result as an array reference.

variances pitch set1 pitch set2

Given two pitch sets, in scalar context returns the shared notes of those two pitch sets as an array reference. In list context, returns the shared notes (intersection), difference, and union all as array references.

zrelation pitch set1 pitch set2

Given two pitch sets, returns true if the two sets share the same interval_class_content, false if not.

SEE ALSO

  • The perlreftut, perldsc, and perllol perldocs to learn more about perl references, as the pitch sets utilize array references and arrays of array references.

  • http://www.mta.ca/faculty/arts-letters/music/pc-set_project/pc-set_new/

  • Musimathics, Vol. 1, p.311-317

  • Music::Chord::Positions for a more tonal module.

AUTHOR

Jeremy Mates, <jmates@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2012 by Jeremy Mates

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.