def test_LeafDynMaker_03(): pitches = [0, 2, 4, 5, 7, 9] durations = [(1, 32), (2, 32), (3, 32), (4, 32), (5, 32), (6, 32)] dynamics = ['pp', 'pp', 'mp', 'f', 'f', 'p'] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker( pitches, durations, dynamics, omit_repeated_dynamics=True, ) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'32 \pp d'16 e'16. \mp f'8 \f g'8 ~ g'32 a'8. \p } """)
def test_LeafDynMaker_04(): pitches = [0, 2, 4, 5, 7, 9, 11, 12] durations = (1, 4) dynamics = ['p', 'f', 'ff'] articulations = ['.', '>'] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \staccato d'4 \f - \accent e'4 \ff f'4 g'4 a'4 b'4 c''4 } """)
def test_LeafDynMaker_01(): pitches = [0, 2, 4, 5, 7, 9] durations = [(1, 32), (2, 32), (3, 32), (4, 32), (5, 32), (6, 32)] dynamics = ['pp', 'p', 'mp', 'mf', 'f', 'ff'] articulations = ['.', '>', '-', '_', '^', '+'] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'32 \pp - \staccato d'16 \p - \accent e'16. \mp - \tenuto f'8 \mf - \portato g'8 \f - \marcato ~ g'32 a'8. \ff - \stopped } """)
def test_LeafDynMaker_09(): maker = auxjad.LeafDynMaker() note = maker(0, (1, 4), 'p', '-') staff = abjad.Staff([note]) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \tenuto } """)
def test_LeafDynMaker_09(): leaf_dyn_maker = auxjad.LeafDynMaker() note = leaf_dyn_maker(0, (1, 4), 'p', '-') staff = abjad.Staff([note]) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \tenuto } """)
def test_LeafDynMaker_08(): pitches = [ 0, "d'", 'E4', abjad.NumberedPitch(5), abjad.NamedPitch("g'"), abjad.NamedPitch('A4'), ] durations = [ (1, 32), '2/32', abjad.Duration('3/32'), abjad.Duration(0.125), abjad.Duration(5, 32), abjad.Duration(6 / 32), ] dynamics = [ 'p', abjad.Dynamic('f'), ] articulations = [ '>', abjad.Articulation('-'), abjad.Staccato(), ] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'32 \p - \accent d'16 \f - \tenuto e'16. \staccato f'8 g'8 ~ g'32 a'8. } """)
def test_LeafDynMaker_05(): pitches = [0, 2, 4, 5, 7, 9, 11, 12] durations = (1, 4) dynamics = ['p', 'f', 'ff'] articulations = ['.', '>'] maker = auxjad.LeafDynMaker() notes = maker( pitches, durations, dynamics, articulations, cyclic_dynamics=True, cyclic_articulations=True, ) staff = abjad.Staff(notes) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \staccato d'4 \f - \accent e'4 \ff - \staccato f'4 \p - \accent g'4 \f - \staccato a'4 \ff - \accent b'4 \p - \staccato c''4 \f - \accent } """)
def test_LeafDynMaker_02(): pitches = [5, None, (0, 2, 7)] durations = [(1, 4), (1, 8), (1, 16)] dynamics = ['p', None, 'f'] articulations = ['staccato', None, 'tenuto'] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { f'4 \p - \staccato r8 <c' d' g'>16 \f - \tenuto } """)
def test_LeafDynMaker_06(): pitches = [0, 2, 4, 5, 7, 9, 11, 12] durations = (1, 4) dynamics = 'p' articulations = '.' maker = auxjad.LeafDynMaker() notes = maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \staccato d'4 e'4 f'4 g'4 a'4 b'4 c''4 } """)
def test_LeafDynMaker_07(): pitches = [0, 2, 4, 5, 7, 9, 11, 12] durations = (1, 4) dynamics = 'p' articulations = '.' leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker( pitches, durations, dynamics, articulations, cyclic_articulations=True, ) staff = abjad.Staff(notes) assert format(staff) == abjad.String.normalize(r""" \new Staff { c'4 \p - \staccato d'4 - \staccato e'4 - \staccato f'4 - \staccato g'4 - \staccato a'4 - \staccato b'4 - \staccato c''4 - \staccato } """)
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_example_of_usage_03(): random.seed(12432) pitch_selector = auxjad.TenneySelector([0, 7, 8, 2, 3, 10]) 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=(5, 4), step_size=(1, 4), ) staff = abjad.Staff() notes = looper.output_n(6) staff.append(notes) looper.step_size = (1, 16) notes = looper.output_n(6) staff.append(notes) abjad.mutate(staff[:]).remove_repeated_time_signatures() looper.window_size = (3, 4) notes = looper.output_n(6) staff.append(notes) abjad.mutate(staff[:]).remove_repeated_dynamics() assert format(staff) == abjad.String.normalize(r""" \new Staff { \time 5/4 bf'4. \f g'4. af'4 \mf c'4 - \tenuto bf'8 \f g'4. af'4 \mf c'4. - \tenuto g'8 \f g'4 af'4 \mf c'4 - \tenuto ~ c'8 g'4 \f ef'8 \p af'4 \mf c'4. - \tenuto g'8 \f ~ g'8 ef'4. \p c'4. \mf - \tenuto g'4 \f ef'8 \p ~ ef'4 bf'4 c'8 \mf - \tenuto g'4 \f ef'4. \p bf'2 c'16 \mf - \tenuto g'8. \f ~ g'16 ef'8. \p ~ ef'8. bf'16 ~ bf'4.. ~ bf'16 g'4 \f ef'4. \p bf'8 ~ bf'4. ~ bf'8 g'8. \f ef'16 \p ~ ef'4 ~ ef'16 bf'8. ~ bf'4 ~ bf'16 ~ bf'8 af'16 - \tenuto g'8 \f ef'4. \p bf'4 ~ bf'4 ~ bf'8 af'8 - \tenuto g'16 \f ef'8. \p ~ ef'8. bf'16 ~ bf'4 ~ bf'4 ~ bf'16 af'8. - \tenuto ef'4. bf'4. ~ bf'4 af'4 - \tenuto \time 3/4 ef'4 ~ ef'16 bf'4.. ef'4 bf'2 ef'8. bf'16 ~ bf'2 ef'8 bf'8 ~ bf'2 ef'16 bf'8. ~ bf'4.. af'16 - \tenuto bf'2 ~ bf'8 af'8 - \tenuto } """)