def __call__(self) -> abjad.Score: """ Calls score template. """ site = "arctic.ScoreTemplate.__call__()" tag = abjad.Tag(site) # GLOBAL CONTEXT #global_context = self._make_global_context() # Violin markup_voice = abjad.Voice(name="Violin_Markup_Voice", tag=tag) music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag) dynamics_voice = abjad.Voice(name="Violin_Dynamics_Voice", tag=tag) violin_staff = abjad.Staff( [markup_voice, music_voice, dynamics_voice], simultaneous=True, name="Violin", tag=tag, ) abjad.annotate( violin_staff, "default_instrument", arctic.instruments["Violin"], ) abjad.annotate(violin_staff, "default_clef", abjad.Clef("treble")) violin_tag = abjad.LilyPondLiteral(r"\tag #'violin", format_slot='before') abjad.attach(violin_tag, violin_staff) abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme( 'violin', force_quotes=True) # MonoSynth markup_voice = abjad.Voice(name="Monosynth_Markup_Voice", tag=tag) music_voice = abjad.Voice(name="Monosynth_Music_Voice", tag=tag) dynamics_voice = abjad.Voice(name="Monosynth_Dynamics_Voice", tag=tag) monosynth_staff = abjad.Staff( [markup_voice, music_voice, dynamics_voice], simultaneous=True, name="Monosynth", tag=tag, ) abjad.annotate( monosynth_staff, "default_instrument", arctic.instruments["Monosynth"], ) abjad.annotate(monosynth_staff, "default_clef", abjad.Clef("treble")) monosynth_tag = abjad.LilyPondLiteral(r"\tag #'monosynth", format_slot='before') abjad.attach(monosynth_tag, monosynth_staff) abjad.setting(monosynth_staff).midi_instrument = abjad.scheme.Scheme( 'clarinet', force_quotes=True) ### RH PolySynth Voices ### markup_voice = abjad.Voice(name="RH_I_Markup_Voice", tag=tag) music_voice = abjad.Voice(name="RH_I_Music_Voice", tag=tag) dynamics_voice = abjad.Voice(name="RH_I_Dynamics_Voice", tag=tag) #rh_voice_2 = abjad.Voice( # lilypond_type="RHVoiceII", name="RH_II_Music_Voice", tag=tag # ) # RH PolySynth Staff polysynth_music_rh_staff = abjad.Staff( [markup_voice, music_voice, dynamics_voice], simultaneous=True, name="RH_Polysynth", tag=tag, ) abjad.annotate( polysynth_music_rh_staff, "default_clef", abjad.Clef("treble") ) ### LH PolySynth Voices ### markup_voice = abjad.Voice(name="LH_I_Markup_Voice", tag=tag) music_voice = abjad.Voice(name="LH_I_Music_Voice", tag=tag) dynamics_voice = abjad.Voice(name="LH_I_Dynamics_Voice", tag=tag) # lh_voice_2 = abjad.Voice( # lilypond_type="LHVoiceII", name="LH_II_Music_Voice", tag=tag # ) # # LH PolySynth Staff polysynth_music_lh_staff = abjad.Staff( [markup_voice, music_voice, dynamics_voice], simultaneous=True, name="LH_Polysynth", tag=tag, ) abjad.annotate( polysynth_music_lh_staff, "default_clef", abjad.Clef("bass") ) # Polysynth Staff Group polysynth_staff_group = abjad.StaffGroup( [polysynth_music_rh_staff, polysynth_music_lh_staff], simultaneous=True, lilypond_type="PianoStaff", name="Polysynth_Staff_Group", tag=tag, ) polysynth_tag = abjad.LilyPondLiteral(r"\tag #'polysynth", format_slot='before') abjad.attach(polysynth_tag, polysynth_staff_group) abjad.setting(polysynth_staff_group).midi_instrument = abjad.scheme.Scheme( 'organ', force_quotes=True) # Music Context music_context = abjad.Context( [ violin_staff, monosynth_staff, polysynth_staff_group, ], lilypond_type="MusicContext", simultaneous=True, name="Music_Context", tag=tag, ) # Score score = abjad.Score( [music_context], name="Score", tag=tag ) return score
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 _show_transforms(): voice = abjad.Voice(name="Voice") staff = abjad.Staff([voice], name="Staff") score = abjad.Score([staff], name="Score") segments, names = library.silver_start() _add_segments_to_voice(voice, "start", segments, names, do_not_page_break=True) segments, names = library.silver_transform_1() _add_segments_to_voice( voice, "transform 1", segments, names, do_not_page_break=True ) segments, names = library.silver_transform_2() _add_segments_to_voice(voice, "transform 2", segments, names) segments, names = library.silver_transform_3() _add_segments_to_voice(voice, "transform 3", segments, names) segments, names = library.silver_transform_4() _add_segments_to_voice(voice, "transform 4", segments, names) segments, names = library.silver_transform_5() _add_segments_to_voice(voice, "transform 5", segments, names) segments, names = library.silver_transform_6() _add_segments_to_voice(voice, "transform 6", segments, names) segments, names = library.silver_transform_7() _add_segments_to_voice(voice, "transform 7", segments, names) leaf = abjad.select.leaf(score, 0) time_signature = abjad.TimeSignature((1, 8)) abjad.attach(time_signature, leaf) literal = abjad.LilyPondLiteral("#(set-accidental-style 'forget)") abjad.attach(literal, leaf) preamble = r"""#(set-default-paper-size "letter") #(set-global-staff-size 14) \paper { bottom-margin = 15 evenFooterMarkup = \markup \fill-line { "Mráz (silver transforms)" } indent = 0 oddFooterMarkup = \evenFooterMarkup ragged-last = ##t ragged-last-bottom = ##t ragged-right = ##t top-margin = 20 left-margin = 15 print-page-number = ##f system-system-spacing.padding = 12 tagline = ##f } \layout { \context { \Voice \remove Forbid_line_break_engraver \consists Horizontal_bracket_engraver } \context { \Score \remove Bar_number_engraver \override BarLine.transparent = ##t \override Flag.stencil = ##f \override HorizontalBracket.bracket-flare = #'(0 . 0) \override HorizontalBracket.staff-padding = 5 \override HorizontalBracket.thickness = 2 \override HorizontalBracketText.bracket = ##f \override HorizontalBracketText.padding = 1.5 \override NonMusicalPaperColumn.line-break-permission = ##f \override Rest.transparent = ##t \override SpacingSpanner.strict-note-spacing = ##t \override SpacingSpanner.uniform-stretching = ##t \override SpanBar.transparent = ##t \override Stem.stencil = ##f \override TimeSignature.stencil = ##f autoBeaming = ##f proportionalNotationDuration = #(ly:make-moment 1 16) } }""" preamble = _trim_block_string(preamble) lilypond_file = abjad.LilyPondFile([preamble, score]) name = "show/transforms" print(f"Writing {name} ...") abjad.persist.as_pdf(lilypond_file, name)
def test_CrossFader_08(): random.seed(62190) fade_out_container = abjad.Container(r"\time 3/4 r4 c'4 d'4") fade_in_container = abjad.Container(r"\time 3/4 a''4 g''2") fader = auxjad.CrossFader(fade_out_container, fade_in_container) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 3/4 r4 c'4 d'4 r2 d'4 r2 d'4 R1 * 3/4 R1 * 3/4 } \new Staff { \time 3/4 R1 * 3/4 R1 * 3/4 a''4 r2 a''4 r2 a''4 g''2 } >> """ ) random.seed(62190) fader = auxjad.CrossFader(fade_out_container, fade_in_container, fade_out_last=True, ) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 3/4 r4 c'4 d'4 r2 d'4 r2 d'4 r2 d'4 R1 * 3/4 } \new Staff { \time 3/4 R1 * 3/4 R1 * 3/4 a''4 r2 a''4 g''2 a''4 g''2 } >> """ ) random.seed(62190) fader = auxjad.CrossFader(fade_out_container, fade_in_container, fade_in_first=True, fade_out_last=True, ) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 3/4 r4 c'4 d'4 r4 c'4 d'4 r4 c'4 d'4 r2 d'4 R1 * 3/4 } \new Staff { \time 3/4 R1 * 3/4 a''4 r2 a''4 g''2 a''4 g''2 a''4 g''2 } >> """ )
def test_CrossFader_01(): random.seed(17737) fade_out_container = abjad.Staff(r"fs'4 g'2 bf'4") fade_in_container = abjad.Staff(r"\times 4/5 {cs''4 d''1}") fader = auxjad.CrossFader(fade_out_container, fade_in_container) assert abjad.lilypond(fader) == abjad.String.normalize( r""" \new Staff { \time 4/4 fs'4 g'2 bf'4 } \new Staff { \times 4/5 { \time 4/4 cs''4 d''1 } } """ ) selection_a, selection_b = fader() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 fs'4 g'2 bf'4 } \new Staff { \time 4/4 R1 } >> """ ) selection_a, selection_b = fader() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 fs'4 g'2 bf'4 } \new Staff { \times 4/5 { \time 4/4 r4 d''1 } } >> """ ) selection_a, selection_b = fader.current_window score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 fs'4 g'2 bf'4 } \new Staff { \times 4/5 { \time 4/4 r4 d''1 } } >> """ )
def test_CrossFader_19(): random.seed(25519) fade_out_container = abjad.Container(r"\times 2/3 {<c' e'>2 g'1}") fade_in_container = abjad.Container(r"<d' ef'>2. <bf a'>4") fader = auxjad.CrossFader(fade_out_container, fade_in_container, fade_in_first=True, fade_out_last=True, ) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \times 2/3 { \time 4/4 <c' e'>2 g'1 } \times 2/3 { <c' e'>2 g'1 } \times 2/3 { <c' e'>2 g'1 } \times 2/3 { <c' e'>2 g'1 } \times 2/3 { c'2 g'1 } \times 2/3 { c'2 g'1 } \times 2/3 { c'2 r1 } R1 } \new Staff { \time 4/4 R1 ef'2. r4 <d' ef'>2. r4 <d' ef'>2. bf4 <d' ef'>2. bf4 <d' ef'>2. <bf a'>4 <d' ef'>2. <bf a'>4 <d' ef'>2. <bf a'>4 } >> """ )
def test_CrossFader_04(): random.seed(44811) fade_out_container = abjad.Container(r"fs'4 g'2 bf'4") fade_in_container = abjad.Container(r"\times 4/5 {cs''4 d'1}") fader = auxjad.CrossFader(fade_out_container, fade_in_container) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 fs'4 g'2 bf'4 fs'4 g'2 bf'4 fs'4 r2 bf'4 fs'4 r2 bf'4 r2. bf'4 R1 } \new Staff { \time 4/4 R1 \times 4/5 { cs''4 r1 } \times 4/5 { cs''4 r1 } \times 4/5 { cs''4 d'1 } \times 4/5 { cs''4 d'1 } \times 4/5 { cs''4 d'1 } } >> """ )
def make_bartok_score(): """ make the Bartok example score. """ # make score skeleton 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) # make upper measures upper_measures = [] upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) lower_measures = copy.deepcopy(upper_measures) upper_staff.extend(upper_measures) lower_staff.extend(lower_measures) # add leaves to upper measures upper_measures[0].extend("a'8 g'8 f'8 e'8") abjad.attach(abjad.TimeSignature((2, 4)), upper_measures[0][0]) upper_measures[1].extend("d'4 g'8 f'8 e'8 d'8") abjad.attach(abjad.TimeSignature((3, 4)), upper_measures[1][0]) upper_measures[2].extend("c'8 d'16 e'16 f'8 e'8") abjad.attach(abjad.TimeSignature((2, 4)), upper_measures[2][0]) upper_measures[3].append("d'2") upper_measures[4].append("d'2") # add leaves to lower measures 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") # make parallel music for measure 4 upper_voice = abjad.Voice("b2", name='upper voice') command = abjad.LilyPondLiteral(r'\voiceOne') abjad.attach(command, upper_voice) lower_voice = abjad.Voice("b4 a4", name='lower voice') command = abjad.LilyPondLiteral(r'\voiceTwo') abjad.attach(command, lower_voice) lower_measures[3].extend([upper_voice, lower_voice]) lower_measures[3].is_simultaneous = True # make parallel music for measure 5 upper_voice = abjad.Voice("b2", name='upper voice') command = abjad.LilyPondLiteral(r'\voiceOne') abjad.attach(command, upper_voice) lower_voice = abjad.Voice("g2", name='lower voice') command = abjad.LilyPondLiteral(r'\voiceTwo') abjad.attach(command, lower_voice) lower_measures[4].extend([upper_voice, lower_voice]) lower_measures[4].is_simultaneous = True # add bass clef clef = abjad.Clef('bass') leaf = abjad.inspect(lower_staff).leaf(0) abjad.attach(clef, leaf) # add dynamics 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]) # add final bar line score.add_final_bar_line() # select leaves for attaching spanners to upper_leaves = abjad.select(upper_staff).leaves() lower_leaves = abjad.select(lower_staff).leaves() # attach beams abjad.beam(upper_leaves[:4]) abjad.beam(lower_leaves[1:5]) abjad.beam(lower_leaves[6:10]) # attach slurs abjad.slur(upper_leaves[:5]) abjad.slur(upper_leaves[5:]) abjad.slur(lower_leaves[1:6]) # attach hairpins abjad.hairpin('<', upper_leaves[-7:-2]) abjad.hairpin('>', upper_leaves[-2:]) # attach a ritardando with markup start_text_span = abjad.StartTextSpan(left_text=abjad.Markup('ritard.')) abjad.text_spanner(upper_leaves[-7:], start_text_span=start_text_span) # tie notes abjad.tie(upper_leaves[-2:]) # tie more notes note_1 = lower_staff[-2]['upper voice'][0] note_2 = lower_staff[-1]['upper voice'][0] notes = abjad.select([note_1, note_2]) abjad.tie(notes) # return the score return score
def make_empty_score(): tag = baca.tags.function_name(inspect.currentframe()) global_context = baca.score.make_global_context() rh_voice_1 = abjad.Voice(lilypond_type="RHVoiceI", name="RH.Music.1", tag=tag) rh_voice_1I = abjad.Voice(lilypond_type="RHInsertVoiceI", name="RH.Insert_Voice.1", tag=tag) rh_voice_2 = abjad.Voice(lilypond_type="RHVoiceII", name="RH.Music.2", tag=tag) rh_voice_2I = abjad.Voice( lilypond_type="RHInsertVoiceII", name="RH.Insert_Voice.2", tag=tag, ) rh_voice_3 = abjad.Voice(lilypond_type="RHVoiceIII", name="RH.Music.3", tag=tag) rh_voice_3I = abjad.Voice( lilypond_type="RHInsertVoiceIII", name="RH.Insert_Voice.3", tag=tag, ) rh_voice_4 = abjad.Voice(lilypond_type="RHVoiceIV", name="RH.Music.4", tag=tag) rh_voice_4I = abjad.Voice( lilypond_type="RHInsertVoiceIV", name="RH.Insert_Voice.4", tag=tag, ) rh_voice_5 = abjad.Voice(lilypond_type="RHVoiceV", name="RH.Music.5", tag=tag) rh_voice_6 = abjad.Voice(lilypond_type="RHVoiceVI", name="RH.Music.6", tag=tag) rh_resonance_voice = abjad.Voice( lilypond_type="RHResonanceVoice", name="RH.Resonance_Voice", tag=tag, ) lh_voice_1 = abjad.Voice(lilypond_type="LHVoiceI", name="LH.Music.1", tag=tag) lh_voice_2 = abjad.Voice(lilypond_type="LHVoiceII", name="LH.Music.2", tag=tag) lh_voice_3 = abjad.Voice(lilypond_type="LHVoiceIII", name="LH.Music.3", tag=tag) lh_voice_4 = abjad.Voice(lilypond_type="LHVoiceIV", name="LH.Music.4", tag=tag) lh_voice_4I = abjad.Voice( lilypond_type="LHInsertVoiceIV", name="LH.Insert_Voice.4", tag=tag, ) lh_voice_5 = abjad.Voice(lilypond_type="LHVoiceV", name="LH.Music.5", tag=tag) lh_voice_5I = abjad.Voice(lilypond_type="LHInsertVoiceV", name="LH.Insert_Voice.5", tag=tag) lh_voice_6 = abjad.Voice(lilypond_type="LHVoiceVI", name="LH.Music.6", tag=tag) lh_voice_6I = abjad.Voice( lilypond_type="LHInsertVoiceVI", name="LH.Insert_Voice.6", tag=tag, ) lh_resonance_voice = abjad.Voice( lilypond_type="LHResonanceVoice", name="LH.Resonance_Voice", tag=tag, ) piano_music_rh_staff = abjad.Staff( [ rh_voice_1, rh_voice_1I, rh_voice_2, rh_voice_2I, rh_voice_3, rh_voice_3I, rh_voice_4, rh_voice_4I, rh_voice_5, rh_voice_6, rh_resonance_voice, ], lilypond_type="PianoMusicRHStaff", simultaneous=True, name="Piano_Music_RH.Staff", tag=tag, ) piano_music_lh_staff = abjad.Staff( [ lh_voice_1, lh_voice_2, lh_voice_3, lh_voice_4, lh_voice_4I, lh_voice_5, lh_voice_5I, lh_voice_6, lh_voice_6I, lh_resonance_voice, ], lilypond_type="PianoMusicLHStaff", simultaneous=True, name="Piano_Music_LH.Staff", tag=tag, ) piano_music_staff_group = abjad.StaffGroup( [piano_music_rh_staff, piano_music_lh_staff], lilypond_type="PianoMusicStaffGroup", name="Piano_Music.Staff_Group", tag=tag, ) music_context = abjad.Context( [piano_music_staff_group], lilypond_type="MusicContext", name="MusicContext", tag=tag, ) score = abjad.Score([global_context, music_context], name="Score", tag=tag) baca.score.assert_lilypond_identifiers(score) baca.score.assert_unique_context_names(score) # baca.score.assert_matching_custom_context_names(score) _validate_voice_names(score) return score
def make_piano_score(leaves=None, lowest_treble_pitch="B3", sketch=False): r""" Makes piano score from ``leaves``. .. container:: example Makes empty piano score: >>> result = abjad.Score.make_piano_score() >>> abjad.f(result[0]) \new Score << \new PianoStaff << \context Staff = "Treble_Staff" { } \context Staff = "Bass_Staff" { } >> >> .. container:: example Makes piano score from leaves: >>> notes = [abjad.Note(x, (1, 4)) for x in [-12, 37, -10, 2, 4, 17]] >>> result = abjad.Score.make_piano_score(leaves=notes) >>> abjad.show(result[0]) # doctest: +SKIP .. docs:: >>> abjad.f(result[0]) \new Score << \new PianoStaff << \context Staff = "Treble_Staff" { \clef "treble" r4 cs''''4 r4 d'4 e'4 f''4 } \context Staff = "Bass_Staff" { \clef "bass" c4 r4 d4 r4 r4 r4 } >> >> .. container:: example Makes piano sketch score from leaves: >>> maker = abjad.NoteMaker() >>> notes = maker( ... [-12, -10, -8, -7, -5, 0, 2, 4, 5, 7], ... [(1, 16)], ... ) >>> result = abjad.Score.make_piano_score( ... leaves=notes, ... sketch=True, ... ) >>> abjad.show(result[0]) # doctest: +SKIP .. docs:: >>> abjad.f(result[0]) \new Score \with { \override BarLine.stencil = ##f \override BarNumber.transparent = ##t \override SpanBar.stencil = ##f \override TimeSignature.stencil = ##f } << \new PianoStaff << \context Staff = "Treble_Staff" { \clef "treble" r16 r16 r16 r16 r16 c'16 d'16 e'16 f'16 g'16 } \context Staff = "Bass_Staff" { \clef "bass" c16 d16 e16 f16 g16 r16 r16 r16 r16 r16 } >> >> Returns score, treble staff, bass staff triple. """ import abjad leaves = leaves or [] lowest_treble_pitch = abjad.NamedPitch(lowest_treble_pitch) treble_staff = abjad.Staff(name="Treble_Staff") bass_staff = abjad.Staff(name="Bass_Staff") staff_group = abjad.StaffGroup( [treble_staff, bass_staff], lilypond_type="PianoStaff" ) score = abjad.Score() score.append(staff_group) for leaf in leaves: treble_pitches, bass_pitches = [], [] for pitch in abjad.inspect(leaf).pitches(): if pitch < lowest_treble_pitch: bass_pitches.append(pitch) else: treble_pitches.append(pitch) written_duration = leaf.written_duration if not treble_pitches: treble_leaf = abjad.Rest(written_duration) elif len(treble_pitches) == 1: treble_leaf = abjad.Note(treble_pitches[0], written_duration) else: treble_leaf = abjad.Chord(treble_pitches, written_duration) treble_staff.append(treble_leaf) if not bass_pitches: bass_leaf = abjad.Rest(written_duration) elif len(bass_pitches) == 1: bass_leaf = abjad.Note(bass_pitches[0], written_duration) else: bass_leaf = abjad.Chord(bass_pitches, written_duration) bass_staff.append(bass_leaf) if 0 < len(treble_staff): abjad.attach(abjad.Clef("treble"), treble_staff[0]) if 0 < len(bass_staff): abjad.attach(abjad.Clef("bass"), bass_staff[0]) if sketch: abjad.override(score).time_signature.stencil = False abjad.override(score).bar_number.transparent = True abjad.override(score).bar_line.stencil = False abjad.override(score).span_bar.stencil = False return score, treble_staff, bass_staff
def __call__(self): """ Calls string quartet score template. Returns score. """ import abjad site = "abjad.StringQuartetScoreTemplate.__call__()" tag = Tag(site) # make first violin voice and staff first_violin_voice = abjad.Voice( [], name="First_Violin_Voice", tag=tag ) first_violin_staff = abjad.Staff( [first_violin_voice], name="First_Violin_Staff", tag=tag ) clef = abjad.Clef("treble") abjad.annotate(first_violin_staff, "default_clef", clef) violin = abjad.Violin() abjad.annotate(first_violin_staff, "default_instrument", violin) literal = abjad.LilyPondLiteral(r"\tag #'first-violin", "before") abjad.attach(literal, first_violin_staff) # make second violin voice and staff second_violin_voice = abjad.Voice( [], name="Second_Violin_Voice", tag=tag ) second_violin_staff = abjad.Staff( [second_violin_voice], name="Second_Violin_Staff", tag=tag ) clef = abjad.Clef("treble") abjad.annotate(second_violin_staff, "default_clef", clef) violin = abjad.Violin() abjad.annotate(second_violin_staff, "default_instrument", violin) literal = abjad.LilyPondLiteral(r"\tag #'second-violin", "before") abjad.attach(literal, second_violin_staff) # make viola voice and staff viola_voice = abjad.Voice([], name="Viola_Voice", tag=tag) viola_staff = abjad.Staff( [viola_voice], name="Viola_Staff", tag=tag ) clef = abjad.Clef("alto") abjad.annotate(viola_staff, "default_clef", clef) viola = abjad.Viola() abjad.annotate(viola_staff, "default_instrument", viola) literal = abjad.LilyPondLiteral(r"\tag #'viola", "before") abjad.attach(literal, viola_staff) # make cello voice and staff cello_voice = abjad.Voice([], name="Cello_Voice", tag=tag) cello_staff = abjad.Staff( [cello_voice], name="Cello_Staff", tag=tag ) clef = abjad.Clef("bass") abjad.annotate(cello_staff, "default_clef", clef) cello = abjad.Cello() abjad.annotate(cello_staff, "default_instrument", cello) literal = abjad.LilyPondLiteral(r"\tag #'cello", "before") abjad.attach(literal, cello_staff) # make string quartet staff group string_quartet_staff_group = abjad.StaffGroup( [ first_violin_staff, second_violin_staff, viola_staff, cello_staff, ], name="String_Quartet_Staff_Group", tag=tag, ) # make string quartet score string_quartet_score = abjad.Score( [string_quartet_staff_group], name="String_Quartet_Score", tag=tag, ) # return string quartet score return string_quartet_score
def __illustrate__(self, markup_direction=enums.Up, figure_name=None, **keywords): """ Illustrates segment. Returns LilyPond file. """ import abjad notes = [] for item in self: note = abjad.Note(item, Duration(1, 8)) notes.append(note) markup = None if self._equivalence_markup: markup = self._equivalence_markup if isinstance(figure_name, str): figure_name = abjad.Markup(figure_name) if figure_name is not None: markup = figure_name if markup is not None: direction = markup_direction markup = abjad.new(markup, direction=direction) abjad.attach(markup, notes[0]) voice = abjad.Voice(notes) staff = abjad.Staff([voice]) score = abjad.Score([staff]) score.add_final_bar_line() abjad.override(score).bar_line.transparent = True abjad.override(score).bar_number.stencil = False abjad.override(score).beam.stencil = False abjad.override(score).flag.stencil = False abjad.override(score).stem.stencil = False abjad.override(score).time_signature.stencil = False string = r"\override Score.BarLine.transparent = ##f" command = abjad.LilyPondLiteral(string, "after") last_leaf = abjad.select(score).leaves()[-1] abjad.attach(command, last_leaf) moment = abjad.SchemeMoment((1, 12)) abjad.setting(score).proportional_notation_duration = moment lilypond_file = abjad.LilyPondFile.new(music=score) if "title" in keywords: title = keywords.get("title") if not isinstance(title, abjad.Markup): title = abjad.Markup(title) lilypond_file.header_block.title = title if "subtitle" in keywords: markup = abjad.Markup(keywords.get("subtitle")) lilypond_file.header_block.subtitle = markup command = abjad.LilyPondLiteral(r"\accidentalStyle forget") lilypond_file.layout_block.items.append(command) lilypond_file.layout_block.indent = 0 string = "markup-system-spacing.padding = 8" command = abjad.LilyPondLiteral(string) lilypond_file.paper_block.items.append(command) string = "system-system-spacing.padding = 10" command = abjad.LilyPondLiteral(string) lilypond_file.paper_block.items.append(command) string = "top-markup-spacing.padding = 4" command = abjad.LilyPondLiteral(string) lilypond_file.paper_block.items.append(command) return lilypond_file
def __call__(self): """ Calls string orchestra template. Returns score. """ import abjad ### TAGS ### tag_names = [] ### SCORE ### staff_group = abjad.StaffGroup(name='Outer Staff Group', ) score = abjad.Score( [staff_group], name='Score', ) ### VIOLINS ### if self.violin_count: clef_name = 'treble' if self.use_percussion_clefs: clef_name = 'percussion' instrument = abjad.Violin() instrument_count = self.violin_count instrument_staff_group, instrument_tag_names = \ self._make_instrument_staff_group( clef_name=clef_name, count=instrument_count, instrument=instrument, ) staff_group.append(instrument_staff_group) tag_names.extend(instrument_tag_names) ### VIOLAS ### if self.viola_count: clef_name = 'alto' if self.use_percussion_clefs: clef_name = 'percussion' instrument = abjad.Viola() instrument_count = self.viola_count instrument_staff_group, instrument_tag_names = \ self._make_instrument_staff_group( clef_name=clef_name, count=instrument_count, instrument=instrument, ) staff_group.append(instrument_staff_group) tag_names.extend(instrument_tag_names) ### CELLOS ### if self.cello_count: clef_name = 'bass' if self.use_percussion_clefs: clef_name = 'percussion' instrument = abjad.Cello() instrument_count = self.cello_count instrument_staff_group, instrument_tag_names = \ self._make_instrument_staff_group( clef_name=clef_name, count=instrument_count, instrument=instrument, ) staff_group.append(instrument_staff_group) tag_names.extend(instrument_tag_names) ### BASSES ### if self.contrabass_count: clef_name = 'bass_8' if self.use_percussion_clefs: clef_name = 'percussion' instrument = abjad.Contrabass() instrument_count = self.contrabass_count instrument_staff_group, instrument_tag_names = \ self._make_instrument_staff_group( clef_name=clef_name, count=instrument_count, instrument=instrument, ) staff_group.append(instrument_staff_group) tag_names.extend(instrument_tag_names) ### TIME SIGNATURE CONTEXT ### global_context = abjad.Context( name='GlobalContext', lilypond_type='GlobalContext', ) instrument_tags = ' '.join(tag_names) tag_string = r"\tag #'({})".format(instrument_tags) tag_command = abjad.LilyPondLiteral(tag_string, 'before') abjad.attach(tag_command, global_context) score.insert(0, global_context) return score
sequential_event = basic.SequentialEvent([]) for movement_pitch in movement_pitches: sequential_event.append( music.NoteLike(movement_pitch, fractions.Fraction(1, 3)) ) for solution_pitch in solution_pitches: sequential_event.append( music.NoteLike(solution_pitch, fractions.Fraction(1, 5)) ) voice = converter.convert(sequential_event) abjad.attach( abjad.Markup( "\\teeny { movement: " + str(' - '.join(str(pitch.ratio) for pitch in movement_pitches)) + ", harmonicity = " + str(round(harmonicity, 3)) + " }", direction="^", ), voice[0][0][0], ) abjad.attach( abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'), voice[0][0][0] ) score = abjad.Score([abjad.Staff([voice])]) lilypond_file.items.append(score) abjad.persist.as_pdf(lilypond_file, "transition_harmonies.pdf")
def test_scoretools_VerticalMoment___eq___02(): score = abjad.Score([]) score.append(abjad.Staff([abjad.Tuplet((4, 3), "d''8 c''8 b'8")])) staff_group = abjad.StaffGroup(r''' \new Staff { a'4 g'4 } \new Staff { \clef "bass" f'8 e'8 d'8 c'8 } ''') staff_group.lilypond_type = 'PianoStaff' score.append(staff_group) assert format(score) == abjad.String.normalize(r''' \new Score << \new Staff { \tweak text #tuplet-number::calc-fraction-text \times 4/3 { d''8 c''8 b'8 } } \new PianoStaff << \new Staff { a'4 g'4 } \new Staff { \clef "bass" f'8 e'8 d'8 c'8 } >> >> ''') vertical_moment_1 = abjad.inspect(staff_group).get_vertical_moment_at( abjad.Offset(1, 8)) "VerticalMoment(PianoStaff<<2>>, abjad.Staff{2}, a'4, abjad.Staff{4}, e'8)" vertical_moment_2 = abjad.inspect(staff_group[0]).get_vertical_moment_at( abjad.Offset(1, 8)) "VerticalMoment(abjad.Staff{2}, a'4, abjad.Staff{4}, e'8)" assert not vertical_moment_1 == vertical_moment_2 assert vertical_moment_1 != vertical_moment_2
import abjad as ab import numpy as np import random # Initialize score and staffs score = ab.Score() staff = ab.StaffGroup([], lilypond_type='PianoStaff') upper_staff = ab.Staff() lower_staff = ab.Staff() staff.append(upper_staff) staff.append(lower_staff) score.append(staff) # Choose key signature key_choices = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'as', 'bs', 'cs', 'ds', 'es', 'fs', 'gs', 'af', 'bf', 'cf', 'df', 'ef', 'ff', 'gf' ] mode_choices = ['major', 'minor'] chosen_key = random.choices(key_choices)[0] chosen_mode = random.choices(mode_choices)[0] key_signature = ab.KeySignature(chosen_key, chosen_mode) # Choose time signature # time_signature_choices = [(4, 4), (3, 4), (2, 4), (2, 2), (6, 8), (3, 8), (9, 8), (12, 8), (5, 4), (6, 4)] # time_signature_probabilities = [100, 75, 67, 50, 37, 25, 20, 15, 10, 5] # time_signature = random.choices(time_signature_choices, weights = time_signature_probabilities)[0] time_signature = (3, 8) measure_duration = time_signature[0] / time_signature[1]
def test_CrossFader_18(): random.seed(97142) fade_out_container = abjad.Container(r"c'4.\p e'8--\f ~ e'2") fade_in_container = abjad.Container( r"\times 2/3 {f'4-.\pp r4 d'4->\f ~ } d'2" ) fader = auxjad.CrossFader(fade_out_container, fade_in_container, fade_in_first=True, fade_out_last=True, ) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 c'4. \p e'8 \f - \tenuto ~ e'2 c'4. \p e'8 \f - \tenuto ~ e'2 r4. e'8 - \tenuto ~ e'2 r4. e'8 - \tenuto ~ e'2 R1 } \new Staff { \time 4/4 R1 \times 2/3 { f'4 \pp - \staccato r2 } r2 \times 2/3 { f'4 - \staccato r2 } r2 \times 2/3 { f'4 - \staccato r4 d'4 \f - \accent ~ } d'2 \times 2/3 { f'4 \pp - \staccato r4 d'4 \f - \accent ~ } d'2 } >> """ )
score = abjad.Score( [ abjad.Staff(lilypond_type="TimeSignatureContext", name="Global Context"), abjad.StaffGroup( [ abjad.Staff( [abjad.Voice(name="Voice 1")], name="Staff 1", lilypond_type="BowStaff", ), abjad.Staff( [abjad.Voice(name="Voice 5")], name="Staff 5", lilypond_type="BeamStaff", ), abjad.Staff( [abjad.Voice(name="Voice 2")], name="Staff 2", lilypond_type="Staff" ), ], name="Staff Group 1", ), abjad.StaffGroup( [ abjad.Staff( [abjad.Voice(name="Voice 3")], name="Staff 3", lilypond_type="BowStaff", ), abjad.Staff( [abjad.Voice(name="Voice 6")], name="Staff 6", lilypond_type="BeamStaff", ), abjad.Staff( [abjad.Voice(name="Voice 4")], name="Staff 4", lilypond_type="Staff" ), ], name="Staff Group 2", ), ], name="Cthar Score", )
def test_CrossFader_03(): random.seed(44811) fade_out_container = abjad.Container(r"fs'4 g'2 bf'4") fade_in_container = abjad.Container(r"\times 4/5 {cs''4 d'1}") fader = auxjad.CrossFader(fade_out_container, fade_in_container) staff_a = abjad.Staff() staff_b = abjad.Staff() score = abjad.Score([staff_a, staff_b]) for _ in range(3): selection_a, selection_b = fader() staff_a.extend(selection_a) staff_b.extend(selection_b) fader.reset() selection_a, selection_b = fader() staff_a.extend(selection_a) staff_b.extend(selection_b) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 fs'4 g'2 bf'4 \time 4/4 fs'4 g'2 bf'4 \time 4/4 fs'4 r2 bf'4 \time 4/4 fs'4 g'2 bf'4 } \new Staff { \time 4/4 R1 \times 4/5 { \time 4/4 cs''4 r1 } \times 4/5 { \time 4/4 cs''4 r1 } \time 4/4 R1 } >> """ )
def __call__(self): """ Calls string quartet score template. Returns score. """ import abjad # make first violin voice and staff first_violin_voice = abjad.Voice( [], name='First Violin Voice', ) first_violin_staff = abjad.Staff( [first_violin_voice], name='First Violin Staff', ) clef = abjad.Clef('treble') abjad.annotate(first_violin_staff, 'default_clef', clef) violin = abjad.Violin() abjad.annotate(first_violin_staff, 'default_instrument', violin) tag = abjad.LilyPondLiteral(r"\tag #'first-violin", 'before') abjad.attach(tag, first_violin_staff) # make second violin voice and staff second_violin_voice = abjad.Voice( [], name='Second Violin Voice', ) second_violin_staff = abjad.Staff( [second_violin_voice], name='Second Violin Staff', ) clef = abjad.Clef('treble') abjad.annotate(second_violin_staff, 'default_clef', clef) violin = abjad.Violin() abjad.annotate(second_violin_staff, 'default_instrument', violin) tag = abjad.LilyPondLiteral(r"\tag #'second-violin", 'before') abjad.attach(tag, second_violin_staff) # make viola voice and staff viola_voice = abjad.Voice( [], name='Viola Voice', ) viola_staff = abjad.Staff( [viola_voice], name='Viola Staff', ) clef = abjad.Clef('alto') abjad.annotate(viola_staff, 'default_clef', clef) viola = abjad.Viola() abjad.annotate(viola_staff, 'default_instrument', viola) tag = abjad.LilyPondLiteral(r"\tag #'viola", 'before') abjad.attach(tag, viola_staff) # make cello voice and staff cello_voice = abjad.Voice( [], name='Cello Voice', ) cello_staff = abjad.Staff( [cello_voice], name='Cello Staff', ) clef = abjad.Clef('bass') abjad.annotate(cello_staff, 'default_clef', clef) cello = abjad.Cello() abjad.annotate(cello_staff, 'default_instrument', cello) tag = abjad.LilyPondLiteral(r"\tag #'cello", 'before') abjad.attach(tag, cello_staff) # make string quartet staff group string_quartet_staff_group = abjad.StaffGroup( [ first_violin_staff, second_violin_staff, viola_staff, cello_staff, ], name='String Quartet Staff Group', ) # make string quartet score string_quartet_score = abjad.Score( [string_quartet_staff_group], name='String Quartet Score', ) # return string quartet score return string_quartet_score
def test_CrossFader_06(): random.seed(10711) fade_out_container = abjad.Container(r"e'8 fs'4. r2") fade_in_container = abjad.Container(r"c''2 ~ c''8 d''4.") fader = auxjad.CrossFader(fade_out_container, fade_in_container) staff_a = abjad.Staff() staff_b = abjad.Staff() score = abjad.Score([staff_a, staff_b]) for selection_a, selection_b in fader: staff_a.extend(selection_a) staff_b.extend(selection_b) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 e'8 fs'4. r2 \time 4/4 e'8 fs'4. r2 \time 4/4 e'8 r2.. \time 4/4 e'8 r2.. \time 4/4 R1 } \new Staff { \time 4/4 R1 \time 4/4 c''2 ~ c''8 r4. \time 4/4 c''2 ~ c''8 r4. \time 4/4 c''2 ~ c''8 d''4. \time 4/4 c''2 ~ c''8 d''4. } >> """ )
return notes card_funcs = [ func() for func in filter(lambda x: callable(x), CardBuilder.__dict__.values()) ] i = 0 for card_base in card_funcs: if os.path.exists(f'../resources/card_{i}.jpg'): print(f"Skipping card {i}") i += 1 continue score = abjad.Score(name="Score") notes = card_base + [abjad.Rest('r2') for _ in range(3) ] + [abjad.Note("C5", (1, 4)) for _ in range(4)] container = abjad.Container(notes) repeat = abjad.Repeat() abjad.attach(repeat, container) staff = abjad.Staff([container]) score.append(staff) note = abjad.select(score).note(0) time_signature = abjad.TimeSignature((12, 4)) abjad.attach(time_signature, note) lilypond_file = abjad.LilyPondFile(items=[preamble, score]) abjad.show(lilypond_file) all_pdfs = glob.glob(
def test_CrossFader_09(): random.seed(50137) fade_out_container = abjad.Container(r"e'2 c'2") fade_in_container = abjad.Container( r"c''8 d''8 e''8 f''8 g''8 a''8 b''8 c'''8" ) fader = auxjad.CrossFader(fade_out_container, fade_in_container) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 e'2 c'2 e'2 c'2 r2 c'2 r2 c'2 r2 c'2 R1 R1 R1 R1 R1 R1 } \new Staff { \time 4/4 R1 r4. f''8 r2 r4. f''8 r2 r4. f''8 r8 a''8 r4 r4. f''8 r8 a''8 b''8 r8 r4. f''8 r8 a''8 b''8 r8 r4. f''8 r8 a''8 b''8 c'''8 r4 e''8 f''8 r8 a''8 b''8 c'''8 r8 d''8 e''8 f''8 r8 a''8 b''8 c'''8 c''8 d''8 e''8 f''8 r8 a''8 b''8 c'''8 c''8 d''8 e''8 f''8 g''8 a''8 b''8 c'''8 } >> """ ) random.seed(50137) fader = auxjad.CrossFader(fade_out_container, fade_in_container, weighted_duration=True, ) selection_a, selection_b = fader.output_all() score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 4/4 e'2 c'2 e'2 c'2 r2 c'2 r2 c'2 r2 c'2 r2 c'2 r2 c'2 r2 c'2 r2 c'2 r2 c'2 R1 } \new Staff { \time 4/4 R1 r4. f''8 r2 r4. f''8 r2 r4. f''8 r8 a''8 r4 r4. f''8 r8 a''8 b''8 r8 r4 e''8 f''8 r8 a''8 b''8 r8 r4 e''8 f''8 g''8 a''8 b''8 r8 c''8 r8 e''8 f''8 g''8 a''8 b''8 r8 c''8 r8 e''8 f''8 g''8 a''8 b''8 c'''8 c''8 d''8 e''8 f''8 g''8 a''8 b''8 c'''8 c''8 d''8 e''8 f''8 g''8 a''8 b''8 c'''8 } >> """ )
def test_example_of_usage_03(): random.seed(12432) pitch_selector = auxjad.TenneySelector([ "c'", ("fs'", "g'"), "ef''", "a''", ("b", "bf''"), ]) duration_selector = auxjad.CartographySelector([(2, 8), (3, 8), (5, 8)]) dynamic_selector = auxjad.CartographySelector(['p', 'mp', 'mf', 'f']) articulation_selector = auxjad.CartographySelector([None, '-', '>']) pitches = [pitch_selector() for _ in range(8)] durations = [duration_selector() for _ in range(8)] dynamics = [dynamic_selector() for _ in range(8)] articulations = [articulation_selector() for _ in range(8)] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) container = abjad.Container(notes) looper = auxjad.WindowLooper( container, window_size=(4, 4), step_size=(1, 16), after_rest=(1, 4), after_rest_in_new_measure=True, ) staff = abjad.Staff() notes = looper.output_n(4) staff.append(notes) looper.step_size = (1, 4) notes = looper.output_n(4) staff.append(notes) looper.window_size = (7, 8) looper.step_size = (1, 16) looper.after_rest = 0 notes = looper.output_n(6) staff.append(notes) score = abjad.Score([staff]) score.add_final_bar_line() assert abjad.lilypond(score) == abjad.String.normalize(r""" \new Score << \new Staff { \time 4/4 <b bf''>4. \f c'8 ~ c'4 ef''4 \mf \time 1/4 R1 * 1/4 \time 4/4 <b bf''>4 \f ~ <b bf''>16 c'8. ~ c'8. ef''16 \mf ~ ef''8. c'16 - \tenuto \time 1/4 R1 * 1/4 \time 4/4 <b bf''>4 \f c'4 ~ c'8 ef''4 \mf c'8 - \tenuto \time 1/4 R1 * 1/4 \time 4/4 <b bf''>8. \f c'16 ~ c'4 ~ c'16 ef''8. \mf ~ ef''16 c'8. - \tenuto \time 1/4 R1 * 1/4 \time 4/4 c'4 \f ~ c'16 ef''8. \mf ~ ef''16 c'8. - \tenuto ~ c'8. <fs' g'>16 \f \time 1/4 R1 * 1/4 \time 4/4 c'16 ef''8. \mf ~ ef''16 c'8. - \tenuto ~ c'8. <fs' g'>16 \f ~ <fs' g'>8. a''16 \p \time 1/4 R1 * 1/4 \time 4/4 ef''16 \mf c'8. - \tenuto ~ c'8. <fs' g'>16 \f ~ <fs' g'>8. a''16 \p ~ a''4 \time 1/4 R1 * 1/4 \time 4/4 c'8. \mf - \tenuto <fs' g'>16 \f ~ <fs' g'>8. a''16 \p ~ a''4 ~ a''16 <b bf''>8. \time 1/4 R1 * 1/4 \time 7/8 c'8 \mf - \tenuto <fs' g'>4 \f a''4. \p <b bf''>8 c'16 \mf - \tenuto <fs' g'>16 \f ~ <fs' g'>8. a''16 \p ~ a''4 ~ a''16 <b bf''>8. <fs' g'>4 \f a''4. \p <b bf''>4 <fs' g'>8. \f a''8. \p ~ a''8. <b bf''>16 ~ <b bf''>4 <fs' g'>8 \f a''4 \p ~ a''8 <b bf''>4. <fs' g'>16 \f a''16 \p ~ a''4 ~ a''16 <b bf''>4.. \bar "|." } >> """)
def test_CrossFader_13(): random.seed(81943) fade_out_container = abjad.Container( r"\time 3/4 a'4 bf'2 ~ \time 2/4 bf'4 f'4" ) fade_in_container = abjad.Container( r"\time 3/4 r16 cs''4.. e''4 \time 2/4 d''2" ) fader = auxjad.CrossFader(fade_out_container, fade_in_container) selection_a, selection_b = fader.output_n(3) score = abjad.Score([ abjad.Staff(selection_a), abjad.Staff(selection_b), ]) assert abjad.lilypond(score) == abjad.String.normalize( r""" \new Score << \new Staff { \time 3/4 a'4 bf'2 ~ \time 2/4 bf'4 f'4 \time 3/4 a'4 bf'2 ~ \time 2/4 bf'4 f'4 \time 3/4 a'4 bf'2 ~ \time 2/4 bf'4 r4 } \new Staff { \time 3/4 R1 * 3/4 \time 2/4 R1 * 1/2 \time 3/4 r16 cs''4.. r4 \time 2/4 R1 * 1/2 \time 3/4 r16 cs''4.. r4 \time 2/4 R1 * 1/2 } >> """ )
# We can replace the original timespan list in the dictionary of # timespan lists because we know the key it was stored at (its voice # name): all_timespan_lists[voice_name] = timespan_list # Create a score structure score = abjad.Score([ abjad.Staff(lilypond_type="TimeSignatureContext", name="Global Context"), abjad.StaffGroup( [ abjad.Staff([abjad.Voice(name="Voice 1")], name="Staff 1", lilypond_type="Staff"), abjad.Staff([abjad.Voice(name="Voice 3")], name="Staff 3", lilypond_type="Staff"), abjad.Staff([abjad.Voice(name="Voice 8")], name="Staff 8", lilypond_type="Staff"), ], name="Staff Group 1", ), ]) # Teach each of the staves how to draw analysis brackets # for staff in score['Staff Group']: # staff.consists_commands.append('Horizontal_bracket_engraver') # Add skips and time signatures to the global context
import abjad from chalk_line.materials.score_structure.instruments import voices voice_staff_names = [[f"Voice {i + 1}", f"Staff {i + 1}"] for i in range(voices)] score = abjad.Score( [ abjad.Staff(lilypond_type="TimeSignatureContext", name="Global Context"), abjad.StaffGroup( [ abjad.Staff( [abjad.Voice(name=voice_name)], name=staff_name, lilypond_type="Staff", ) for voice_name, staff_name in voice_staff_names ], name="Staff Group", ), ], name="chalk_line Score", )
def test_WindowLooper_27(): container = abjad.Container(r"c'4 d'4 e'4 f'4") looper = auxjad.WindowLooper( container, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) tuplet = abjad.Tuplet('3:2', r"c'2 d'2 e'2") looper = auxjad.WindowLooper( tuplet, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) voice = abjad.Voice(r"c'4 d'4 e'4 f'4") looper = auxjad.WindowLooper( voice, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) staff = abjad.Staff(r"c'4 d'4 e'4 f'4") looper = auxjad.WindowLooper( staff, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) score = abjad.Score([abjad.Staff(r"c'4 d'4 e'4 f'4")]) looper = auxjad.WindowLooper( score, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) voice = abjad.Voice(r"c'4 d'4 e'4 f'4") staff = abjad.Staff([voice]) looper = auxjad.WindowLooper( staff, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) staff = abjad.Staff(r"c'4 d'4 e'4 f'4") score = abjad.Score([staff]) looper = auxjad.WindowLooper( score, window_size=(4, 4), step_size=(1, 16), ) assert isinstance(looper(), abjad.Selection) voice1 = abjad.Voice(r"c'4 d'4 e'4 f'4") voice2 = abjad.Voice(r"g2 f2") staff = abjad.Staff([voice1, voice2], simultaneous=True) with pytest.raises(ValueError): looper = auxjad.WindowLooper( staff, # noqa: F841 window_size=(4, 4), step_size=(1, 16), ) staff1 = abjad.Staff(r"c'4 d'4 e'4 f'4") staff2 = abjad.Staff(r"g2 f2") score = abjad.Score([staff1, staff2]) with pytest.raises(ValueError): looper = auxjad.WindowLooper( score, # noqa: F841 window_size=(4, 4), step_size=(1, 16), )
def __call__(self) -> abjad.Score: """ Calls score template. """ # GLOBAL CONTEXT global_context = abjad.Voice(name="Global_Context") global_context_ii = abjad.Voice(name="Global_Context_II") global_context_iii = abjad.Voice(name="Global_Context_III") # RH STAFF rh_voice_one = abjad.Voice(name="RH_Voice_One") # command = abjad.LilyPondLiteral(r"\voiceOne") # abjad.attach(command, rh_voice_one) # abjad.override(rh_voice_one).stem.direction = abjad.Up # abjad.override(rh_voice_one).tie.direction = abjad.Up rh_voice_two = abjad.Voice(name="RH_Voice_Two") # command = abjad.LilyPondLiteral(r"\voiceTwo") # abjad.attach(command, rh_voice_two) # abjad.override(rh_voice_two).stem.direction = abjad.Down # abjad.override(rh_voice_two).tie.direction = abjad.Down rh_voice_three = abjad.Voice(name="RH_Voice_Three") # command = abjad.LilyPondLiteral(r"\voiceThree") # abjad.attach(command, rh_voice_three) # abjad.override(rh_voice_three).stem.direction = abjad.Down # abjad.override(rh_voice_three).tie.direction = abjad.Down rh_staff = abjad.Staff( [global_context, rh_voice_one, rh_voice_two, rh_voice_three], name="RH_Staff") rh_staff.simultaneous = True # LH STAFF lh_voice_one = abjad.Voice(name="LH_Voice_Four") lh_voice_two = abjad.Voice(name="LH_Voice_Five") lh_staff = abjad.Staff([global_context_ii, lh_voice_one, lh_voice_two], name="LH_Staff") lh_staff.simultaneous = True # ORGAN STAFF piano_group = abjad.StaffGroup( [rh_staff, lh_staff], lilypond_type="PianoStaff", name="Piano_Staff", ) abjad.annotate(piano_group, "default_instrument", abjad.Piano()) instrumentName_piano = abjad.LilyPondLiteral( r"\set PianoStaff.instrumentName = \markup{Organ}") abjad.attach(instrumentName_piano, piano_group) # ELECTRONICS # ELECTRONICS RH STAFF voice_one_elec = abjad.Voice(name="RH_Voice_One_Electronics") electronics = abjad.Staff([global_context_iii, voice_one_elec], name="Electronics_Staff") electronics.simultaneous = True abjad.annotate(electronics, "default_instrument", abjad.Piano()) instrumentName_electronics = abjad.LilyPondLiteral( r"\set Staff.instrumentName = \markup{Electronics}") abjad.attach(instrumentName_electronics, electronics) # SCORE score = abjad.Score( [piano_group, electronics], name="Score", ) # abjad.override(score).script.padding = 1.1 # abjad.override(score).spacing_spanner.strict_grace_spacing = True # abjad.override(score).spacing_spanner.strict_note_spacing = True # abjad.override(score).spacing_spanner.uniform_stretching = True # abjad.override(score).stem.length = 8 # abjad.override(score).text_script.outside_staff_padding = 1 # abjad.override(score).tuplet_bracket.bracket_visibility = True # abjad.override(score).tuplet_bracket.minimum_length = 3 # abjad.override(score).tuplet_bracket.outside_staff_padding = 1.5 # abjad.override(score).tuplet_bracket.padding = 1.5 # abjad.override(score).tuplet_bracket.springs_and_rods = \ # abjad.scheme.Scheme('ly:spanner::set-spacing-rods', verbatim=True) # abjad.override(score).tuplet_bracket.staff_padding = 2.25 # abjad.override(score).tuplet_number.text = \ # abjad.scheme.Scheme( # 'tuplet-number::calc-fraction-text', verbatim=True) # abjad.setting(score).proportional_notation_duration = \ # abjad.scheme.SchemeMoment((1, 24)) # abjad.setting(score).tuplet_full_length = True return score
state2 = stack2.state selection3 = stack([time_signatures[2]], previous_state=state1) selection4 = stack2(time_signatures[3:], previous_state=state2) selection = selection1 + selection2 + selection3 + selection4 staff = abjad.Staff(selection, name="staffname") abjad.attach(abjad.Clef("bass"), abjad.select(staff).leaf(0)) pitches = [] ties = abjad.select(staff).logical_ties(pitched=True) for eye in range(len(ties)): multiplied_val = eye * 0.25 sin_val = math.sin(eye) added_val = multiplied_val + sin_val if 3 < added_val: added_val -= 4.5 pitch = abjad.NumberedPitch(added_val) pitch -= 12 pitches.append(pitch) zipped = zip(pitches, abjad.select(staff).logical_ties(pitched=True)) for pitch, tie in zipped: for leaf in abjad.select(tie).leaves(): leaf.written_pitch = pitch score = abjad.Score([ts_staff, staff]) file = abjad.LilyPondFile.new( score, includes=[r"\Users\Matthew\mason\mason\lilypond\stylesheet.ily"]) abjad.persist(file).as_pdf( r"\Users\Matthew\mason\mason\playground\july_second.pdf")