NAME
Music::Intervals - Mathematical breakdown of musical intervals
VERSION
version 0.0301
SYNOPSIS
use Music::Intervals;
$m = Music::Intervals->new(
notes => [qw( C E G B )],
size => 3,
chords => 1,
justin => 1,
equalt => 1,
freqs => 1,
interval => 1,
cents => 1,
prime => 1,
);
$m->process;
# Then print Dumper any of:
$m->chord_names;
$m->natural_frequencies;
$m->natural_intervals;
$m->natural_cents;
$m->natural_prime_factors;
$m->eq_tempered_frequencies;
$m->eq_tempered_intervals;
$m->eq_tempered_cents;
# Find known intervals
$name = $m->by_ratio($ratio);
$ratio = $m->by_name($interval_name);
# Show all the known intervals (the "notes" attribute above):
perl -MData::Dumper -MMusic::Intervals::Ratios -e'print Dumper $Music::Intervals::Ratios::ratio'
DESCRIPTION
A Music::Intervals
object shows the mathematical break-down of musical intervals and chords.
This module reveals the "guts" of chords within a given tonality. By guts I mean, the measurements of the notes and the intervals between them. Both just intonation (ratio) and equal temperament (decimal) are handled, with over 400 intervals, too!
METHODS
new()
$x = Music::Intervals->new(%arguments);
Attributes and defaults
- cents: 0 - divisions of the octave
- chords: 0 - chord names
- equalt: 0 - equal temperament
- freqs: 0 - frequencies
- interval: 0 - note intervals
- justin: 0 - just intonation
- prime: 0 - prime factorization
- rootless: 0 - show chord names with no root
- octave: 4 - use the fourth octave
- concert: 440 - concert pitch
- size: 3 - chord size
- tonic: C - root of the computations
-
* Currently (and for the foreseeable future) this will remain the only value that produces sane results.
- semitones: 12 - number of notes in the scale
- temper: semitones * 100 / log(2) - physical distance between notes
- notes: [ C D E F G A B ] - actual notes to use in the computation
-
The list of notes may be any of the keys in the Music::Intervals::Ratios
ratio
hashref. This is very very long and contains useful intervals such as those of the common scale and even the Pythagorean intervals, too.A few examples:
* [qw( C E G )] * [qw( C D D# )] * [qw( C D Eb )] * [qw( C D D# Eb E E# Fb F )] * [qw( C 11h 7h )] * [qw( C pM3 pM7 )]
For natural_intervals() this example produces the following:
'C pM3 pM7' => { 'C pM3' => { '81/64' => 'Pythagorean major third' }, 'C pM7' => { '243/128' => 'Pythagorean major seventh' }, 'pM3 pM7' => { '3/2' => 'perfect fifth' } }
For eq_tempered_cents() this is:
'C pM3 pM7' => { 'pM3 pM7' => '701.955000865387', 'C pM7' => '-8527.85665190266', 'C pM3' => '-9229.81165276804' }
Note that case matters for interval names. For example, "M" means major and "m" means minor.
by_name()
$ratio = $m->by_name('C');
# { ratio => '1/1', name => 'unison, perfect prime, tonic' }
Return a known ratio or undef.
by_ratio()
$name = $m->by_ratio($ratio);
Return a known ratio name or undef.
SEE ALSO
For the time being, you will need to look at the source of Music::Intervals::Ratios
for the note and interval names.
https://github.com/ology/Music/blob/master/intervals
http://en.wikipedia.org/wiki/List_of_musical_intervals
http://en.wikipedia.org/wiki/Equal_temperament
http://en.wikipedia.org/wiki/Just_intonation
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 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.