NAME
Music::Chord::Positions - generate various chord inversions and voicings
SYNOPSIS
use Music::Chord::Positions qw/:all/;
my @inverses = chord_inv([0,4,7]);
my @voicings = chord_pos([0,4,7]);
my @voices = chords2voices(@inverses);
Interface may be subject to change without notice!
DESCRIPTION
Utility methods for generating inversions or chord voicing variations of a given pitch set. A pitch set is an array reference consisting of semitone intervals, for example:
[0, 4, 7] # Major C E G
[0, 3, 7] # minor C D# G
[0, 4, 7, 11] # Major 7th C E G B
Or whatever. The pitch set may be specified manually, or the chord_num method of Music::Chord::Note used to derive a pitch set from a named chord.
use Music::Chord::Positions qw/:all/;
use Music::Chord::Note;
# These both result in the same output from chord_inv()
my @i1 = chord_inv([ 0,3,7 ]);
my @i2 = chord_inv([ Music::Chord::Note->new->chord_num('m') ]);
Using the resulting pitch sets and so forth left as exercise to user; converting the semitones to MIDI::Simple or voices to lilypond compatible output should not be too difficult (see the eg
directory of this module's distribution for sample scripts).
SUBROUTINES
Nothing exported by default. Use the fully qualified path, or import stuff. If OO desired, code something up?
- chord_inv( pitch set reference )
-
Generates inversions of the pitch set, returns a list of pitch sets (list of array references). The order of the results will be 1st inversion, 2nd inversion, etc.
No transposition is performed, so inversions of 9ths or larger may result in a chord in a register above the original. If this is a problem, decrement the semitones in the pitch set by 12 or whatever.
- chord_pos( pitch set reference, list of optional parameters ... )
-
Generate different voicings of a different chord, by default in registers two above the base. Returns list of pitch sets (list of array references) in who knows what order.
Only voicings where the root remains in the root will be considered; chords that do not represent all pitches in the pitch set or chords that double non-root pitches will be excluded. Chords with intervals greater than 19 semitones (octave+fifth) between adjacent pitches will also be excluded, as will transpositions of the same voicing into higher registers.
The chord_pos method can be influenced by the following parameters (default values are shown). Beware that removing restrictions may result in many, many, many different voicings for larger pitch sets.
- interval_adj_max 19
-
Largest interval allowed between two adjacent voices, in semitones.
- no_limit_doublings 0
-
If set and true, allows doublings on all pitches, not just the default of the root pitch.
- no_limit_uniq 0
-
If set and true, disables the unique pitch check. That is, voicings will be allowed with fewer pitches than in the original pitch set.
- octave_count 2
-
How far above the register of the chord to generate voicings in. If set to a large value, the interval_adj_max value may also need to be increased.
- root_any 0
-
If set and true, allows the root pitch of the voicing to be any member of the original pitch set, not just the lowest of that set. Pointless if root_lock set.
- root_lock 0
-
Prevent the root pitch from changing in the generated positions. Defeats root_any option.
- voice_count depends on pitch set passed
-
Use this to customize the number of voices in the different chord voicings. At present, only one extra voice above the number of voices in the pitch set is implemented. Mostly to support SATB for three- pitch chords, in which case the root pitch will be doubled:
chord_pos([0,4,7], voice_count => 4);
The chord voicings allowed by the default options may still not suit certain musical styles; for example, in SATB chorales, the bass alone is allowed to drift far from the other voices, but not both the bass and tenor from the upper voices.
- chords2voices( pitch set list )
-
Accepts a pitch set list (such as returned by chord_pos), transposes vertical chords into horizontal voices. Returns list of voices, highest to lowest.
- scale_deg( )
-
Returns number of degrees in the scale. Should always be 12, unless someone sneaks in support for alternate scale systems in behind my back.
SEE ALSO
Theory of Harmony by Arnold Schoenberg. Whose simple chord voicing exercise prompted this not as simple diversion in coding.
AUTHOR
Jeremy Mates <jmates@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2011 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 or, at your option, any later version of Perl 5 you may have available.