Skip to content

Commit

Permalink
Propagate **kwargs for UpdatePattern
Browse files Browse the repository at this point in the history
  • Loading branch information
josiah-wolf-oberholtzer committed Jan 11, 2024
1 parent 275400d commit ca4a014
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions supriya/patterns/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Priority(enum.IntEnum):


class Event:
def __init__(self, *, delta: float = 0.0) -> None:
def __init__(self, *, delta: float = 0.0, **kwargs) -> None:
self.delta = delta

def __eq__(self, expr: Any) -> bool:
Expand Down Expand Up @@ -93,8 +93,9 @@ def __init__(
calculation_rate: CalculationRateLike = "audio",
channel_count: int = 1,
delta: float = 0.0,
**kwargs,
) -> None:
Event.__init__(self, delta=delta)
Event.__init__(self, delta=delta, **kwargs)
self.id_ = id_
self.calculation_rate = CalculationRate.from_expr(calculation_rate)
self.channel_count = channel_count
Expand All @@ -116,9 +117,9 @@ def perform(

class BusFreeEvent(Event):
def __init__(
self, id_: Union[UUID, Tuple[UUID, int]], *, delta: float = 0.0
self, id_: Union[UUID, Tuple[UUID, int]], *, delta: float = 0.0, **kwargs
) -> None:
Event.__init__(self, delta=delta)
Event.__init__(self, delta=delta, **kwargs)
self.id_ = id_

def perform(
Expand All @@ -137,9 +138,11 @@ def perform(


class CompositeEvent(Event):
def __init__(self, events, *, delta: float = 0.0) -> None:
def __init__(self, events, *, delta: float = 0.0, **kwargs) -> None:
Event.__init__(self, delta=delta)
self.events = events
self.events = (
events if not kwargs else [new(event, **kwargs) for event in events]
)

def expand(self, offset) -> Sequence[Tuple[float, Priority, "Event"]]:
events = []
Expand All @@ -157,8 +160,9 @@ def __init__(
add_action: AddActionLike = AddAction.ADD_TO_HEAD,
delta: float = 0.0,
target_node: Optional[Union[Node, UUID]] = None,
**kwargs,
) -> None:
Event.__init__(self, delta=delta)
Event.__init__(self, delta=delta, **kwargs)
self.id_ = id_
self.add_action = AddAction.from_expr(add_action)
self.target_node = target_node
Expand Down Expand Up @@ -187,6 +191,7 @@ def perform(
notes_mapping: Dict[Union[UUID, Tuple[UUID, int]], float],
priority: Priority,
target_node: Optional[Node] = None,
**kwargs,
) -> None:
proxy_mapping[self.id_] = context.add_group(
add_action=self.add_action,
Expand All @@ -199,9 +204,9 @@ def perform(

class NodeFreeEvent(Event):
def __init__(
self, id_: Union[UUID, Tuple[UUID, int]], *, delta: float = 0.0
self, id_: Union[UUID, Tuple[UUID, int]], *, delta: float = 0.0, **kwargs
) -> None:
Event.__init__(self, delta=delta)
Event.__init__(self, delta=delta, **kwargs)
self.id_ = id_

def perform(
Expand Down Expand Up @@ -237,6 +242,7 @@ def __init__(
delta=delta,
id_=id_,
target_node=target_node,
**kwargs,
)
self.duration = duration
self.synthdef = synthdef
Expand Down

0 comments on commit ca4a014

Please sign in to comment.