Devices
minispeaker.devices
default_speaker
def default_speaker() -> strRetrieves 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
def available_speakers() -> List[str]Retrieves all available speakers by name.
Returns:
List[str]- A list of available speakers
MaDeviceState
class MaDeviceState(Enum)Miniaudio equivalent enum of ma_device_state.
Arguments:
Enumtype - Pythonic version ofma_device_state
Attributes:
UNINITIALIZED- Device has not been initialized yetSTOPPED- Device is initialized but not actively processing audioSTARTED- Device is actively processing audioSTOPPING- Device is in the process of stoppingSTARTING- Device is in the process of starting
ConcurrentPlaybackDevice
class ConcurrentPlaybackDevice(PlaybackDevice)Modified miniaudio PlaybackDevice class with accessible ma_device_state and thread-safe concurrency.
Arguments:
*args- Variable length argument list passed to parentPlaybackDevice.stoppedEvent - Used to signal when aPlaybackDeviceis finished.**kwargs- Arbitrary keyword arguments passed to parentPlaybackDevice.
Attributes:
stateMaDeviceState - Current state of the audio device.volumefloat | None - Volume level of the PlaybackDevice (0.0 to 1.0+).startingbool - True if the device is currently starting.stoppingbool - True if the device is currently stopping.stoppedbool - True if the device has stopped.closedbool - True if the device is uninitialized/closed.startedbool - True if the device has started and is running.
ConcurrentPlaybackDevice.state
@property
def state()Retrieves ma_device_state from PlaybackDevice.
ConcurrentPlaybackDevice.volume
@property
def volume() -> float | NoneUnlike Speaker volume, this volume represents the volume of the local PlaybackDevice itself, before Python processing.
Returns:
float | None: Volume of PlaybackDevice.
ConcurrentPlaybackDevice.volume
@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:
volfloat - The initial volume of the speaker as a percent decimal.
ConcurrentPlaybackDevice.wait
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
@property
def starting() -> boolIs the PlaybackDevice starting?
ConcurrentPlaybackDevice.stopping
@property
def stopping() -> boolIs the PlaybackDevice stopping?
ConcurrentPlaybackDevice.stopped
@property
def stopped() -> boolHas the PlaybackDevice stopped?
ConcurrentPlaybackDevice.closed
@property
def closed() -> boolIs the PlaybackDevice uninitialized?
ConcurrentPlaybackDevice.started
@property
def started()Has the PlaybackDevice started?
ConcurrentPlaybackDevice.start
def start(callback_generator: PlaybackCallbackGeneratorType)Starts Playback with thread-safety. Is no-op on subsequent start requests while running.
Arguments:
callback_generatorPlaybackCallbackGeneratorType - Any valid miniaudio playback generator.
ConcurrentPlaybackDevice.stop
def stop()Stops Playback with thread-safety. Is no-op on subsequent stop requests while not running.