Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Music: Calculate Chord Progression Triads

by jimX11 (Friar)
on Jan 31, 2007 at 14:28 UTC ( [id://597535]=note: print w/replies, xml ) Need Help??


in reply to Music: Calculate Chord Progression Triads

Blues in C:C C C C F F C C G G C C

Ok, I blew the 7ths. Eh.

So many 3 chord songs, so little refactoring time...
Produced by:
use strict; sub build_scale { # The parameter is the key of the scale # as in "what key is a bicycle in? B flat" my $key = shift; my @notes = ('C', 'C#/Db', 'D', 'D#/Eb', 'E', 'F', 'F#/Gb', 'G', 'G#/Ab', 'A', 'A#/Bb', 'B'); my @intervals = (0, 2, 4, 5, 7, 9, 11, 12); # Create a scale based on the intervals in a major scale my @scale = map {$notes[($key + $intervals[$_]) % 12]} (0..7); return @scale; } sub blues_in { my $key = shift; my @scale = build_scale($key); #my @blues = qw( 1 1 1 1 4 4 1 1 5 4 1 1); my @blues = qw( 0 0 0 0 3 3 0 0 4 4 0 0); print "Blues in $scale[0]:", join (" ", map {$scale[$_]} @blues),"\n"; } sub chord_progression { my @scale = build_scale( shift); # Create triads. Increment each note within the scale. # All notes in the chord progression fall within the # major scale. my ($root, $third, $fifth) = (0, 2, 4); my @name = ('Maj', 'min', 'min', 'Maj', 'Maj', 'min', 'Dim', 'Maj' +); for (0..7) { printf "%6s %3s: %6s, %6s, %6s\n", $scale[$root], $name[$_], $scale[$root], $scale[$third], $scale[$fifth]; $root++; $third++; $fifth++; $root %= 7; $third %= 7; $fifth %= 7; } print "\n"; } # Call the subroutine for each note in the scale for (0..11) { # chord_progression($_); blues_in($_); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-19 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found