Tuesday, January 24, 2017

JFugue Jython Example 6. Advanced Chord Progressions

This is Example 6 from JFugue website (JFugue Examples) in Jython.



# JFugue 6. Advanced Chord Progressions

'''
You can do some pretty cool things with chord
progressions. The methods below use $ to indicate
an index into either the chord progression (in
which case, the index points to the nth chord),
or a specific chord (in which case the index
points to the nth note of the chord). Underscore
means "the whole thing". If you change the indexes,
make sure you don't introduce an
ArrayOutOfBoundsException (for example, a major
chord has only three notes, so trying to get the
4th index, $3 (remember that this is zero-based),
would cause an error).
'''

import sys
sys.path.append("C:/jfugue-5.0.7.jar")

from org.jfugue.player import Player
from org.jfugue.theory import ChordProgression

cp = ChordProgression("I IV V")
player = Player()
p1 = "$0q $1q $2q Rq"
p2 = "$0q $0q $0q $0q $1q $1q $2q $0q"
p3a = "$0 $0 $0 $0 $1 $1 $2 $0"
p3b = "V0 $0s $1s $2s Rs V1 $_q"
player.play(cp.eachChordAs(p1))
player.play(cp.allChordsAs(p2))
player.play(cp.allChordsAs(p3a).eachChordAs(p3b))

No comments:

Post a Comment