NAME

Music::ToRoman - Convert notes and chords to Roman numeral notation

VERSION

version 0.1902

SYNOPSIS

use Music::ToRoman;

my $mtr = Music::ToRoman->new(
  scale_note => 'A',
  scale_name => 'minor',
);

my $roman = $mtr->parse('Am');  # i (minor)
$roman = $mtr->parse('Bdim');   # iio (diminished)
$roman = $mtr->parse('B dim');  # ii o
$roman = $mtr->parse('Bo');     # iio
$roman = $mtr->parse('Bø');     # ii7b5 (half-diminished)
$roman = $mtr->parse('Bb');     # bII (flat-two major)
$roman = $mtr->parse('CM');     # III (major)
$roman = $mtr->parse('C');      # III
$roman = $mtr->parse('Cm9/G');  # iii9/VII (minor-nine with seven bass)
$roman = $mtr->parse('Cm9/Bb'); # iii9/bii (minor-nine with flat-two bass)
$roman = $mtr->parse('Dsus4');  # IVsus4 (suspended)
$roman = $mtr->parse('D sus4'); # IV sus4
$roman = $mtr->parse('D maj7'); # IV maj7 (major seventh)
$roman = $mtr->parse('DMaj7');  # IVmaj7
$roman = $mtr->parse('D△7');    # IVmaj7
$roman = $mtr->parse('E7');     # V7 (dominant seventh)
$roman = $mtr->parse('Fmin7');  # vimin7 (minor seventh)
$roman = $mtr->parse('G+');     # VII+ (augmented)

$mtr = Music::ToRoman->new(
  scale_note => 'A',
  scale_name => 'dorian',
  chords     => 0,
);

$roman = $mtr->parse('A');      # i
$roman = $mtr->parse('B');      # ii
$roman = $mtr->parse('C');      # III
$roman = $mtr->parse('D');      # IV
$roman = $mtr->parse('E');      # v
$roman = $mtr->parse('F#');     # vi
$roman = $mtr->parse('G');      # VII
$roman = $mtr->parse('Amin7');  # imin7
$roman = $mtr->parse('Bo');     # iio
$roman = $mtr->parse('CMaj7');  # IIImaj7
$roman = $mtr->parse('D7');     # IV7
$roman = $mtr->parse('Em');     # v

my @mode = $mtr->get_scale_mode;
my @chords = $mtr->get_scale_chords;

DESCRIPTION

Music::ToRoman converts named chords to Roman numeral notation. Also individual "chordless" notes may be converted given a diatonic mode scale_name.

ATTRIBUTES

scale_note

Note on which the scale is based. Default: C

This must be an uppercase letter from A-G either alone or followed by # or b.

Note that the keys of A# and D# are better represented by Gb and Eb respectively, because the scales contain notes with double sharps. Double flat scales are not supported.

scale_name

Name of the scale. Default: major

The diatonic mode names supported are:

ionian / major
dorian
phrygian
lydian
mixolydian
aeolian / minor
locrian

major_tonic

Note on which the major scale is based. Default: 'C'

This must be an uppercase letter from A-G and followed by a # or b.

This attribute is required when the scale_note is set to a double-sharp, and the scale_name is not major (or ionian).

Again, double flat scales are not supported.

chords

Are we given chords to parse with major (M) or minor (m/o/dim/ø) designations?

Default: 1

If this is set to 0, single notes can be used to return the major/minor Roman numeral for the given diatonic mode scale_name.

verbose

Show the progress of the parse method.

Default: 0

METHODS

new

$mtr = Music::ToRoman->new(
  scale_note  => $note,
  scale_name  => $name,
  major_tonic => $tonic,
  chords      => $chords,
  verbose     => $verbose,
);

Create a new Music::ToRoman object.

parse

$roman = $mtr->parse($chord);

Parse a note or chord name into a Roman numeral representation.

For instance, the Roman numeral representation for the aeolian (or minor) mode is: i ii III iv v VI VII - where the case indicates the major/minor status of the given chord.

This can be overridden by parsing say, B7 (B dominant seventh), thus producing II7.

If a major/minor chord designation is not provided, M major is assumed.

If the chords attribute is set to 0, the scale_name is used to figure out the correct Roman numeral representation.

A diminished chord may be given as either o or dim. Half-diminished (m7b5) chords can be given as ø. A decoration of may be given for say the △7 major seventh chord.

Parsing a double flatted chord will only work in select cases.

get_scale_mode

@mode = $mtr->get_scale_mode;

Return the Roman representation of the mode.

get_scale_chords

@mode = $mtr->get_scale_chords;

Return the chords of the mode.

SEE ALSO

List::MoreUtils

Moo

Music::Note

Music::Scales

https://en.wikipedia.org/wiki/Roman_numeral_analysis

For example usage, check out the test files t/*-methods.t in this distribution. Also see eg/roman and eg/basslines in Music::BachChoralHarmony.

App::MusicTools vov is the reverse of this module, and is significantly powerful.

THANK YOU

Dan Book (DBOOK) for the list rotation logic

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 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.