simvx.core.audio_bus

Audio bus system – named buses with volume, mute, and routing.

Provides a mixing hierarchy similar to Godot’s audio bus layout. Buses can route to parent buses (e.g., SFX -> Master, Music -> Master), and the final volume is computed by walking the chain.

Public API: from simvx.core.audio_bus import AudioBusLayout, AudioBus

layout = AudioBusLayout.get_default()
layout.get_bus("Music").volume_db = -6.0
layout.get_bus("SFX").mute = True

# Effective volume considers the full chain:
effective = layout.get_effective_volume("SFX")

Module Contents

Classes

AudioBus

A single audio bus with volume, mute, and parent routing.

AudioBusLayout

Collection of audio buses with routing and volume computation.

Data

API

simvx.core.audio_bus.log

‘getLogger(…)’

simvx.core.audio_bus.__all__

[‘AudioBus’, ‘AudioBusLayout’]

class simvx.core.audio_bus.AudioBus(name: str, volume_db: float = 0.0, send_to: str = '')

A single audio bus with volume, mute, and parent routing.

Attributes: name: Bus display name (e.g., “Master”, “SFX”). volume_db: Volume in decibels (-80 to 24). 0 = full volume. mute: If True, this bus and all children produce no output. solo: If True, only this bus (and its children) produce output. send_to: Name of the parent bus this routes to (empty for Master).

Initialization

__slots__

(‘name’, ‘volume_db’, ‘mute’, ‘solo’, ‘send_to’, ‘_effects’)

get_linear_volume() float

Convert volume_db to linear scale (0.0 to ~15.85).

add_effect(effect: Any) None

Add an audio effect to this bus’s processing chain.

remove_effect(effect: Any) None

Remove an audio effect from this bus.

property effects: list[Any]

Read-only view of effects on this bus.

__repr__() str
class simvx.core.audio_bus.AudioBusLayout

Collection of audio buses with routing and volume computation.

Default layout creates four buses: Master (root) <- Music, SFX, Voice

Initialization

add_bus(name: str, volume_db: float = 0.0, send_to: str = '') simvx.core.audio_bus.AudioBus

Add a new audio bus.

Args: name: Unique bus name. volume_db: Initial volume in dB. send_to: Name of parent bus to route to.

Returns: The created AudioBus.

remove_bus(name: str) None

Remove a bus by name. Cannot remove Master.

get_bus(name: str) simvx.core.audio_bus.AudioBus | None

Get a bus by name, or None if not found.

property buses: list[simvx.core.audio_bus.AudioBus]

All buses in the layout.

property bus_names: list[str]

Names of all buses.

get_effective_volume(bus_name: str) float

Compute effective volume in dB by walking the bus chain to Master.

The effective volume is the sum of volume_db values along the chain. If any bus in the chain is muted, returns -80 (silent).

get_effective_linear(bus_name: str) float

Compute effective volume as linear multiplier (0.0 to ~15.85).

classmethod get_default() simvx.core.audio_bus.AudioBusLayout

Return the default bus layout (Master, Music, SFX, Voice).

classmethod create_default() simvx.core.audio_bus.AudioBusLayout

Create the standard four-bus layout.

classmethod reset()

Reset the default layout singleton (for tests).

to_dict() list[dict]

Serialize to JSON-compatible format.

classmethod from_dict(data: list[dict]) simvx.core.audio_bus.AudioBusLayout

Deserialize from JSON format.