-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
137 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Timemarkers | ||
=========== | ||
|
||
.. module:: pyflp.timemarker | ||
.. autoclass:: TimeMarker | ||
:members: | ||
|
||
.. grid:: | ||
|
||
.. grid-item:: | ||
|
||
.. autoclass:: TimeMarkerType | ||
:members: | ||
|
||
.. grid-item:: | ||
:child-align: center | ||
:columns: auto | ||
|
||
.. image:: /img/arrangement/timemarker/action.png | ||
|
||
Event IDs | ||
--------- | ||
|
||
.. autoclass:: TimeMarkerID | ||
:members: | ||
:member-order: bysource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"""Contains the types required for pattern and playlist timemarkers.""" | ||
|
||
import enum | ||
|
||
from ._descriptors import EventProp | ||
from ._events import DWORD, TEXT, EventEnum, U8Event, U32Event | ||
from ._models import EventModel | ||
|
||
__all__ = ["TimeMarkerID", "TimeMarkerType", "TimeMarker"] | ||
|
||
|
||
@enum.unique | ||
class TimeMarkerID(EventEnum): | ||
Numerator = (33, U8Event) | ||
Denominator = (34, U8Event) | ||
Position = (DWORD + 20, U32Event) | ||
Name = TEXT + 13 | ||
|
||
|
||
class TimeMarkerType(enum.IntEnum): | ||
Marker = 0 | ||
"""Normal text marker.""" | ||
|
||
Signature = 134217728 | ||
"""Used for time signature markers.""" | ||
|
||
|
||
class TimeMarker(EventModel): | ||
"""A marker in the timeline of an :class:`Arrangement`. | ||
![](https://bit.ly/3gltKbt) | ||
""" | ||
|
||
def __repr__(self): | ||
if self.type == TimeMarkerType.Marker: | ||
if self.name: | ||
return f"Marker {self.name!r} @ {self.position!r}" | ||
return f"Unnamed marker @ {self.position!r}" | ||
|
||
time_sig = f"{self.numerator}/{self.denominator}" | ||
if self.name: | ||
return f"Signature {self.name!r} ({time_sig}) @ {self.position!r}" | ||
return f"Unnamed {time_sig} signature @ {self.position!r}" | ||
|
||
denominator: EventProp[int] = EventProp[int](TimeMarkerID.Denominator) | ||
name = EventProp[str](TimeMarkerID.Name) | ||
numerator = EventProp[int](TimeMarkerID.Numerator) | ||
|
||
@property | ||
def position(self) -> int | None: | ||
if TimeMarkerID.Position in self.events.ids: | ||
event = self.events.first(TimeMarkerID.Position) | ||
if event.value < TimeMarkerType.Signature: | ||
return event.value | ||
return event.value - TimeMarkerType.Signature | ||
|
||
@property | ||
def type(self) -> TimeMarkerType | None: | ||
"""The action with which a time marker is associated. | ||
[![](https://bit.ly/3RDM1yn)]() | ||
""" | ||
if TimeMarkerID.Position in self.events.ids: | ||
event = self.events.first(TimeMarkerID.Position) | ||
if event.value >= TimeMarkerType.Signature: | ||
return TimeMarkerType.Signature | ||
return TimeMarkerType.Marker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters