Last active
October 12, 2023 06:12
-
-
Save ology/61969e844959d94b6a67dee71df91a6e to your computer and use it in GitHub Desktop.
ology's version of octatonic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package ChordExtra; | |
use Role::Tiny; | |
# chord intervals as relative to the previous note in the chord | |
sub chord_intervals { | |
my ($self, $name) = @_; | |
my @c = $self->chord_num($name); | |
@c = reverse map { $_ == 0 ? $c[$_] : $c[$_] - $c[$_ - 1] } reverse 0 .. $#c; | |
return @c; | |
} | |
package main; | |
use Array::Circular; | |
use Role::Tiny (); | |
use Music::Scales qw(get_scale_nums); | |
use Music::Chord::Note; | |
Role::Tiny->apply_roles_to_package('Music::Chord::Note', 'ChordExtra'); | |
my $flavor = shift || 'dim7'; | |
my $scale_name = shift || 'chromatic'; | |
my %notes = ( | |
1 => 'c', 2 => 'cis', 3 => 'd', 4 => 'ees', 5 => 'e', 6 => 'f', | |
7 => 'fis', 8 => 'g', 9 => 'gis', 10 => 'a', 11 => 'bes', 12 => 'b' | |
); | |
my $mcn = Music::Chord::Note->new; | |
my @chord = $mcn->chord_intervals($flavor); | |
printf "%s chord intervals: %s = %s\n", ucfirst($scale_name), $flavor, "@chord"; | |
my @scale_notes = get_scale_nums($scale_name); | |
my $nums = Array::Circular->new(map { $_ + 1 } @scale_notes); | |
for my $root (0 .. $#scale_notes) { | |
$nums->reset; | |
$nums->next($root); | |
my @top = map { $notes{ $nums->next($_) } } @chord; | |
$nums->reset; | |
$nums->next($root); | |
$nums->prev(1); | |
my @lower = map { $notes{ $nums->next($_) } } @chord; | |
my @scale = (); | |
for my $n (0 .. $#top) { | |
push @scale, $lower[$n], $top[$n]; | |
} | |
for my $n (0 .. $#scale) { | |
print "$scale[$n] "; | |
print '|| ' if $n eq 3; | |
print "\\break \n" if $n eq 7; | |
} | |
$nums->reset; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chromatic chord intervals: dim7 = 0 3 3 3 | |
b c d ees || f fis gis a \break | |
c cis ees e || fis g a bes \break | |
cis d e f || g gis bes b \break | |
d ees f fis || gis a b c \break | |
ees e fis g || a bes c cis \break | |
e f g gis || bes b cis d \break | |
f fis gis a || b c d ees \break | |
fis g a bes || c cis ees e \break | |
g gis bes b || cis d e f \break | |
gis a b c || d ees f fis \break | |
a bes c cis || ees e fis g \break | |
bes b cis d || e f g gis \break | |
~~~ | |
Major chord intervals: 7 = 0 4 3 3 | |
b c f g || b c e f \break | |
c d g a || c d f g \break | |
d e a b || d e g a \break | |
e f b c || e f a b \break | |
f g c d || f g b c \break | |
g a d e || g a c d \break | |
a b e f || a b d e \break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment