Skip to content
On this page

Track Control

minispeaker.tracks

Track

python
class Track()

[🔗]

A dataclass representing an audio track with playback control functionality.

This class manages audio track state including play/pause, mute/unmute, volume control, and provides methods to retrieve audio chunks and wait for track completion.

Attributes:

  • name str - The name identifier of the track.
  • paused bool - Whether the track is currently paused.
  • muted bool - Whether the track is currently muted.
  • volume float - The volume level of the track as a decimal.
  • realtime bool - Whether the track operates in realtime mode.

Track.pause

python
def pause()

[🔗]

Pauses the track. Does nothing if the track is already paused.

Track.cont

python
def cont()

[🔗]

Unpauses the track. Does nothing if the track is already playing.

Track.mute

python
def mute()

[🔗]

Mutes the track. The audio will still be playing but it won't be heard. Does nothing if the track is already muted.

Track.unmute

python
def unmute()

[🔗]

Unmutes the track. Does nothing if the track is not muted.

Track.wait

python
def wait() -> bool | Coroutine[Any, Any, Literal[True]]

[🔗]

Wait until Track is finished.

Returns:

bool | Coroutine[Any, Any, Literal[True]]: Either a synchronous or asynchronous return result of Event.wait

Track.chunk

python
def chunk(num_frames: int) -> ndarray

[🔗]

Retrieves the latest audio chunk.

Arguments:

  • num_frames int - The number of frames per chunk.

Returns:

  • ndarray - A audio chunk represented as a numpy array.

TrackMapping

python
class TrackMapping(Dict[str, Track])

[🔗]

Container for Track access and control.

TrackMapping.clear

python
def clear()

[🔗]

Removes all current tracks. An alert is sent indicating all the tracks are finished.

TrackMapping.__delitem__

python
def __delitem__(name: str)

[🔗]

Remove a Track called name. An alert is sent indicating thatTrack is finished.

Arguments:

  • name str - Name of the Track