# `mopidy.mixer` — Audio mixer API

class mopidy.mixer.Mixer(config: Dict)

  Audio mixer API

  If the mixer has problems during initialization it should raise `mopidy.exceptions.MixerError` with a descriptive error message. This will make Mopidy print the error message and exit so that the user can fix the issue.

  Parameters:

    config (dict) – the entire Mopidy configuration

  get_mute() → bool | None

    Get mute state of the mixer.

    MAY be implemented by subclass.

    Return type:

      `True` if muted, `False` if unmuted, `None` if unknown.

  get_volume() → int | None

    Get volume level of the mixer on a linear scale from 0 to 100.

    Example values:

    0:

      Minimum volume, usually silent.

    100:

      Maximum volume.

    `None`:

      Volume is unknown.

    MAY be implemented by subclass.

    Return type:

      int in range [0..100] or `None`

  name: str

    Name of the mixer.

    Used when configuring what mixer to use. Should match the `ext_name` of the extension providing the mixer.

  ping() → bool

    Called to check if the actor is still alive.

  set_mute(mute: bool) → bool

    Mute or unmute the mixer.

    MAY be implemented by subclass.

    Parameters:

      mute (bool) – `True` to mute, `False` to unmute

    Return type:

      `True` if success, `False` if failure

  set_volume(volume: int) → bool

    Set volume level of the mixer.

    MAY be implemented by subclass.

    Parameters:

      volume (int) – Volume in the range [0..100]

    Return type:

      `True` if success, `False` if failure

  trigger_mute_changed(mute: bool) → None

    Send `mute_changed` event to all mixer listeners.

    This method should be called by subclasses when the mute state is changed, either because of a call to `set_mute()` or because of any external entity changing the mute state.

  trigger_volume_changed(volume: int) → None

    Send `volume_changed` event to all mixer listeners.

    This method should be called by subclasses when the volume is changed, either because of a call to `set_volume()` or because of any external entity changing the volume.

class mopidy.mixer.MixerListener

  Marker interface for recipients of events sent by the mixer actor.

  Any Pykka actor that mixes in this class will receive calls to the methods defined here when the corresponding events happen in the mixer actor. This interface is used both for looking up what actors to notify of the events, and for providing default implementations for those listeners that are not interested in all events.

  mute_changed(mute: bool) → None

    Called after the mute state has changed.

    MAY be implemented by actor.

    Parameters:

      mute (bool) – `True` if muted, `False` if not muted

  static send(event: MixerEvent, **kwargs: Any) → None

    Helper to allow calling of mixer listener events

  volume_changed(volume: int) → None

    Called after the volume has changed.

    MAY be implemented by actor.

    Parameters:

      volume (int in range [0..100]) – the new volume

## Mixer implementations

See the extension registry.