Skip to content

Commit

Permalink
(#641) Removed last remaining _repr_specification references.
Browse files Browse the repository at this point in the history
This closes with #641.
  • Loading branch information
trevorbaca committed Jul 31, 2017
1 parent 684598f commit 514ec35
Show file tree
Hide file tree
Showing 41 changed files with 511 additions and 603 deletions.
8 changes: 4 additions & 4 deletions abjad/demos/bartok/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import abjad


if __name__ == '__main__':
from abjad import show
from abjad.demos import bartok
lilypond_file = bartok.make_bartok_score()
show(lilypond_file)
lilypond_file = abjad.demos.bartok.make_bartok_score()
abjad.show(lilypond_file)
137 changes: 60 additions & 77 deletions abjad/demos/bartok/make_bartok_score.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
# -*- coding: utf-8 -*-
import abjad
import copy
from abjad import Beam
from abjad import Clef
from abjad import Crescendo
from abjad import Decrescendo
from abjad import Dynamic
from abjad import Markup
from abjad import Measure
from abjad import Score
from abjad import Slur
from abjad import Staff
from abjad import StaffGroup
from abjad import Tie
from abjad import Voice
from abjad import attach
from abjad import indicatortools
from abjad import override
from abjad import spannertools
from abjad.tools.topleveltools import select


def make_bartok_score():
score = Score([])
piano_staff = StaffGroup([], context_name='PianoStaff')
upper_staff = Staff([])
lower_staff = Staff([])
score = abjad.Score([])
piano_staff = abjad.StaffGroup([], context_name='PianoStaff')
upper_staff = abjad.Staff([])
lower_staff = abjad.Staff([])
piano_staff.append(upper_staff)
piano_staff.append(lower_staff)
score.append(piano_staff)
upper_measures = []
upper_measures.append(Measure((2, 4), []))
upper_measures.append(Measure((3, 4), []))
upper_measures.append(Measure((2, 4), []))
upper_measures.append(Measure((2, 4), []))
upper_measures.append(Measure((2, 4), []))
upper_measures.append(abjad.Measure((2, 4), []))
upper_measures.append(abjad.Measure((3, 4), []))
upper_measures.append(abjad.Measure((2, 4), []))
upper_measures.append(abjad.Measure((2, 4), []))
upper_measures.append(abjad.Measure((2, 4), []))
lower_measures = copy.deepcopy(upper_measures)
upper_staff.extend(upper_measures)
lower_staff.extend(lower_measures)
Expand All @@ -45,61 +28,61 @@ def make_bartok_score():
lower_measures[0].extend("b4 d'8 c'8")
lower_measures[1].extend("b8 a8 af4 c'8 bf8")
lower_measures[2].extend("a8 g8 fs8 g16 a16")
upper_voice = Voice("b2", name='upper voice')
command = indicatortools.LilyPondCommand('voiceOne')
attach(command, upper_voice)
lower_voice = Voice("b4 a4", name='lower voice')
command = indicatortools.LilyPondCommand('voiceTwo')
attach(command, lower_voice)
upper_voice = abjad.Voice("b2", name='upper voice')
command = abjad.LilyPondCommand('voiceOne')
abjad.attach(command, upper_voice)
lower_voice = abjad.Voice("b4 a4", name='lower voice')
command = abjad.LilyPondCommand('voiceTwo')
abjad.attach(command, lower_voice)
lower_measures[3].extend([upper_voice, lower_voice])
lower_measures[3].is_simultaneous = True
upper_voice = Voice("b2", name='upper voice')
command = indicatortools.LilyPondCommand('voiceOne')
attach(command, upper_voice)
lower_voice = Voice("g2", name='lower voice')
command = indicatortools.LilyPondCommand('voiceTwo')
attach(command, lower_voice)
upper_voice = abjad.Voice("b2", name='upper voice')
command = abjad.LilyPondCommand('voiceOne')
abjad.attach(command, upper_voice)
lower_voice = abjad.Voice("g2", name='lower voice')
command = abjad.LilyPondCommand('voiceTwo')
abjad.attach(command, lower_voice)
lower_measures[4].extend([upper_voice, lower_voice])
lower_measures[4].is_simultaneous = True
clef = Clef('bass')
attach(clef, lower_staff)
dynamic = Dynamic('pp')
attach(dynamic, upper_measures[0][0])
dynamic = Dynamic('mp')
attach(dynamic, upper_measures[1][1])
dynamic = Dynamic('pp')
attach(dynamic, lower_measures[0][1])
dynamic = Dynamic('mp')
attach(dynamic, lower_measures[1][3])
clef = abjad.Clef('bass')
abjad.attach(clef, lower_staff)
dynamic = abjad.Dynamic('pp')
abjad.attach(dynamic, upper_measures[0][0])
dynamic = abjad.Dynamic('mp')
abjad.attach(dynamic, upper_measures[1][1])
dynamic = abjad.Dynamic('pp')
abjad.attach(dynamic, lower_measures[0][1])
dynamic = abjad.Dynamic('mp')
abjad.attach(dynamic, lower_measures[1][3])
score.add_final_bar_line()
selector = select().by_leaf(flatten=True)
upper_leaves = selector(upper_staff)
lower_leaves = selector(lower_staff)
beam = Beam()
attach(beam, upper_leaves[:4])
beam = Beam()
attach(beam, lower_leaves[1:5])
beam = Beam()
attach(beam, lower_leaves[6:10])
slur = Slur()
attach(slur, upper_leaves[:5])
slur = Slur()
attach(slur, upper_leaves[5:])
slur = Slur()
attach(slur, lower_leaves[1:6])
crescendo = Crescendo()
attach(crescendo, upper_leaves[-7:-2])
decrescendo = Decrescendo()
attach(decrescendo, upper_leaves[-2:])
markup = Markup('ritard.')
text_spanner = spannertools.TextSpanner()
override(text_spanner).text_spanner.bound_details__left__text = markup
attach(text_spanner, upper_leaves[-7:])
tie = Tie()
attach(tie, upper_leaves[-2:])
abjad.selector = abjad.select().by_leaf(flatten=True)
upper_leaves = abjad.selector(upper_staff)
lower_leaves = abjad.selector(lower_staff)
beam = abjad.Beam()
abjad.attach(beam, upper_leaves[:4])
beam = abjad.Beam()
abjad.attach(beam, lower_leaves[1:5])
beam = abjad.Beam()
abjad.attach(beam, lower_leaves[6:10])
slur = abjad.Slur()
abjad.attach(slur, upper_leaves[:5])
slur = abjad.Slur()
abjad.attach(slur, upper_leaves[5:])
slur = abjad.Slur()
abjad.attach(slur, lower_leaves[1:6])
crescendo = abjad.Crescendo()
abjad.attach(crescendo, upper_leaves[-7:-2])
decrescendo = abjad.Decrescendo()
abjad.attach(decrescendo, upper_leaves[-2:])
markup = abjad.Markup('ritard.')
text_spanner = abjad.TextSpanner()
abjad.override(text_spanner).text_spanner.bound_details__left__text = markup
abjad.attach(text_spanner, upper_leaves[-7:])
tie = abjad.Tie()
abjad.attach(tie, upper_leaves[-2:])
note_1 = lower_staff[-2]['upper voice'][0]
note_2 = lower_staff[-1]['upper voice'][0]
notes = [note_1, note_2]
tie = Tie()
attach(tie, notes)
return score
tie = abjad.Tie()
abjad.attach(tie, notes)
return score
8 changes: 4 additions & 4 deletions abjad/demos/desordre/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
#! /usr/bin/env python
import abjad


if __name__ == '__main__':
from abjad import show
from abjad.demos import desordre
lilypond_file = desordre.make_desordre_lilypond_file()
show(lilypond_file)
lilypond_file = abjad.demos.desordre.make_desordre_lilypond_file()
abjad.show(lilypond_file)
53 changes: 24 additions & 29 deletions abjad/demos/desordre/make_desordre_cell.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
# -*- coding: utf-8 -*-
import abjad
import math
from abjad.tools import indicatortools
from abjad.tools import scoretools
from abjad.tools import spannertools
from abjad.tools.topleveltools import attach
from abjad.tools.topleveltools import select


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.
'''Makes a Désordre cell.
'''

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])
notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches]
beam = abjad.Beam()
abjad.attach(beam, notes)
slur = abjad.Slur()
abjad.attach(slur, notes)
clef = abjad.Dynamic('f')
abjad.attach(clef, notes[0])
dynamic = abjad.Dynamic('p')
abjad.attach(dynamic, notes[1])

# make the lower voice
lower_voice = scoretools.Voice(notes)
lower_voice = abjad.Voice(notes)
lower_voice.name = 'RH Lower Voice'
command = indicatortools.LilyPondCommand('voiceTwo')
attach(command, lower_voice)
command = abjad.LilyPondCommand('voiceTwo')
abjad.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)
chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8))
articulation = abjad.Articulation('>')
abjad.attach(articulation, chord)

# make the upper voice
upper_voice = scoretools.Voice([chord])
upper_voice = abjad.Voice([chord])
upper_voice.name = 'RH Upper Voice'
command = indicatortools.LilyPondCommand('voiceOne')
attach(command, upper_voice)
command = abjad.LilyPondCommand('voiceOne')
abjad.attach(command, upper_voice)

# combine them together
container = scoretools.Container([lower_voice, upper_voice])
container = abjad.Container([lower_voice, upper_voice])
container.is_simultaneous = True

# make all 1/8 beats breakable
leaves = select(lower_voice).by_leaf()
leaves = abjad.select(lower_voice).by_leaf()
for leaf in leaves[:-1]:
bar_line = indicatortools.BarLine('')
attach(bar_line, leaf)
bar_line = abjad.BarLine('')
abjad.attach(bar_line, leaf)

return container
7 changes: 3 additions & 4 deletions abjad/demos/desordre/make_desordre_lilypond_file.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
import abjad
from abjad.tools import documentationtools
from abjad.demos.desordre.make_desordre_pitches import make_desordre_pitches
from abjad.demos.desordre.make_desordre_score import make_desordre_score


def make_desordre_lilypond_file():
'''Makes Désordre LilyPond file.
'''

pitches = make_desordre_pitches()
score = make_desordre_score(pitches)
pitches = abjad.demos.desordre.make_desordre_pitches()
score = abjad.demos.desordre.make_desordre_score(pitches)
lilypond_file = documentationtools.make_ligeti_example_lilypond_file(score)
return lilypond_file
13 changes: 5 additions & 8 deletions abjad/demos/desordre/make_desordre_measure.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# -*- coding: utf-8 -*-
import abjad
from abjad.tools import mathtools
from abjad.tools import scoretools
from abjad.tools.topleveltools import inspect_


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.
Returns a measure.
'''

for sequence in pitches:
container = abjad.demos.desordre.make_desordre_cell(sequence)
time_signature = inspect_(container).get_duration()
time_signature = mathtools.NonreducedFraction(time_signature)
time_signature = abjad.inspect_(container).get_duration()
time_signature = abjad.NonreducedFraction(time_signature)
time_signature = time_signature.with_denominator(8)
measure = scoretools.Measure(time_signature, [container])
measure = abjad.Measure(time_signature, [container])

return measure
return measure
17 changes: 7 additions & 10 deletions abjad/demos/desordre/make_desordre_score.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# -*- coding: utf-8 -*-
import abjad
from abjad.tools import indicatortools
from abjad.tools import scoretools
from abjad.tools.topleveltools import attach


def make_desordre_score(pitches):
'''Makes Désordre score.
'''

assert len(pitches) == 2
staff_group = scoretools.StaffGroup()
staff_group = abjad.StaffGroup()
staff_group.context_name = 'PianoStaff'

# build the music
Expand All @@ -19,12 +16,12 @@ def make_desordre_score(pitches):
staff_group.append(staff)

# set clef and key signature to left hand staff
clef = indicatortools.Clef('bass')
attach(clef, staff_group[1])
key_signature = indicatortools.KeySignature('b', 'major')
attach(key_signature, staff_group[1])
clef = abjad.Clef('bass')
abjad.attach(clef, staff_group[1])
key_signature = abjad.KeySignature('b', 'major')
abjad.attach(key_signature, staff_group[1])

# wrap the piano staff in a score
score = scoretools.Score([staff_group])
score = abjad.Score([staff_group])

return score
return score
5 changes: 2 additions & 3 deletions abjad/demos/desordre/make_desordre_staff.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
import abjad
from abjad.tools import scoretools


def make_desordre_staff(pitches):
r'''Makes Désordre staff.
'''

staff = scoretools.Staff()
staff = abjad.Staff()
for sequence in pitches:
measure = abjad.demos.desordre.make_desordre_measure(sequence)
staff.append(measure)
return staff
return staff
6 changes: 3 additions & 3 deletions abjad/demos/ferneyhough/configure_lilypond_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from abjad.tools import schemetools
import abjad


def configure_lilypond_file(lilypond_file):
Expand All @@ -11,5 +11,5 @@ def configure_lilypond_file(lilypond_file):
lilypond_file.layout_block.indent = 0
lilypond_file.layout_block.ragged_right = True
lilypond_file.paper_block.ragged_bottom = True
spacing_vector = schemetools.make_spacing_vector(0, 0, 8, 0)
lilypond_file.paper_block.system_system_spacing = spacing_vector
spacing_vector = abjad.make_spacing_vector(0, 0, 8, 0)
lilypond_file.paper_block.system_system_spacing = spacing_vector
Loading

0 comments on commit 514ec35

Please sign in to comment.