Tuesday, January 24, 2017

JFugue Jython Example 5. Introduction to Chord Progressions

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



# JFugue 5. Introduction to Chord Progressions

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

'''
It's easy to create a Chord Progression in JFugue.
You can then play it, or you can see the notes that
comprise the any of the chords in the progression.
'''

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

cp = ChordProgression("I IV V")
chords = cp.setKey("C").getChords()
for chord in chords:
    print("Chord %s has these notes: " % chord)
    notes = chord.getNotes()
    for note in notes:
        print("%s " % note,end = "\t")
    print("")

player = Player()
player.play(cp)

For each of the 3 chords, the 3 notes are shown, with tabs, in between. For the notes, the end parameter is changed from default newline, to tab character.


No comments:

Post a Comment