def test_ConcatenatingGraceHandler___call___03():
    grace_handler = nauert.ConcatenatingGraceHandler(
        replace_rest_with_final_grace_note=False)
    quantizer = nauert.Quantizer()
    durations = [1000, 1, 999, 1000]
    pitches = [0, 0, None, 0]
    q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
        tuple(zip(durations, pitches)))
    result = quantizer(q_event_sequence, grace_handler=grace_handler)
    assert abjad.lilypond(result) == abjad.string.normalize(r"""
        \new Voice
        {
            {
                \tempo 4=60
                %%% \time 4/4 %%%
                c'4
                \grace {
                    c'16
                }
                r4
                c'4
                r4
            }
        }
        """), print(abjad.lilypond(result))
def test_Quantizer___call___11():
    quantizer = nauert.Quantizer()
    durations = [250, 1250, 750, 1000, 250]
    pitches = range(5)
    all_attachments = [(x,) for x in pitches]
    pitches = [(x, x + 7) for x in pitches]
    q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_attachment_tuples(
        tuple(zip(durations, pitches, all_attachments))
    )
    time_signature = abjad.TimeSignature((7, 8))
    search_tree = nauert.UnweightedSearchTree(
        definition={
            2: {2: None, 3: None},
            3: {2: None, 3: None},
            5: {2: None},
            7: {2: None},
            13: None,
        }
    )
    q_schema = nauert.MeasurewiseQSchema(
        time_signature=time_signature,
        search_tree=search_tree,
        use_full_measure=True,
    )
    grace_handler = nauert.ConcatenatingGraceHandler(
        replace_rest_with_final_grace_note=True
    )
    attack_point_optimizer = nauert.MeasurewiseAttackPointOptimizer()
    result = quantizer(
        q_event_sequence,
        q_schema=q_schema,
        grace_handler=grace_handler,
        attack_point_optimizer=attack_point_optimizer,
    )
    staff = abjad.Staff([result])
    string = abjad.lilypond(staff)
    assert string == abjad.string.normalize(
        r"""
        \new Staff
        {
            \new Voice
            {
                {
                    \tempo 4=60
                    \time 7/8
                    <c' g'>16
                    <cs' af'>16
                    ~
                    <cs' af'>4
                    <d' a'>8.
                    <ef' bf'>16
                    ~
                    <ef' bf'>8.
                    <e' b'>16
                }
            }
        }
        """
    ), print(string)
    assert_q_event_attachments(result, all_attachments)
Exemplo n.º 3
0
 def __init__(
     self,
     sequence,
     q_schema=None,
     grace_handler=None,
     heuristic=None,
     attack_point_optimizer=None,
     attach_tempos=True,
 ):
     self._sequence = sequence
     self._q_schema = q_schema or nauert.MeasurewiseQSchema()
     self._grace_handler = grace_handler or nauert.ConcatenatingGraceHandler(
         replace_rest_with_final_grace_note=True)
     self._heuristic = heuristic or nauert.DistanceHeuristic()
     self._attack_point_optimizer = (
         attack_point_optimizer or nauert.MeasurewiseAttackPointOptimizer())
     self._attach_tempos = attach_tempos
     self._quantizer = nauert.Quantizer()
Exemplo n.º 4
0
 def make_cloud(self, *arguments, **keywords):
     self._simulate_queue()
     results = []
     measurewise_q_schema = nauert.MeasurewiseQSchema(
         *arguments, **keywords)
     grace_handler = nauert.ConcatenatingGraceHandler(
         replace_rest_with_final_grace_note=True)
     optimizer = nauert.MeasurewiseAttackPointOptimizer()
     quantizer = nauert.Quantizer()
     for durations_ms, pitches in zip(self.durations_msps,
                                      self.pitches_per_server):
         q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
             tuple(zip(durations_ms, pitches)))
         result = quantizer(
             q_event_sequence,
             q_schema=measurewise_q_schema,
             grace_handler=grace_handler,
             attack_point_optimizer=optimizer,
             attach_tempos=False,
         )
         results.append(result)
     return results
def test_Quantizer___call___10():
    quantizer = nauert.Quantizer()
    durations = [1000, 1000, 1000, 2000, 1000, 1000, 500, 500]
    pitches = range(8)
    all_attachments = [(x,) for x in pitches]
    pitches = [(x, x + 7) for x in pitches]
    q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_attachment_tuples(
        tuple(zip(durations, pitches, all_attachments))
    )
    grace_handler = nauert.ConcatenatingGraceHandler(
        replace_rest_with_final_grace_note=True
    )
    result = quantizer(q_event_sequence, grace_handler=grace_handler)
    string = abjad.lilypond(result)
    assert string == abjad.string.normalize(
        r"""
        \new Voice
        {
            {
                \tempo 4=60
                %%% \time 4/4 %%%
                <c' g'>4
                <cs' af'>4
                <d' a'>4
                <ef' bf'>4
                ~
            }
            {
                <ef' bf'>4
                <e' b'>4
                <f' c''>4
                <fs' cs''>8
                <g' d''>8
            }
        }
        """
    ), print(string)
    assert_q_event_attachments(result, all_attachments)
def test_ConcatenatingGraceHandler___init___01():
    grace_handler = nauert.ConcatenatingGraceHandler()
    assert grace_handler.grace_duration == abjad.Duration(1, 16)
    assert grace_handler.discard_grace_rest is True
def test_ConcatenatingGraceHandler___init___04():
    grace_handler = nauert.ConcatenatingGraceHandler(
        replace_rest_with_final_grace_note=True)
    assert grace_handler.grace_duration == abjad.Duration(1, 16)
    assert grace_handler.discard_grace_rest is True
    assert grace_handler.replace_rest_with_final_grace_note is True