コード例 #1
0
ファイル: test_sieves.py プロジェクト: nivlekp/pang
def test_sieves_00():
    sieve = abjad.Pattern(indices=[0, 1], period=12)
    origin = 1
    low = -2
    high = 3
    pitches = pang.gen_pitches_from_sieve(sieve, origin, low, high)
    assert pitches == [1, 2]
コード例 #2
0
    def make_basic_rhythm(self, time_signature_pairs):

        beam_specifier = rmakers.BeamSpecifier(
            beam_divisions_together=self.beams,
            beam_each_division=self.beams,
            beam_rests=self.beams,
            )

        division_masks = rmakers.SilenceMask(
            pattern = abjad.Pattern(
                indices=self.mask_indices,
                period=self.mask_period)
                )
        # division_masks = [silence_every([mask_indicies], period=mask_period),]
        tuplet_specifier = rmakers.TupletSpecifier(
            extract_trivial=True,
            )
        tuplet_rhythm_maker = rmakers.TupletRhythmMaker(
            tuplet_ratios=self.tuplet_ratio,
            beam_specifier=beam_specifier,
            division_masks=division_masks,
            # preferred_denominator=None
            # ...equiv of this...I think it is duration specifier
            # but since pretty much everything defaults to None...its okay?
            tuplet_specifier=tuplet_specifier,
            #tag=self.tag,
            )
        selections = tuplet_rhythm_maker(time_signature_pairs)
        music = abjad.Staff(selections)
        music = self._apply_pitches(music)
        return music
コード例 #3
0
ファイル: test_sieves.py プロジェクト: nivlekp/pang
def test_sieves_01():
    sieve = abjad.Pattern(indices=[0, 1, 7], period=12)
    origin = 6
    low = -12
    high = 11
    pitches = pang.gen_pitches_from_sieve(sieve, origin, low, high)
    assert pitches == [-11, -6, -5, 1, 6, 7]
コード例 #4
0
def test_rhythmmakertools_Pattern_matches_index_06():

    mask = abjad.Pattern(
        indices=[-2, -1],
        period=4,
    )

    length = 4
    assert not mask.matches_index(0, length)
    assert not mask.matches_index(1, length)
    assert mask.matches_index(2, length)
    assert mask.matches_index(3, length)
    assert not mask.matches_index(4, length)
    assert not mask.matches_index(5, length)
    assert mask.matches_index(6, length)
    assert mask.matches_index(7, length)
コード例 #5
0
def test_rhythmmakertools_Pattern_matches_index_04():

    mask = abjad.Pattern(
        indices=[0, 1, 2, 3, 4, 5, 6, 7],
        period=None,
    )

    length = 2
    assert mask.matches_index(0, length)
    assert mask.matches_index(1, length)
    assert not mask.matches_index(2, length)
    assert not mask.matches_index(3, length)
    assert not mask.matches_index(4, length)
    assert not mask.matches_index(5, length)
    assert not mask.matches_index(6, length)
    assert not mask.matches_index(7, length)
コード例 #6
0
 def make_basic_rhythm(self, time_signature_pairs):
     beam_specifier = rmakers.BeamSpecifier(
         beam_divisions_together=self.beams,
         beam_each_division=self.beams,
         beam_rests=self.beams,
     )
     division_masks = rmakers.SilenceMask(pattern=abjad.Pattern(
         indices=self.mask_indices, period=self.mask_period))
     note_rhythm_maker = rmakers.NoteRhythmMaker(
         beam_specifier=beam_specifier,
         division_masks=division_masks,
         #tag=self.tag,
     )
     selections = note_rhythm_maker(time_signature_pairs)
     music = abjad.Staff(selections)
     music = self._apply_pitches(music)
     return music
コード例 #7
0
    def make_basic_rhythm(self, durations):
        talea = rmakers.Talea(
            counts = self.counts,
            denominator=self.denominator,
            )
        beam_specifier = rmakers.BeamSpecifier(
            beam_divisions_together=self.beams,
            beam_each_division=self.beams,
            beam_rests=self.beams,
            )

        # burnish_specifier=abjadext.rmakers.BurnishSpecifier(
        #     left_classes=[abjad.Rest],
        #     left_counts=[1, 0, 1],
        #     )
        if self.mask_indices or self.mask_period == None:
            division_masks = None
        else:
            division_masks = rmakers.SilenceMask(
                pattern = abjad.Pattern(
                    indices=self.mask_indices,
                    period=self.mask_period,
                    )
                )
        tuplet_specifier = rmakers.TupletSpecifier(
            trivialize=True,
            extract_trivial=True,
            rewrite_rest_filled=True,
            )
        talea_rhythm_maker = rmakers.TaleaRhythmMaker(
            talea=talea,
            beam_specifier=beam_specifier,
            extra_counts_per_division=self.extra_counts_per_division,
            division_masks=division_masks,
            tuplet_specifier=tuplet_specifier,
            burnish_specifier=self.burnish_specifier
            #tag=self.tag,
            )

        selections = talea_rhythm_maker(durations)
        music = self._apply_pitches(selections)

        return music
コード例 #8
0
 def make_basic_rhythm(self, time_signature_pairs):
     beam_specifier = rmakers.BeamSpecifier(
         beam_divisions_together=self.beams,
         beam_each_division=self.beams,
         beam_rests=self.beams,
     )
     division_masks = rmakers.SilenceMask(pattern=abjad.Pattern(
         indices=self.mask_indices,
         period=self.mask_period,
     ), )
     tuplet_specifier = rmakers.TupletSpecifier(extract_trivial=True, )
     even_division_rhythm_maker = rmakers.EvenDivisionRhythmMaker(
         denominators=self.denominators,
         beam_specifier=beam_specifier,
         extra_counts_per_division=self.extra_counts_per_division,
         division_masks=division_masks,
         tuplet_specifier=tuplet_specifier,
         #tag=self.tag,
     )
     selections = even_division_rhythm_maker(time_signature_pairs)
     music = abjad.Staff(selections)
     music = self._apply_pitches(music)
     return music
コード例 #9
0
ファイル: Duplication.py プロジェクト: aarongrisez/abjad
    def __call__(self, argument):
        """
        Calls rotation on `argument`.

        ..  container:: example

            Duplicates once without period:

            >>> operator_ = abjad.Duplication(counts=1)
            >>> numbers = [1, 2, 3, 4]
            >>> operator_(numbers)
            [1, 2, 3, 4, 1, 2, 3, 4]

        ..  container:: example

            Duplicates twice without period:

            >>> operator_ = abjad.Duplication(counts=2)
            >>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7])
            >>> operator_(pitch_classes)
            PitchClassSegment([0, 1, 4, 7, 0, 1, 4, 7, 0, 1, 4, 7])

        ..  container:: example

            Duplicates periodically:

            >>> operator_ = abjad.Duplication(counts=1, period=3)
            >>> pitches = abjad.PitchSegment("c' d' e' f' g' a' b' c''")
            >>> for pitch in operator_(pitches):
            ...     pitch
            ...
            NamedPitch("c'")
            NamedPitch("d'")
            NamedPitch("e'")
            NamedPitch("c'")
            NamedPitch("d'")
            NamedPitch("e'")
            NamedPitch("f'")
            NamedPitch("g'")
            NamedPitch("a'")
            NamedPitch("f'")
            NamedPitch("g'")
            NamedPitch("a'")
            NamedPitch("b'")
            NamedPitch("c''")
            NamedPitch("b'")
            NamedPitch("c''")

        ..  container:: example

            Duplicate indices:

            >>> operator_ = abjad.Duplication(
            ...     counts=1,
            ...     indices=(0, -1),
            ...     )
            >>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7])
            >>> operator_(pitch_classes)
            PitchClassSegment([0, 0, 1, 4, 7, 7])

        ..  container:: example

            Duplicate indices periodically:

            >>> operator_ = abjad.Duplication(
            ...     counts=1,
            ...     indices=(0,),
            ...     period=2,
            ...     )
            >>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7, 9])
            >>> operator_(pitch_classes)
            PitchClassSegment([0, 0, 1, 4, 4, 7, 9, 9])

        ..  container:: example

            Duplicate indices periodically with different counts:

            >>> operator_ = abjad.Duplication(
            ...     counts=(1, 2),
            ...     indices=(0,),
            ...     period=2,
            ...     )
            >>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7, 9])
            >>> operator_(pitch_classes)
            PitchClassSegment([0, 0, 1, 4, 4, 4, 7, 9, 9])

        ..  container:: example

            Cyclic counts:

            >>> operator_ = abjad.Duplication(counts=(0, 1, 2, 3))
            >>> pitch_classes = abjad.PitchClassSegment([0, 1, 4, 7, 9])
            >>> operator_(pitch_classes)
            PitchClassSegment([0, 1, 1, 4, 4, 4, 7, 7, 7, 7, 9])

        Returns new object with type equal to that of `argument`.
        """
        import abjad

        if not isinstance(argument, collections.Sequence):
            argument = (argument, )

        counts = self.counts
        if isinstance(counts, int):
            counts = counts + 1
        else:
            counts = [_ + 1 for _ in counts]

        if not self.period and not self.indices:
            if isinstance(counts, int):
                return type(argument)(argument * counts)
            else:
                counts = CyclicTuple(counts)
                result = []
                for i, x in enumerate(argument):
                    count = counts[i]
                    result.extend([x] * count)
                if isinstance(argument, abjad.TypedCollection):
                    result = abjad.new(argument, items=result)
                else:
                    result = type(argument)(result)
                return result

        if isinstance(counts, int):
            counts = [counts]
        counts = CyclicTuple(counts)

        if not self.indices:
            if isinstance(argument, abjad.TypedCollection):
                result = abjad.new(argument, items=())
            else:
                result = type(argument)()
            iterator = abjad.sequence(argument).partition_by_counts(
                [self.period],
                cyclic=True,
                overhang=True,
            )
            for i, shard in enumerate(iterator):
                shard = type(argument)(shard) * counts[i]
                result = result + shard
            return result

        pattern = abjad.Pattern(
            indices=self.indices,
            period=self.period,
        )
        result = []
        length = len(argument)
        j = 0
        for i, x in enumerate(argument):
            if pattern.matches_index(i, length):
                count = counts[j]
                result.extend([x] * count)
                j += 1
            else:
                result.append(x)
        if isinstance(argument, abjad.TypedCollection):
            result = abjad.new(argument, items=result)
        else:
            result = type(argument)(result)
        return result
コード例 #10
0
# -*- coding: utf-8 -*-
import abjad

tie_vectors = [
    None, None, None, True, True, True,
    abjad.Pattern([0], period=2)
]
コード例 #11
0
# -*- coding: utf-8 -*-
from surge.materials.segment_ii.rest_indices import rest_indices_by_group
import abjad

non_rest_indices_stage_3 = abjad.Pattern(
    indices=[0, 4, 6, 9, 12, 22],
    period=35,
    inverted=True
)

rest_indices_stage_3 = []

for i in range(35):
    if non_rest_indices_stage_3.matches_index(i, 35):
        rest_indices_stage_3.append(i)

rest_indices = [
    None,
    None,
    rest_indices_stage_3,
    None,
    rest_indices_by_group['a'][4],
    rest_indices_by_group['h'][5],
    None,
]
コード例 #12
0
ファイル: PatternTuple.py プロジェクト: tchiwinpiti/abjad
 def coerce_(argument):
     if hasattr(argument, 'pattern'):
         pass
     elif not isinstance(argument, abjad.Pattern):
         argument = abjad.Pattern(*argument)
     return argument
コード例 #13
0
# -*- coding: utf-8 -*-
from surge.materials.segment_ii.rest_indices import rest_indices_by_group
import abjad

non_rest_indices_stage_3 = abjad.Pattern(indices=[2, 5, 16, 26],
                                         period=35,
                                         inverted=True)

rest_indices_stage_3 = []

for i in range(35):
    if non_rest_indices_stage_3.matches_index(i, 35):
        rest_indices_stage_3.append(i)

rest_indices = [
    None,
    None,
    rest_indices_stage_3,
    None,
    rest_indices_by_group['c'][4],
    rest_indices_by_group['f'][5],
    None,
]
コード例 #14
0
# -*- coding: utf-8 -*-
from surge.materials.segment_ii.rest_indices import rest_indices_by_group
import abjad

non_rest_indices_stage_3 = abjad.Pattern(indices=[1, 8, 13, 18, 29],
                                         period=35,
                                         inverted=True)

rest_indices_stage_3 = []

for i in range(35):
    if non_rest_indices_stage_3.matches_index(i, 35):
        rest_indices_stage_3.append(i)

rest_indices = [
    None,
    None,
    rest_indices_stage_3,
    None,
    rest_indices_by_group['b'][4],
    rest_indices_by_group['g'][5],
    None,
]
コード例 #15
0
# ###
#
# pattern = abjad.Pattern(
#     indices=[0, 1, 7],
#     payload='Allegro non troppo',
#     period=8,
#     )
# total_length = 10
# for index in range(10):
#     match = pattern.matches_index(index, total_length)
#     if match:
#         payload = pattern.payload
#     else:
#         payload = ''
#     print(index, repr(payload))

# ##

pattern = abjad.Pattern(indices=[2, 3, 6],
                        payload="Allegro non troppo",
                        period=8)

total_length = 10
for index in range(10):
    match = pattern.matches_index(index, total_length)
    if match:
        payload = pattern.payload
    else:
        payload = ""
    print(index, repr(payload))