def apply_page_breaks(score): r'''Applies page breaks to score. ''' bell_voice = score['Bell Voice'] measure_indices = [ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 72, 79, 86, 93, 100, ] for measure_index in measure_indices: command = abjad.LilyPondCommand('break', 'after') abjad.attach(command, bell_voice[measure_index])
def apply_rehearsal_marks(score): r'''Applies rehearsal marks to score. ''' bell_voice = score['Bell Voice'] measure_indices = [ 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, ] for measure_index in measure_indices: command = abjad.LilyPondCommand(r'mark \default', 'before') abjad.attach(command, bell_voice[measure_index])
def make_desordre_cell(pitches): '''Makes a Désordre cell. ''' notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches] notes = abjad.Selection(notes) 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 = abjad.Voice(notes) lower_voice.name = 'RH Lower Voice' command = abjad.LilyPondCommand('voiceTwo') abjad.attach(command, lower_voice) n = int(math.ceil(len(pitches) / 2.)) chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8)) articulation = abjad.Articulation('>') abjad.attach(articulation, chord) # make the upper voice upper_voice = abjad.Voice([chord]) upper_voice.name = 'RH Upper Voice' command = abjad.LilyPondCommand('voiceOne') abjad.attach(command, upper_voice) # combine them together container = abjad.Container([lower_voice, upper_voice]) container.is_simultaneous = True # make all 1/8 beats breakable leaves = abjad.select(lower_voice).leaves() for leaf in leaves[:-1]: bar_line = abjad.BarLine('') abjad.attach(bar_line, leaf) return container
def configure_lilypond_file(lilypond_file): r'''Configures LilyPond file. ''' lilypond_file._global_staff_size = 8 context_block = abjad.ContextBlock( source_lilypond_type=r'Staff \RemoveEmptyStaves', ) abjad.override(context_block).vertical_axis_group.remove_first = True lilypond_file.layout_block.items.append(context_block) slash_separator = abjad.LilyPondCommand('slashSeparator') lilypond_file.paper_block.system_separator_markup = slash_separator bottom_margin = abjad.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.bottom_margin = bottom_margin top_margin = abjad.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.top_margin = top_margin left_margin = abjad.LilyPondDimension(0.75, 'in') lilypond_file.paper_block.left_margin = left_margin right_margin = abjad.LilyPondDimension(0.5, 'in') lilypond_file.paper_block.right_margin = right_margin paper_width = abjad.LilyPondDimension(5.25, 'in') lilypond_file.paper_block.paper_width = paper_width paper_height = abjad.LilyPondDimension(7.25, 'in') lilypond_file.paper_block.paper_height = paper_height lilypond_file.header_block.composer = abjad.Markup('Arvo Pärt') title = 'Cantus in Memory of Benjamin Britten (1980)' lilypond_file.header_block.title = abjad.Markup(title)
def make_bartok_score(): score = abjad.Score() piano_staff = abjad.StaffGroup([], lilypond_type='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(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) upper_measures[0].extend("a'8 g'8 f'8 e'8") upper_measures[1].extend("d'4 g'8 f'8 e'8 d'8") upper_measures[2].extend("c'8 d'16 e'16 f'8 e'8") upper_measures[3].append("d'2") upper_measures[4].append("d'2") 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 = 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 = 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 = abjad.Clef('bass') leaf = abjad.inspect(lower_staff).get_leaf(0) abjad.attach(clef, leaf) 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() abjad.selector = abjad.select().leaves() 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.Hairpin('<') abjad.attach(crescendo, upper_leaves[-7:-2]) diminuendo = abjad.Hairpin('>') abjad.attach(diminuendo, 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 = abjad.select([note_1, note_2]) abjad.attach(abjad.Tie(), notes) return score
def make_mozart_score(): r'''Makes Mozart score. ''' score_template = abjad.TwoStaffPianoScoreTemplate() score = score_template() # select the measures to use choices = abjad.demos.mozart.choose_mozart_measures() # create and populate the volta containers treble_volta = abjad.Container() bass_volta = abjad.Container() for choice in choices[:7]: treble, bass = abjad.demos.mozart.make_mozart_measure(choice) treble_volta.append(treble) bass_volta.append(bass) # abjad.attach indicators to the volta containers command = abjad.LilyPondCommand('repeat volta 2', 'before') abjad.attach(command, treble_volta) command = abjad.LilyPondCommand('repeat volta 2', 'before') abjad.attach(command, bass_volta) # append the volta containers to our staves score['RHVoice'].append(treble_volta) score['LHVoice'].append(bass_volta) # create and populate the alternative ending containers treble_alternative = abjad.Container() bass_alternative = abjad.Container() for choice in choices[7:9]: treble, bass = abjad.demos.mozart.make_mozart_measure(choice) treble_alternative.append(treble) bass_alternative.append(bass) # abjad.attach indicators to the alternative containers command = abjad.LilyPondCommand('alternative', 'before') abjad.attach(command, treble_alternative) command = abjad.LilyPondCommand('alternative', 'before') abjad.attach(command, bass_alternative) # append the alternative containers to our staves score['RHVoice'].append(treble_alternative) score['LHVoice'].append(bass_alternative) # create the remaining measures for choice in choices[9:]: treble, bass = abjad.demos.mozart.make_mozart_measure(choice) score['RHVoice'].append(treble) score['LHVoice'].append(bass) # abjad.attach indicators time_signature = abjad.TimeSignature((3, 8)) leaf = abjad.inspect(score['RHStaff']).get_leaf(0) abjad.attach(time_signature, leaf) bar_line = abjad.BarLine('|.') leaf = abjad.inspect(score['RHStaff']).get_leaf(-1) abjad.attach(bar_line, leaf) bar_line = abjad.BarLine('|.') leaf = abjad.inspect(score['LHStaff']).get_leaf(-1) abjad.attach(bar_line, leaf) # remove the default piano instrument and add a custom one: abjad.detach(abjad.Instrument, score['PianoStaff']) klavier = abjad.instrumenttools.Piano( name='Katzenklavier', short_name='kk.', ) leaf = abjad.inspect(score['PianoStaff']).get_leaf(0) abjad.attach(klavier, leaf) return score
def mk_bar_line() -> abjad.LilyPondCommand: return abjad.LilyPondCommand('bar "|"', "after")
def mk_cadenza() -> abjad.LilyPondCommand: return abjad.LilyPondCommand("cadenzaOn", "before")
def mk_numeric_ts() -> abjad.LilyPondCommand: return abjad.LilyPondCommand("numericTimeSignature", "before")
def mk_no_time_signature() -> abjad.LilyPondCommand: return abjad.LilyPondCommand( "override Score.TimeSignature.stencil = ##f", "before")