コード例 #1
0
 def _get_value_from_pattern(patterns, current_stage, last):
     if last is None:
         start = Handler._cycle_next(patterns, current_stage)
     else:
         start = last
     end = Handler._cycle_next(patterns, current_stage)
     return start, end
コード例 #2
0
 def _get_value_from_pattern(patterns, current_stage, last):
     if last is None:
         start = Handler._cycle_next(patterns, current_stage)
     else:
         start = last
     end = Handler._cycle_next(patterns, current_stage)
     return start, end
コード例 #3
0
 def test__cycle_next(self):
     patterns = [
         [0],
         [0, 1],
     ]
     cycles = Handler._create_cycles(patterns)
     next_cycle = Handler._cycle_next(cycles, 0)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 0)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 1)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 0)
コード例 #4
0
 def test__cycle_next(self):
     patterns = [
         [0],
         [0, 1],
     ]
     cycles = Handler._create_cycles(patterns)
     next_cycle = Handler._cycle_next(cycles, 0)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 0)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 0)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 1)
     next_cycle = Handler._cycle_next(cycles, 1)
     self.assertEqual(next_cycle, 0)
コード例 #5
0
    def _handle_rhythm_voice(self, rhythm_voice, current_stage):
        if (self._height_envelopes is None or
            self._height_envelopes[current_stage] is None) and \
                (self._height_envelope_patterns is None or
                 self._height_envelope_patterns[current_stage] is None):
            return

        previous_string_index = None
        for tie, offset_start, offset_end, i, count in \
                self._iterate_logical_ties(rhythm_voice):
            # hide leaves if necessary
            if not self._show_rhythmic_notation:
                for leaf in tie:
                    Handler._hide_leaf(leaf)

            if tie.is_pitched:
                tremolo = Handler._cycle_next(
                    self._tremolo_patterns,
                    current_stage
                )

                string_index = Handler._cycle_next(
                    self._string_index_patterns,
                    current_stage
                )

                direction = Handler._cycle_next(
                    self._direction_patterns,
                    current_stage
                )

                if string_index != previous_string_index:
                    BowingHandler._attach_string_index(string_index, tie)

                if direction:
                    BowingHandler._attach_direction(direction, tie)

                if tremolo:
                    Handler._add_stem_tremolo(tie)

                previous_string_index = string_index
            else:
                previous_string_index = None
コード例 #6
0
    def _handle_rhythm_voice(self, rhythm_voice, current_stage):
        if (self._height_envelopes is None or
            self._height_envelopes[current_stage] is None) and \
                (self._height_envelope_patterns is None or
                 self._height_envelope_patterns[current_stage] is None):
            return

        previous_string_index = None
        for tie, offset_start, offset_end, i, count in \
                self._iterate_logical_ties(rhythm_voice):
            # hide leaves if necessary
            if not self._show_rhythmic_notation:
                for leaf in tie:
                    Handler._hide_leaf(leaf)

            if tie.is_pitched:
                tremolo = Handler._cycle_next(self._tremolo_patterns,
                                              current_stage)

                string_index = Handler._cycle_next(self._string_index_patterns,
                                                   current_stage)

                direction = Handler._cycle_next(self._direction_patterns,
                                                current_stage)

                if string_index != previous_string_index:
                    BowingHandler._attach_string_index(string_index, tie)

                if direction:
                    BowingHandler._attach_direction(direction, tie)

                if tremolo:
                    Handler._add_stem_tremolo(tie)

                previous_string_index = string_index
            else:
                previous_string_index = None
コード例 #7
0
    def _handle_voice(self, voice, current_stage):
        if (self._height_envelopes is None or
            self._height_envelopes[current_stage] is None) and \
                (self._height_envelope_patterns is None or
                 self._height_envelope_patterns[current_stage] is None):
            return

        last_height = None
        last_pressure = None

        for tie, offset_start, offset_end, i, count in \
                Handler._iterate_logical_ties(voice):

            if tie.is_pitched:
                height_start, height_end = \
                    EnvelopeHandler._get_value(
                        self._height_envelopes,
                        self._height_envelope_patterns,
                        current_stage,
                        offset_start,
                        offset_end,
                        last_height,
                    )

                pressure_start, pressure_end = \
                    EnvelopeHandler._get_value(
                        self._pressure_envelopes,
                        self._pressure_envelope_patterns,
                        current_stage,
                        offset_start,
                        offset_end,
                        last_pressure,
                    )

                staccato = Handler._cycle_next(self._staccato_patterns,
                                               current_stage)

                if not staccato:
                    sweep = Handler._cycle_next(self._sweep_patterns,
                                                current_stage)

                    tremolo = Handler._cycle_next(self._tremolo_patterns,
                                                  current_stage)

                    if sweep:
                        style = 'zigzag'
                    elif tremolo:
                        style = 'dashed-line'
                    else:
                        style = None

                    Handler._attach_glissando(
                        tie.head,
                        style=style,
                        color=scheme_rgb_color(
                            grayscale_to_rgb(
                                Handler._intensity_to_grayscale(
                                    pressure_start))),
                    )

                    Handler._hidden_grace_after(tie.tail)

                    grace_container = abjad.inspect(tie.tail)\
                        .get_after_grace_container()

                if grace_container is not None and \
                        len(grace_container) > 0:
                    self._set_y_offset(grace_container[0], height_end)
                    if count - 1 != i:
                        Handler._attach_glissando(
                            grace_container[0],
                            style=style,
                            color=scheme_rgb_color(
                                grayscale_to_rgb(
                                    Handler._intensity_to_grayscale(
                                        pressure_start))),
                        )

                jete = Handler._cycle_next(self._jete_patterns, current_stage)

                if jete:
                    BowingHandler._add_jete(tie.head)

                self._set_y_offset(tie.head, height_start)
                EnvelopeHandler._attach_notehead(tie, pressure_start)

                if not tie.is_trivial:
                    for note in tie[1:]:
                        Handler._add_gliss_skip(note)
                        Handler._hide_note_head(note)

                last_height = height_end
                last_pressure = pressure_end
            else:
                last_height = None
                last_pressure = None
コード例 #8
0
    def _handle_voice(self, voice, current_stage):
        if (self._height_envelopes is None or
            self._height_envelopes[current_stage] is None) and \
                (self._height_envelope_patterns is None or
                 self._height_envelope_patterns[current_stage] is None):
            return

        last_height = None
        last_pressure = None

        for tie, offset_start, offset_end, i, count in \
                Handler._iterate_logical_ties(voice):

            if tie.is_pitched:
                height_start, height_end = \
                    EnvelopeHandler._get_value(
                        self._height_envelopes,
                        self._height_envelope_patterns,
                        current_stage,
                        offset_start,
                        offset_end,
                        last_height,
                    )

                pressure_start, pressure_end = \
                    EnvelopeHandler._get_value(
                        self._pressure_envelopes,
                        self._pressure_envelope_patterns,
                        current_stage,
                        offset_start,
                        offset_end,
                        last_pressure,
                    )

                staccato = Handler._cycle_next(self._staccato_patterns,
                                               current_stage)

                if not staccato:
                    sweep = Handler._cycle_next(self._sweep_patterns,
                                                current_stage)

                    tremolo = Handler._cycle_next(self._tremolo_patterns,
                                                  current_stage)

                    if sweep:
                        style = 'zigzag'
                    elif tremolo:
                        style = 'dashed-line'
                    else:
                        style = None

                    Handler._attach_glissando(
                        tie.head,
                        style=style,
                        color=scheme_rgb_color(
                            grayscale_to_rgb(
                                Handler._intensity_to_grayscale(pressure_start)
                            )
                        ),
                    )

                    Handler._hidden_grace_after(tie.tail)

                    grace_container = abjad.inspect(tie.tail)\
                        .get_after_grace_container()

                if grace_container is not None and \
                        len(grace_container) > 0:
                    self._set_y_offset(grace_container[0], height_end)
                    if count - 1 != i:
                        Handler._attach_glissando(
                            grace_container[0],
                            style=style,
                            color=scheme_rgb_color(
                                grayscale_to_rgb(
                                    Handler._intensity_to_grayscale(
                                        pressure_start)
                                )
                            ),
                        )

                jete = Handler._cycle_next(self._jete_patterns, current_stage)

                if jete:
                    BowingHandler._add_jete(tie.head)

                self._set_y_offset(tie.head, height_start)
                EnvelopeHandler._attach_notehead(tie, pressure_start)

                if not tie.is_trivial:
                    for note in tie[1:]:
                        Handler._add_gliss_skip(note)
                        Handler._hide_note_head(note)

                last_height = height_end
                last_pressure = pressure_end
            else:
                last_height = None
                last_pressure = None