Skip to content

Commit

Permalink
Add nperiods property to Driver
Browse files Browse the repository at this point in the history
This will just add the possibility to configure the number of periods
used by the underlying soundcard. This can be especially helpfull when
tailoring performance on jittery systems.
  • Loading branch information
hjespersen committed Jan 30, 2024
1 parent bd6b437 commit 59dd4aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/jack_server/_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@ def period(self) -> int:
def period(self, __value: int) -> None:
self.params["period"].value = __value

@property
def nperiods(self) -> int:
return cast(int, self.params["nperiods"].value)

@nperiods.setter
def nperiods(self, __value: int) -> None:
self.params["nperiods"].value = __value

def __repr__(self) -> str:
return f"<jack_server.Driver name={self.name}>"
3 changes: 3 additions & 0 deletions src/jack_server/_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
device: str | SetByJack = SetByJack_,
rate: SampleRate | SetByJack = SetByJack_,
period: int | SetByJack = SetByJack_,
nperiods: int | SetByJack = SetByJack_,
) -> None:
self._created = False
self._opened = False
Expand All @@ -73,6 +74,8 @@ def __init__(
self.driver.rate = rate
if not isinstance(period, SetByJack):
self.driver.period = period
if not isinstance(nperiods, SetByJack):
self.driver.nperiods = nperiods

def _create(
self,
Expand Down

0 comments on commit 59dd4aa

Please sign in to comment.