Skip to content
On this page

Devices

minispeaker.devices

default_speaker

python
def default_speaker() -> str

[🔗]

Retrieves the default speaker.

Internally implemented using pyminiaudio's internal library, which is subject to change.

Raises:

  • MiniaudioError - If speaker enumeration fails

Returns:

  • str - The name of the default speaker.

available_speakers

python
def available_speakers() -> List[str]

[🔗]

Retrieves all available speakers by name.

Returns:

  • List[str] - A list of available speakers

MaDeviceState

python
class MaDeviceState(Enum)

[🔗]

Miniaudio equivalent enum of ma_device_state.

Arguments:

  • Enum type - Pythonic version of ma_device_state

Attributes:

  • UNINITIALIZED - Device has not been initialized yet
  • STOPPED - Device is initialized but not actively processing audio
  • STARTED - Device is actively processing audio
  • STOPPING - Device is in the process of stopping
  • STARTING - Device is in the process of starting

ConcurrentPlaybackDevice

python
class ConcurrentPlaybackDevice(PlaybackDevice)

[🔗]

Modified miniaudio PlaybackDevice class with accessible ma_device_state and thread-safe concurrency.

Arguments:

  • *args - Variable length argument list passed to parent PlaybackDevice.
  • stopped Event - Used to signal when a PlaybackDevice is finished.
  • **kwargs - Arbitrary keyword arguments passed to parent PlaybackDevice.

Attributes:

  • state MaDeviceState - Current state of the audio device.
  • volume float | None - Volume level of the PlaybackDevice (0.0 to 1.0+).
  • starting bool - True if the device is currently starting.
  • stopping bool - True if the device is currently stopping.
  • stopped bool - True if the device has stopped.
  • closed bool - True if the device is uninitialized/closed.
  • started bool - True if the device has started and is running.

ConcurrentPlaybackDevice.state

python
@property
def state()

[🔗]

Retrieves ma_device_state from PlaybackDevice.

ConcurrentPlaybackDevice.volume

python
@property
def volume() -> float | None

[🔗]

Unlike Speaker volume, this volume represents the volume of the local PlaybackDevice itself, before Python processing.

Returns:

float | None: Volume of PlaybackDevice.

ConcurrentPlaybackDevice.volume

python
@volume.setter
def volume(vol: float)

[🔗]

Attempts to internally sets the volume of the internal PlaybackDevice.

Uses internal implementation _device.masterVolumeFactor, so this function may not work if harmful changes are made to miniaudio or pyminiaudio.

Function is no-op if it does not dynamically pass sanity checks on internal implementation.

Arguments:

  • vol float - The initial volume of the speaker as a percent decimal.

ConcurrentPlaybackDevice.wait

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

[🔗]

Waits for the PlaybackDevice to be stopped.

Returns:

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

ConcurrentPlaybackDevice.starting

python
@property
def starting() -> bool

[🔗]

Is the PlaybackDevice starting?

ConcurrentPlaybackDevice.stopping

python
@property
def stopping() -> bool

[🔗]

Is the PlaybackDevice stopping?

ConcurrentPlaybackDevice.stopped

python
@property
def stopped() -> bool

[🔗]

Has the PlaybackDevice stopped?

ConcurrentPlaybackDevice.closed

python
@property
def closed() -> bool

[🔗]

Is the PlaybackDevice uninitialized?

ConcurrentPlaybackDevice.started

python
@property
def started()

[🔗]

Has the PlaybackDevice started?

ConcurrentPlaybackDevice.start

python
def start(callback_generator: PlaybackCallbackGeneratorType)

[🔗]

Starts Playback with thread-safety. Is no-op on subsequent start requests while running.

Arguments:

  • callback_generator PlaybackCallbackGeneratorType - Any valid miniaudio playback generator.

ConcurrentPlaybackDevice.stop

python
def stop()

[🔗]

Stops Playback with thread-safety. Is no-op on subsequent stop requests while not running.