Skip to content

Commit

Permalink
Fix: rebuilding a stable branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubobubobubobubo committed Nov 12, 2024
1 parent 8925919 commit d07f883
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 12 deletions.
59 changes: 59 additions & 0 deletions sardine_core/handlers/osc.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,62 @@ def send(
else:
serialized = list(chain(*message.items()))
self.call_timed_with_nudge(deadline, self._send, f"/{address}", serialized)

@alias_param(name="iterator", alias="i")
@alias_param(name="divisor", alias="d")
@alias_param(name="rate", alias="r")
@alias_param(name="sorted", alias="s")
def send_pure(
self,
address: Optional[StringElement] | Callable[[], StringElement],
iterator: Number | Callable[[], Number] = 0,
divisor: NumericElement | Callable[[], NumericElement] = 1,
rate: NumericElement | Callable[[], NumericElement] = 1,
sort: bool | Callable[[], bool] = True,
**rest_of_pattern: dict,
) -> None:

def _util_flatten(value):
if isinstance(value, (list, tuple)):
return list(value)
else:
return [value]

if address is None:
return

if self.apply_conditional_mask_to_bars(
pattern=rest_of_pattern,
):
return

pattern = {"address": _resolve_if_callable(address)}

# Evaluate all potential callables
for key, value in rest_of_pattern.items():
pattern[key] = _resolve_if_callable(value)

deadline = self.env.clock.shifted_time
for message in self.pattern_reduce(
pattern,
_resolve_if_callable(iterator),
_resolve_if_callable(divisor),
_resolve_if_callable(rate),
):
if message["address"] is None:
continue
address = message.pop("address")
if sort:
serialized = list(
chain(
*[
_util_flatten(value)
for key, value in sorted(message.items())
]
)
)
else:
serialized = list(
chain(*[_util_flatten(value) for value in message.values()])
)
self.call_timed_with_nudge(deadline, self._send, f"/{address}", serialized)
14 changes: 2 additions & 12 deletions sardine_core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ def panic(*runners: AsyncRunner) -> None:
D("superpanic")


def Pat(
pattern: str, i: int = 0, div: int = 1, rate: int = 1, as_text: bool = False
) -> Any:
def Pat(pattern: str, i: int = 0, div: int = 1, rate: int = 1) -> Any:
"""
General purpose pattern interface. This function can be used to summon the global
parser stored in the fish_bowl. It is generally used to pattern outside of the
Expand All @@ -426,15 +424,7 @@ def Pat(
Returns:
int: The ith element from the resulting pattern
"""
result = bowl.parser.parse(pattern)
if print:
pattern = []
for iterator in range(i):
pattern.append(Sender.pattern_element(result, iterator, div, rate))
print(pattern)
return pattern
else:
return Sender.pattern_element(result, i, div, rate)
return Sender.pattern_element(bowl.parser.parse(pattern), i, div, rate)


class Delay:
Expand Down

0 comments on commit d07f883

Please sign in to comment.