Model

SoundModel

class SoundModel(event_bus: EventBus)[source]

Bases: object

Network listener and data dispatcher for the audio engine.

This class operates as the primary data gateway. It listens for incoming UDP packets containing simulation state data (in JSON format), decodes them, and identifies changes between consecutive data frames. Significant changes are then published to the EventBus to notify registered adapters.

bus

The central communication hub for publishing simulation updates.

Type:

EventBus

sock

The UDP socket used for receiving simulation data.

Type:

socket.socket

client_data

A local cache of the most recent data frame received from the simulation client.

Type:

dict

__init__(event_bus: EventBus)[source]

Initializes the network socket and binds it to the local UDP endpoint.

Parameters:

event_bus (EventBus) – The bus instance where simulation data will be dispatched.

on_tick() None[source]

Main execution loop for the network listener.

Captures a new data frame, identifies changed attributes, and publishes the differences to the EventBus. This should be called frequently (typically within the main program loop) to ensure audio-simulation synchronicity.