NAME
Music::ModalFunction - Query for modal and scalar musical functions
VERSION
version 0.0504
SYNOPSIS
use Music::ModalFunction ();
# What chords do C major and A minor have in common?
my $m = Music::ModalFunction->new(
mode_note => 'c',
mode => 'ionian',
key_note => 'a',
key => 'aeolian',
);
my $results = $m->pivot_chord_keys; # 7 common chords
# What chords do C major and F♯ (G♭) major have in common?
$m = Music::ModalFunction->new(
mode_note => 'c',
mode => 'ionian',
key_note => 'gb',
key => 'ionian',
);
$results = $m->pivot_chord_keys; # No chords in common!
# What modes can have a Dmaj dominant chord?
$m = Music::ModalFunction->new(
chord_note => 'd',
chord => 'maj',
key_function => 'dominant',
);
$results = $m->chord_key;
# [[ 'chord_key', 'd', 'maj', 'g', 'ionian', 'dominant', 'r_V' ],
# [ 'chord_key', 'd', 'maj', 'g', 'lydian', 'dominant', 'r_V' ]]
# So the answers are G Ionian and G Lydian.
# In what modes can a Gmaj chord function as a subdominant pivot chord?
$m = Music::ModalFunction->new(
chord_note => 'g',
chord => 'maj',
key_function => 'subdominant',
hash_results => 1,
);
$results = $m->pivot_chord_keys;
# [{ method => 'pivot_chord_keys', chord_note => 'g', chord => 'maj', mode_note => 'c', mode => 'ionian', mode_function => 'dominant', mode_roman => 'r_V', key_note => 'd', key => 'dorian', key_function => 'subdominant', key_roman => 'r_IV' },
# { method => 'pivot_chord_keys', chord_note => 'g', chord => 'maj', mode_note => 'c', mode => 'ionian', mode_function => 'dominant', mode_roman => 'r_V', key_note => 'd', key => 'ionian', key_function => 'subdominant', key_roman => 'r_IV' },
# { method => 'pivot_chord_keys', chord_note => 'g', chord => 'maj', mode_note => 'c', mode => 'ionian', mode_function => 'dominant', mode_roman => 'r_V', key_note => 'd', key => 'mixolydian', key_function => 'subdominant', key_roman => 'r_IV' },
# ... ]
# Inspecting all the results, we see that the answers are D Dorian, D Ionian, and D Mixolydian.
# compare non-modal scales
$m = Music::ModalFunction->new(
mode_note => 'c',
mode => 'diminished',
key_note => 'c',
key => 'harmonic_minor',
use_scales => 1,
);
$results = $m->pivot_chord_keys;
# [ 'pivot_chord_keys', 'd', 'dim', 'c', 'diminished', 'flat2', 'r_bii', 'c', 'harmonic_minor', 'supertonic', 'r_ii' ],
# [ 'pivot_chord_keys', 'b', 'dim', 'c', 'diminished', 'leading_tone', 'r_vii', 'c', 'harmonic_minor', 'subtonic', 'r_vii' ],
DESCRIPTION
Music::ModalFunction
allows querying of a musical database of Prolog facts and rules that bind notes, chords, modes/scales, keys and diatonic functionality. In this database, the facts are all called chord_key
and the rules are pivot_chord_keys
and roman_key
.
Wikipedia puts it this way, "A common chord, in the theory of harmony, is a chord that is diatonic to more than one key or, in other words, is common to (shared by) two keys."
To bind a value to a fact or rule argument, declare it in the object constructor. Unbound arguments will return all the possible values that make the query true.
The essential question is, "Can a chord in one key function in a second?" Any parts of this open-ended question may be unbound, thereby resulting in all possible truths.
nb: The names "mode" (and "scale"), and "key" below, are both used to mean modes (or scales) 1 and 2, respectively. But for some reason I chose to use "key" even though that is confusing. Argh! :|
ATTRIBUTES
chord_note, mode_note, key_note
c
, db
, d
, eb
, e
, f
, gb
, g
, ab
, a
, bb
, or b
* Sharps are not used - only flats.
chord
maj
, min
, or dim
mode, key
ionian
, dorian
, phrygian
, lydian
, mixolydian
, aeolian
, or locrian
mode_function, key_function
tonic
, parallel_minor
, flat2
, supertonic
, flat3
, mediant
, subdominant
, flat5
, dominant
, submediant
, leading_tone
, or subtonic
mode_roman, key_roman
r_I
, r_i
, r_bii
, r_II
, r_ii
, r_bIII
, r_III
, r_iii
, r_IV
, r_bV
, r_V
, r_v
, r_VI
, r_vi
, r_vii
, or r_VII
.
hash_results
Return the query results as a list of named hash references.
Default: 0
use_scales
Use alternative scales instead of modes.
Default: 0
scales
augmented
, blues
, diminished
, harmonic_minor
, melodic_minor
, pentatonic
, or pentatonic_minor
verbose
Default: 0
METHODS
new
$m = Music::ModalFunction->new(%args);
Create a new Music::ModalFunction
object.
If defined, argument values will be bound to a variable. Otherwise an unbound variable is used for the queries detailed below.
chord_key
$results = $m->chord_key;
Ask the database a question about what chords are in what keys.
Constructor arguments:
chord_note, chord, key_note, key, key_function, key_roman
Here, chord_note and chord together are the named chord defined within the context of the key_note and key. The chord's function in the key is the key_function and basically indicates the relative scale position. The key_roman argument serves as an indicator of both the chord quality and the position in the scale.
pivot_chord_keys
$results = $m->pivot_chord_keys;
Ask the database a question about what chords share common keys.
Constructor arguments:
chord_note, chord, mode_note, mode, mode_function, mode_roman, key_note, key, key_function, key_roman
roman_key
$results = $m->roman_key;
Ask the database a question about what Roman numeral functional chords share common keys.
Constructor arguments:
mode, mode_roman, key, key_roman
SEE ALSO
The t/01-methods.t and eg/* files in this distribution
https://en.wikipedia.org/wiki/Prolog
https://en.wikipedia.org/wiki/Common_chord_(music)
https://en.wikipedia.org/wiki/Closely_related_key
https://ology.github.io/2023/06/05/querying-a-music-theory-database/ is the write-up about using this module
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2023-2024 by Gene Boggs.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)