コード例 #1
0
 def __init__(self, payload=None, start_offset=None, voice_name=None):
     from abjad.tools import lilypondfiletools
     if isinstance(payload, lilypondfiletools.LilyPondFile):
         payload = payload.items[:]
     payload = scoretools.Container(music=payload)
     StartPositionedPayloadExpression.__init__(
         self,
         payload=payload,
         start_offset=start_offset,
         voice_name=voice_name,
         )
コード例 #2
0
 def __init__(self, payload=None, start_offset=None, voice_name=None):
     from experimental.tools import musicexpressiontools
     payload = musicexpressiontools.DivisionList(
         payload,
         start_offset=start_offset,
         voice_name=voice_name,
         )
     StartPositionedPayloadExpression.__init__(
         self,
         payload=payload,
         start_offset=start_offset,
         voice_name=voice_name,
         )
コード例 #3
0
 def __init__(self, payload=None, start_offset=None, voice_name=None):
     from experimental.tools import musicexpressiontools
     payload = musicexpressiontools.DivisionList(
         payload,
         start_offset=start_offset,
         voice_name=voice_name,
     )
     StartPositionedPayloadExpression.__init__(
         self,
         payload=payload,
         start_offset=start_offset,
         voice_name=voice_name,
     )
コード例 #4
0
    def rotate(self, rotation):
        r'''Rotate start-positioned division payload expression by `rotation`.

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.rotate(-1)

        ::

            >>> print(format(expression))
            musicexpressiontools.StartPositionedDivisionPayloadExpression(
                payload=musicexpressiontools.DivisionList(
                    [
                        durationtools.Division(6, 8),
                        durationtools.Division(3, 4),
                        durationtools.Division(6, 8),
                        ],
                    start_offset=durationtools.Offset(0, 1),
                    ),
                start_offset=durationtools.Offset(0, 1),
                )

        Operates in place and returns division payload expression.
        '''
        return StartPositionedPayloadExpression.rotate(self, rotation)
コード例 #5
0
    def rotate(self, rotation):
        r'''Rotate start-positioned division payload expression by `rotation`.

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.rotate(-1)

        ::

            >>> print expression.storage_format
            musicexpressiontools.StartPositionedDivisionPayloadExpression(
                payload=musicexpressiontools.DivisionList(
                    [Division('[6, 8]', start_offset=Offset(0, 1)),
                    Division('[3, 4]', start_offset=Offset(3, 4)),
                    Division('[6, 8]', start_offset=Offset(3, 2))],
                    start_offset=durationtools.Offset(0, 1)
                    ),
                start_offset=durationtools.Offset(0, 1)
                )

        Operates in place and returns division payload expression.
        '''
        return StartPositionedPayloadExpression.rotate(self, rotation)
コード例 #6
0
    def rotate(self, rotation):
        r'''Rotate start-positioned division payload expression by `rotation`.

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.rotate(-1)

        ::

            >>> print(format(expression))
            musicexpressiontools.StartPositionedDivisionPayloadExpression(
                payload=musicexpressiontools.DivisionList(
                    [
                        durationtools.Division(6, 8),
                        durationtools.Division(3, 4),
                        durationtools.Division(6, 8),
                        ],
                    start_offset=durationtools.Offset(0, 1),
                    ),
                start_offset=durationtools.Offset(0, 1),
                )

        Operates in place and returns division payload expression.
        '''
        return StartPositionedPayloadExpression.rotate(self, rotation)
コード例 #7
0
    def translate(self, translation):
        r'''Translate start-positioned rhythm payload expression by
        `translation`.

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.translate(10)

        ::

            >>> print(format(expression))
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=scoretools.Container(
                    "{ c'8 d'8 e'8 f'8 }"
                    ),
                start_offset=durationtools.Offset(10, 1),
                )

        Operates in place and returns start-positioned rhythm payload expression.
        '''
        return StartPositionedPayloadExpression.translate(self, translation)
コード例 #8
0
    def __or__(self, expr):
        r'''Logical OR of two start-positioned division payload expressions:

        ::

            >>> expression_1 = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     2 * [(3, 16)], Offset(0))
            >>> timespan = timespantools.Timespan(Offset(6, 16))
            >>> expression_2 = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     2 * [(2, 16)], Offset(6, 16))

        ::

            >>> expression_1.timespan.stops_when_timespan_starts(expression_2)
            True

        ::

            >>> result = expression_1 | expression_2

        ::

            >>> print format(result)
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                musicexpressiontools.Division(
                                    '[3, 16]',
                                    start_offset=durationtools.Offset(0, 1),
                                    ),
                                musicexpressiontools.Division(
                                    '[3, 16]',
                                    start_offset=durationtools.Offset(3, 16),
                                    ),
                                musicexpressiontools.Division(
                                    '[2, 16]',
                                    start_offset=durationtools.Offset(3, 8),
                                    ),
                                musicexpressiontools.Division(
                                    '[2, 16]',
                                    start_offset=durationtools.Offset(1, 2),
                                    ),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__or__(self, expr)
コード例 #9
0
    def partition_by_ratio_of_durations(self, ratio):
        r'''Partition start-positioned division payload expression by
        `ratio` of durations.

        ::

            >>> payload = [(6, 8), (6, 8), (6, 8), (6, 8), (6, 4), (6, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.partition_by_ratio_of_durations((1, 1))

        ::

            >>> print(format(result))
            musicexpressiontools.TimespanScopedSingleContextSetExpressionInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 4),
                                durationtools.Division(6, 4),
                                ],
                            start_offset=durationtools.Offset(3, 1),
                            ),
                        start_offset=durationtools.Offset(3, 1),
                        ),
                    ]
                )

        Operates in place and returns newly constructed inventory.
        '''
        return StartPositionedPayloadExpression.partition_by_ratio_of_durations(
            self, ratio)
コード例 #10
0
    def partition_by_ratio_of_durations(self, ratio):
        r'''Partition start-positioned division payload expression by
        `ratio` of durations.

        ::

            >>> payload = [(6, 8), (6, 8), (6, 8), (6, 8), (6, 4), (6, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.partition_by_ratio_of_durations((1, 1))

        ::

            >>> print(format(result))
            musicexpressiontools.TimespanScopedSingleContextSetExpressionInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 4),
                                durationtools.Division(6, 4),
                                ],
                            start_offset=durationtools.Offset(3, 1),
                            ),
                        start_offset=durationtools.Offset(3, 1),
                        ),
                    ]
                )

        Operates in place and returns newly constructed inventory.
        '''
        return StartPositionedPayloadExpression.partition_by_ratio_of_durations(self, ratio)
コード例 #11
0
    def __or__(self, expr):
        r'''Logical OR of two start-positioned division payload expressions:

        ::

            >>> expression_1 = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     2 * [(3, 16)], Offset(0))
            >>> timespan = timespantools.Timespan(Offset(6, 16))
            >>> expression_2 = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     2 * [(2, 16)], Offset(6, 16))

        ::

            >>> expression_1.timespan.stops_when_timespan_starts(expression_2)
            True

        ::

            >>> result = expression_1 | expression_2

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(3, 16),
                                durationtools.Division(3, 16),
                                durationtools.Division(2, 16),
                                durationtools.Division(2, 16),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__or__(self, expr)
コード例 #12
0
    def partition_by_ratio(self, ratio):
        r'''Partition start-positioned rhythm payload expression by `ratio`:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(10))

        ::

            >>> result = expression.partition_by_ratio((1, 2, 1))

        ::

            >>> print(format(result))
            musicexpressiontools.TimespanScopedSingleContextSetExpressionInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 }"
                            ),
                        start_offset=durationtools.Offset(10, 1),
                        ),
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ d'8 e'8 }"
                            ),
                        start_offset=durationtools.Offset(81, 8),
                        ),
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ f'8 }"
                            ),
                        start_offset=durationtools.Offset(83, 8),
                        ),
                    ]
                )

        Operates in place and returns newly constructed region expression inventory.
        '''
        return StartPositionedPayloadExpression.partition_by_ratio(self, ratio)
コード例 #13
0
    def reflect(self):
        r'''Reflect start-positioned division payload expression about axis.

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.reflect()

        ::

            >>> print format(expression)
            musicexpressiontools.StartPositionedDivisionPayloadExpression(
                payload=musicexpressiontools.DivisionList(
                    [
                        musicexpressiontools.Division(
                                '[3, 4]', 
                                start_offset=durationtools.Offset(0, 1),
                                ),
                        musicexpressiontools.Division(
                                '[6, 8]', 
                                start_offset=durationtools.Offset(3, 4),
                                ),
                        musicexpressiontools.Division(
                                '[6, 8]', 
                                start_offset=durationtools.Offset(3, 2),
                                ),
                        ],
                    start_offset=durationtools.Offset(0, 1),
                    ),
                start_offset=durationtools.Offset(0, 1),
                )

        Operates in place and returns division payload expression.
        '''
        return StartPositionedPayloadExpression.reflect(self)
コード例 #14
0
    def partition_by_ratio(self, ratio):
        r'''Partition start-positioned division payload expression by `ratio`.

        ::

            >>> payload = [(6, 8), (6, 8), (6, 8), (6, 8), (6, 4), (6, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> result = expression.partition_by_ratio((1, 1))

        ::

            >>> print result.storage_format
            musicexpressiontools.TimespanScopedSingleContextSetExpressionInventory([
                musicexpressiontools.StartPositionedDivisionPayloadExpression(
                    payload=musicexpressiontools.DivisionList(
                        [Division('[6, 8]', start_offset=Offset(0, 1)),
                        Division('[6, 8]', start_offset=Offset(3, 4)),
                        Division('[6, 8]', start_offset=Offset(3, 2))],
                        start_offset=durationtools.Offset(0, 1)
                        ),
                    start_offset=durationtools.Offset(0, 1)
                    ),
                musicexpressiontools.StartPositionedDivisionPayloadExpression(
                    payload=musicexpressiontools.DivisionList(
                        [Division('[6, 8]', start_offset=Offset(9, 4)),
                        Division('[6, 4]', start_offset=Offset(3, 1)),
                        Division('[6, 4]', start_offset=Offset(9, 2))],
                        start_offset=durationtools.Offset(9, 4)
                        ),
                    start_offset=durationtools.Offset(9, 4)
                    )
                ])

        Operates in place and returns newly constructed inventory.
        '''
        return StartPositionedPayloadExpression.partition_by_ratio(self, ratio)
コード例 #15
0
    def partition_by_ratio_of_durations(self, ratio):
        r'''Partition start-positioned rhythm payload expression 
        by `ratio` of durations.

        ::

            >>> payload = [Container("c'2 d'8 e'8 f'4")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(10))

        ::

            >>> result = expression.partition_by_ratio_of_durations((1, 1))

        ::

            >>> print result.storage_format
            musicexpressiontools.TimespanScopedSingleContextSetExpressionInventory([
                musicexpressiontools.StartPositionedRhythmPayloadExpression(
                    payload=containertools.Container(
                        music=[{c'2}]
                        ),
                    start_offset=durationtools.Offset(10, 1)
                    ),
                musicexpressiontools.StartPositionedRhythmPayloadExpression(
                    payload=containertools.Container(
                        music=[{d'8, e'8, f'4}]
                        ),
                    start_offset=durationtools.Offset(21, 2)
                    )
                ])

        Operates in place and returns newly constructed region 
        expression inventory.
        '''
        return StartPositionedPayloadExpression.partition_by_ratio_of_durations(
            self, ratio)
コード例 #16
0
    def __and__(self, timespan):
        r'''Keep intersection of start-positioned
        division payload expression and `timespan`.

        Example 1. Intersection on the left:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(0, Offset(1, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 2. Intersection on the right:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(Offset(17, 8), 100)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(17, 8),
                            ),
                        start_offset=durationtools.Offset(17, 8),
                        ),
                    ]
                )

        Example 3. Trisection:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(Offset(1, 8), Offset(17, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(5, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(5, 8),
                                ],
                            start_offset=durationtools.Offset(1, 8),
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 4. No intersection:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                []
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__and__(self, timespan)
コード例 #17
0
    def __sub__(self, timespan):
        r'''Subtract `timespan` from start-positioned division
        payload expression.

        Example 1. Subtract from left:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(0, Offset(1, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(5, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(3, 4),
                                ],
                            start_offset=durationtools.Offset(1, 8),
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 2. Subtract from right:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(Offset(17, 8), 100)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(5, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 3. Subtract from middle:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(Offset(1, 8), Offset(17, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(17, 8),
                            ),
                        start_offset=durationtools.Offset(17, 8),
                        ),
                    ]
                )

        Example 4. Subtract from nothing:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(3, 4),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__sub__(self, timespan)
コード例 #18
0
    def __and__(self, timespan):
        r'''Keep intersection of start-positioned
        division payload expression and `timespan`.

        Example 1. Intersection on the left:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(0, Offset(1, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 2. Intersection on the right:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(Offset(17, 8), 100)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(17, 8),
                            ),
                        start_offset=durationtools.Offset(17, 8),
                        ),
                    ]
                )

        Example 3. Trisection:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(Offset(1, 8), Offset(17, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(5, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(5, 8),
                                ],
                            start_offset=durationtools.Offset(1, 8),
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 4. No intersection:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                []
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__and__(self, timespan)
コード例 #19
0
    def __or__(self, expr):
        r'''Logical OR of two start-positioned rhythm payload expressions:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression_1 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> payload = [Container("g'8 a'8 b'8 c''8")]
            >>> expression_2 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(4, 8))

        ::

            >>> expression_1.timespan.stops_when_timespan_starts(expression_2)
            True

        ::

            >>> result = expression_1 | expression_2

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Leave start-positioned rhythm payload expression unchanged:

        ::

            >>> print(format(expression_1))
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=scoretools.Container(
                    "{ c'8 d'8 e'8 f'8 }"
                    ),
                start_offset=durationtools.Offset(0, 1),
                )

        Leave `expr` unchanged:

        ::

            >>> print(format(expression_2))
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=scoretools.Container(
                    "{ g'8 a'8 b'8 c''8 }"
                    ),
                start_offset=durationtools.Offset(1, 2),
                )

        Returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__or__(self, expr)
コード例 #20
0
    def __sub__(self, timespan):
        r'''Subtract `timespan` from start-positioned division
        payload expression.

        Example 1. Subtract from left:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(0, Offset(1, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(5, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(3, 4),
                                ],
                            start_offset=durationtools.Offset(1, 8),
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 2. Subtract from right:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(Offset(17, 8), 100)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(5, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 3. Subtract from middle:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(Offset(1, 8), Offset(17, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(1, 8),
                                ],
                            start_offset=durationtools.Offset(17, 8),
                            ),
                        start_offset=durationtools.Offset(17, 8),
                        ),
                    ]
                )

        Example 4. Subtract from nothing:

        ::

            >>> payload = [(6, 8), (6, 8), (3, 4)]
            >>> expression = musicexpressiontools.StartPositionedDivisionPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedDivisionPayloadExpression(
                        payload=musicexpressiontools.DivisionList(
                            [
                                durationtools.Division(6, 8),
                                durationtools.Division(6, 8),
                                durationtools.Division(3, 4),
                                ],
                            start_offset=durationtools.Offset(0, 1),
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__sub__(self, timespan)
コード例 #21
0
 def __init__(self, payload=None, start_offset=None, voice_name=None):
     payload = containertools.Container(music=payload)
     StartPositionedPayloadExpression.__init__(self,
         payload=payload, start_offset=start_offset, voice_name=voice_name)
コード例 #22
0
    def __sub__(self, timespan):
        r'''Subtract `timespan` from start-positioned rhythm payload
        expression.

        Example 1. Subtract from left:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(0, Offset(1, 8))

        ::

                >>> print(format(result))
                timespantools.TimespanInventory(
                    [
                        musicexpressiontools.StartPositionedRhythmPayloadExpression(
                            payload=scoretools.Container(
                                "{ d'8 e'8 f'8 }"
                                ),
                            start_offset=durationtools.Offset(1, 8),
                            ),
                        ]
                    )

        Example 2. Subtract from right:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(Offset(3, 8), 100)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 d'8 e'8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 3. Subtract from middle:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(
            ...     Offset(1, 8), Offset(3, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ f'8 }"
                            ),
                        start_offset=durationtools.Offset(3, 8),
                        ),
                    ]
                )

        Example 4. Subtract nothing:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression - timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 d'8 e'8 f'8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__sub__(self, timespan)
コード例 #23
0
    def __and__(self, timespan):
        r'''Intersection start-positioned rhythm payload expression
        and `timespan`.

        Example 1. Intersection on the left:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(
            ...     Offset(-1, 8), Offset(3, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 d'8 e'8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Example 2. Intersection on the right:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))
            >>> result = expression & timespantools.Timespan(
            ...     Offset(1, 8), Offset(5, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ d'8 e'8 f'8 }"
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 3. Trisection:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = musicexpressiontools.StartPositionedRhythmPayloadExpression(payload, Offset(0))
            >>> result = expression & timespantools.Timespan(Offset(1, 8), Offset(3, 8))

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ d'8 e'8 }"
                            ),
                        start_offset=durationtools.Offset(1, 8),
                        ),
                    ]
                )

        Example 4. No intersection:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression = musicexpressiontools.StartPositionedRhythmPayloadExpression(payload, Offset(0))
            >>> result = expression & timespantools.Timespan(100, 200)

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                []
                )

        Operates in place and returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__and__(self, timespan)
コード例 #24
0
    def __or__(self, expr):
        r'''Logical OR of two start-positioned rhythm payload expressions:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression_1 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> payload = [Container("g'8 a'8 b'8 c''8")]
            >>> expression_2 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(4, 8))

        ::

            >>> expression_1.timespan.stops_when_timespan_starts(expression_2)
            True

        ::

            >>> result = expression_1 | expression_2

        ::

            >>> print(format(result))
            timespantools.TimespanInventory(
                [
                    musicexpressiontools.StartPositionedRhythmPayloadExpression(
                        payload=scoretools.Container(
                            "{ c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8 }"
                            ),
                        start_offset=durationtools.Offset(0, 1),
                        ),
                    ]
                )

        Leave start-positioned rhythm payload expression unchanged:

        ::

            >>> print(format(expression_1))
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=scoretools.Container(
                    "{ c'8 d'8 e'8 f'8 }"
                    ),
                start_offset=durationtools.Offset(0, 1),
                )

        Leave `expr` unchanged:

        ::

            >>> print(format(expression_2))
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=scoretools.Container(
                    "{ g'8 a'8 b'8 c''8 }"
                    ),
                start_offset=durationtools.Offset(1, 2),
                )

        Returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__or__(self, expr)
コード例 #25
0
    def __or__(self, expr):
        r'''Logical OR of two start-positioned rhythm payload expressions:

        ::

            >>> payload = [Container("c'8 d'8 e'8 f'8")]
            >>> expression_1 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(0))

        ::

            >>> payload = [Container("g'8 a'8 b'8 c''8")]
            >>> expression_2 = \
            ...     musicexpressiontools.StartPositionedRhythmPayloadExpression(
            ...     payload, Offset(4, 8))

        ::

            >>> expression_1.timespan.stops_when_timespan_starts(expression_2)
            True

        ::

            >>> result = expression_1 | expression_2

        ::

            >>> print result.storage_format
            timespantools.TimespanInventory([
                musicexpressiontools.StartPositionedRhythmPayloadExpression(
                    payload=containertools.Container(
                        music=[{c'8, d'8, e'8, f'8, g'8, a'8, b'8, c''8}]
                        ),
                    start_offset=durationtools.Offset(0, 1)
                    )
                ])

        Leave start-positioned rhythm payload expression unchanged:

        ::

            >>> print expression_1.storage_format
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=containertools.Container(
                    music=[{c'8, d'8, e'8, f'8}]
                    ),
                start_offset=durationtools.Offset(0, 1)
                )

        Leave `expr` unchanged:

        ::

            >>> print expression_2.storage_format
            musicexpressiontools.StartPositionedRhythmPayloadExpression(
                payload=containertools.Container(
                    music=[{g'8, a'8, b'8, c''8}]
                    ),
                start_offset=durationtools.Offset(1, 2)
                )

        Returns timespan inventory.
        '''
        return StartPositionedPayloadExpression.__or__(self, expr)