NAME
Music::Cadence - Provide musical cadence chords
VERSION
version 0.0700
SYNOPSIS
use Music::Cadence;
my $mc = Music::Cadence->new;
my $chords = $mc->cadence( type => 'perfect' );
# [['G','B','D'], ['C','E','G','C']]
$mc = Music::Cadence->new( octave => 4 );
$chords = $mc->cadence( type => 'perfect' );
# [['G4','B4','D4'], ['C4','E4','G4','C5']]
$chords = $mc->cadence(
type => 'half',
leading => 2,
octave => 0,
); # [['D','F','A'], ['G','B','D']]
$mc = Music::Cadence->new(
key => 'C#',
octave => 5,
);
$chords = $mc->cadence( type => 'perfect' );
# [['G#5','C5','D#5'], ['C#5','F5','G#5','C#6']]
$mc = Music::Cadence->new(
key => 'C#',
octave => 5,
format => 'midi',
);
$chords = $mc->cadence( type => 'perfect' );
# [['Gs5','C5','Ds5'], ['Cs5','F5','Gs5','Cs6']]
$mc = Music::Cadence->new(
key => 'C',
octave => 4,
format => 'midinum',
);
$chords = $mc->cadence( type => 'perfect' );
# [[67,71,62], [60,64,67,72]]
DESCRIPTION
Music::Cadence
provides musical cadence chords.
* This module is a naive implementation of the actual theory. YMMV. Patches welcome.
ATTRIBUTES
key
The key or tonal center to use. Default: C
Examples: G#
, Eb
scale
The scale to use. Default: major
Supported scales are:
ionian / major
dorian
phrygian
lydian
mixolydian
aeolian / minor
locrian
octave
The octave to either append to named chord notes (for midi
or isobase
format) or to determine the correct midinum
note number.
Default: 0
If the format is midi
or isobase
, setting this to 0
means "do not append."
The midinum
range for this attribute is from -1
to 10
.
format
The output format to use. Default: isobase
(i.e. "bare note names")
If midi
, convert sharp #
to s
and flat b
to f
after chord generation.
If midinum
, convert notes to their numerical MIDI equivalents.
METHODS
new
$mc = Music::Cadence->new; # Use defaults
$mc = Music::Cadence->new( # Override defaults
key => $key,
scale => $scale,
octave => $octave,
format => $format,
);
Create a new Music::Cadence
object.
cadence
$chords = $mc->cadence; # Use defaults
$chords = $mc->cadence( # Override defaults
key => $key, # Default: C
scale => $scale, # Default: major
octave => $octave, # Default: 0
type => $type, # Default: perfect
leading => $leading, # Default: 1
variation => $variation, # Default: 1
);
Return an array reference of the chords of the cadence type based on the given key and scale name.
The variation applies to the deceptive
cadence and determines the final chord. If given as 1
, the vi
chord is used. If given as 2
, the IV
chord is used.
Supported cadences are:
perfect
half
plagal
deceptive
The leading chord is a number (1-7) for each diatonic scale chord to use for the first half
cadence chord. For the key of C major
this is:
CM: 1
Dm: 2
Em: 3
FM: 4
GM: 5
Am: 6
Bo: 7
SEE ALSO
The eg/cadence and t/01-methods.t files in this distribution.
https://en.wikipedia.org/wiki/Cadence
https://www.musictheoryacademy.com/how-to-read-sheet-music/cadences/
TO DO
Evaded cadence
Imperfect cadences
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2019 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.