Tuesday, January 24, 2017

JFugue Jython Example 4. Introduction to Patterns, Part 2

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



# JFugue 4. Introduction to Patterns, Part 2

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

'''
Voice and instruments for a pattern can also be set through the API.
In JFugue, methods that would normally return 'void' instead return
the object itself, which allows you do chain commands together, as seen
in this example.
'''

from org.jfugue.player import Player
from org.jfugue.pattern import Pattern

p1 = Pattern("Eq Ch. | Eq Ch. | Dq Eq Dq Cq").setVoice(0)
p1 = p1.setInstrument("Piano")
p2 = Pattern("Rw     | Rw     | GmajQQQ  CmajQ").setVoice(1)
p2 = p2.setInstrument("Flute")
player = Player()
player.play(p1, p2)

No comments:

Post a Comment