from abjad import *
%load_ext abjad.ext.ipython
from abjad.demos import desordre
pitches = [1,2,3]
notes = scoretools.make_notes(pitches, [(1, 8)])
beam = Beam()
attach(beam, notes)
slur = Slur()
attach(slur, notes)
dynamic = Dynamic('f')
attach(dynamic, notes[0])
dynamic = Dynamic('p')
attach(dynamic, notes[1])
voice_lower = Voice(notes)
voice_lower.name = 'rh_lower'
command = indicatortools.LilyPondCommand('voiceTwo')
attach(command, voice_lower)
import math
n = int(math.ceil(len(pitches) / 2.))
chord = Chord([pitches[0], pitches[0] + 12], (n, 8))
articulation = Articulation('>')
attach(articulation, chord)
voice_higher = Voice([chord])
voice_higher.name = 'rh_higher'
command = indicatortools.LilyPondCommand('voiceOne')
attach(command, voice_higher)
container = Container([voice_lower, voice_higher])
container.is_simultaneous = True
cell = Staff([container])
show(cell)
def make_desordre_cell(pitches):
'''The function constructs and returns a *Désordre cell*.
`pitches` is a list of numbers or, more generally, pitch tokens.
'''
notes = [scoretools.Note(pitch, (1, 8)) for pitch in pitches]
beam = spannertools.Beam()
attach(beam, notes)
slur = spannertools.Slur()
attach(slur, notes)
clef = indicatortools.Dynamic('f')
attach(clef, notes[0])
dynamic = indicatortools.Dynamic('p')
attach(dynamic, notes[1])
# make the lower voice
lower_voice = scoretools.Voice(notes)
lower_voice.name = 'RH Lower Voice'
command = indicatortools.LilyPondCommand('voiceTwo')
attach(command, lower_voice)
n = int(math.ceil(len(pitches) / 2.))
chord = scoretools.Chord([pitches[0], pitches[0] + 12], (n, 8))
articulation = indicatortools.Articulation('>')
attach(articulation, chord)
# make the upper voice
upper_voice = scoretools.Voice([chord])
upper_voice.name = 'RH Upper Voice'
command = indicatortools.LilyPondCommand('voiceOne')
attach(command, upper_voice)
# combine them together
container = scoretools.Container([lower_voice, upper_voice])
container.is_simultaneous = True
# make all 1/8 beats breakable
for leaf in lower_voice.select_leaves()[:-1]:
bar_line = indicatortools.BarLine('')
attach(bar_line, leaf)
return container
def make_desordre_measure(pitches):
'''Makes a measure composed of *Désordre cells*.
`pitches` is a list of lists of number (e.g., [[1, 2, 3], [2, 3, 4]])
The function returns a measure.
'''
for sequence in pitches:
container = make_desordre_cell(sequence)
time_signature = inspect_(container).get_duration()
time_signature = mathtools.NonreducedFraction(time_signature)
time_signature = time_signature.with_denominator(8)
measure = scoretools.Measure(time_signature, [container])
return measure
pitches = [[0, 4, 7], [0, 4, 7, 9], [4, 7, 9, 11]]
measure = make_desordre_measure(pitches)
staff = Staff([measure])
show(staff)
def make_desordre_staff(pitches):
r'''Makes Désordre staff.
'''
staff = scoretools.Staff()
for sequence in pitches:
measure = make_desordre_measure(sequence)
staff.append(measure)
return staff
pitches = [[[-1, 4, 5], [-1, 4, 5, 7, 9]], [[0, 7, 9], [-1, 4, 5, 7, 9]]]
staff = make_desordre_staff(pitches)
show(staff)
def make_desordre_score(pitches):
'''Returns a complete piano staff with Ligeti music.
'''
assert len(pitches) == 2
piano = instrumenttools.Piano([])
staff_group = StaffGroup(context_name='PianoStaff', name='Piano')
attach(piano, staff_group)
# build the music
for hand in pitches:
staff = make_desordre_staff(hand)
staff_group.append(staff)
# set clef and key signature to left hand staff
clef = indicatortools.Clef('bass')
attach(clef, staff_group[1])
key_signature = KeySignature('b', 'major')
attach(key_signature, staff_group[1])
# wrap the piano staff in a score
score = scoretools.Score([staff_group])
return score
top = [
[[-1, 4, 5], [-1, 4, 5, 7, 9]],
[[0, 7, 9], [-1, 4, 5, 7, 9]],
[[2, 4, 5, 7, 9], [0, 5, 7]],
[[-3, -1, 0, 2, 4, 5, 7]],
[[-3, 2, 4], [-3, 2, 4, 5, 7]],
[[2, 5, 7], [-3, 9, 11, 12, 14]],
[[4, 5, 7, 9, 11], [2, 4, 5]],
[[-5, 4, 5, 7, 9, 11, 12]],
[[2, 9, 11], [2, 9, 11, 12, 14]],
]
bottom = [
[[-9, -4, -2], [-9, -4, -2, 1, 3]],
[[-6, -2, 1], [-9, -4, -2, 1, 3]],
[[-4, -2, 1, 3, 6], [-4, -2, 1]],
[[-9, -6, -4, -2, 1, 3, 6, 1]],
[[-6, -2, 1], [-6, -2, 1, 3, -2]],
[[-4, 1, 3], [-6, 3, 6, -6, -4]],
[[-14, -11, -9, -6, -4], [-14, -11, -9]],
[[-11, -2, 1, -6, -4, -2, 1, 3]],
[[-6, 1, 3], [-6, -4, -2, 1, 3]],
]
score = make_desordre_score([top, bottom])
from abjad.tools import documentationtools
lilypond_file = documentationtools.make_ligeti_example_lilypond_file(score)
show(lilypond_file)