-
Notifications
You must be signed in to change notification settings - Fork 5
/
modal-chords
44 lines (33 loc) · 1.11 KB
/
modal-chords
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env perl
use strict;
use warnings;
# Play the chords of the given scale mode.
use Data::Dumper::Compact qw(ddc);
use MIDI::Util qw(setup_score midi_format);
use Music::Chord::Note ();
use Music::Scales qw(get_scale_notes);
use Music::ToRoman ();
my $note = shift || 'C';
my $mode = shift || 'ionian'; # ionian, dorian, phrygian, lydian, mixolydian, aeolian, locrian
my $octave = shift || 4;
# Get a chord map of major/minor/diminished designations
my $mtr = Music::ToRoman->new(
scale_note => $note,
scale_name => $mode,
);
my @scale_chords = $mtr->get_scale_chords;
my @scale = get_scale_notes($note, $mode);
my @chords = map { $scale[$_] . $scale_chords[$_] } 0 .. $#scale_chords;
my $score = setup_score();
my $mcn = Music::Chord::Note->new;
# Add each chord to the score
for my $c (@chords) {
my @chord = $mcn->chord_with_octave($c, $octave);
print ddc(\@chord);
$score->n('wn', midi_format(@chord));
}
# Add a resolving chord to the score
my @chord = $mcn->chord_with_octave($chords[0], $octave);
print ddc(\@chord);
$score->n('wn', midi_format(@chord));
$score->write_score("$0.mid");