Skip to content

web_audio

AudioListener dataclass

Protocol object for AudioListener

Source code in zendriver/cdp/web_audio.py
@dataclass
class AudioListener:
    """
    Protocol object for AudioListener
    """

    listener_id: GraphObjectId

    context_id: GraphObjectId

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["listenerId"] = self.listener_id.to_json()
        json["contextId"] = self.context_id.to_json()
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioListener:
        return cls(
            listener_id=GraphObjectId.from_json(json["listenerId"]),
            context_id=GraphObjectId.from_json(json["contextId"]),
        )

context_id: GraphObjectId instance-attribute

listener_id: GraphObjectId instance-attribute

__init__(listener_id, context_id)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioListener:
    return cls(
        listener_id=GraphObjectId.from_json(json["listenerId"]),
        context_id=GraphObjectId.from_json(json["contextId"]),
    )

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["listenerId"] = self.listener_id.to_json()
    json["contextId"] = self.context_id.to_json()
    return json

AudioListenerCreated dataclass

Notifies that the construction of an AudioListener has finished.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioListenerCreated")
@dataclass
class AudioListenerCreated:
    """
    Notifies that the construction of an AudioListener has finished.
    """

    listener: AudioListener

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioListenerCreated:
        return cls(listener=AudioListener.from_json(json["listener"]))

listener: AudioListener instance-attribute

__init__(listener)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioListenerCreated:
    return cls(listener=AudioListener.from_json(json["listener"]))

AudioListenerWillBeDestroyed dataclass

Notifies that a new AudioListener has been created.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioListenerWillBeDestroyed")
@dataclass
class AudioListenerWillBeDestroyed:
    """
    Notifies that a new AudioListener has been created.
    """

    context_id: GraphObjectId
    listener_id: GraphObjectId

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioListenerWillBeDestroyed:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            listener_id=GraphObjectId.from_json(json["listenerId"]),
        )

context_id: GraphObjectId instance-attribute

listener_id: GraphObjectId instance-attribute

__init__(context_id, listener_id)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioListenerWillBeDestroyed:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        listener_id=GraphObjectId.from_json(json["listenerId"]),
    )

AudioNode dataclass

Protocol object for AudioNode

Source code in zendriver/cdp/web_audio.py
@dataclass
class AudioNode:
    """
    Protocol object for AudioNode
    """

    node_id: GraphObjectId

    context_id: GraphObjectId

    node_type: NodeType

    number_of_inputs: float

    number_of_outputs: float

    channel_count: float

    channel_count_mode: ChannelCountMode

    channel_interpretation: ChannelInterpretation

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["nodeId"] = self.node_id.to_json()
        json["contextId"] = self.context_id.to_json()
        json["nodeType"] = self.node_type.to_json()
        json["numberOfInputs"] = self.number_of_inputs
        json["numberOfOutputs"] = self.number_of_outputs
        json["channelCount"] = self.channel_count
        json["channelCountMode"] = self.channel_count_mode.to_json()
        json["channelInterpretation"] = self.channel_interpretation.to_json()
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioNode:
        return cls(
            node_id=GraphObjectId.from_json(json["nodeId"]),
            context_id=GraphObjectId.from_json(json["contextId"]),
            node_type=NodeType.from_json(json["nodeType"]),
            number_of_inputs=float(json["numberOfInputs"]),
            number_of_outputs=float(json["numberOfOutputs"]),
            channel_count=float(json["channelCount"]),
            channel_count_mode=ChannelCountMode.from_json(json["channelCountMode"]),
            channel_interpretation=ChannelInterpretation.from_json(
                json["channelInterpretation"]
            ),
        )

channel_count: float instance-attribute

channel_count_mode: ChannelCountMode instance-attribute

channel_interpretation: ChannelInterpretation instance-attribute

context_id: GraphObjectId instance-attribute

node_id: GraphObjectId instance-attribute

node_type: NodeType instance-attribute

number_of_inputs: float instance-attribute

number_of_outputs: float instance-attribute

__init__(node_id, context_id, node_type, number_of_inputs, number_of_outputs, channel_count, channel_count_mode, channel_interpretation)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioNode:
    return cls(
        node_id=GraphObjectId.from_json(json["nodeId"]),
        context_id=GraphObjectId.from_json(json["contextId"]),
        node_type=NodeType.from_json(json["nodeType"]),
        number_of_inputs=float(json["numberOfInputs"]),
        number_of_outputs=float(json["numberOfOutputs"]),
        channel_count=float(json["channelCount"]),
        channel_count_mode=ChannelCountMode.from_json(json["channelCountMode"]),
        channel_interpretation=ChannelInterpretation.from_json(
            json["channelInterpretation"]
        ),
    )

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["nodeId"] = self.node_id.to_json()
    json["contextId"] = self.context_id.to_json()
    json["nodeType"] = self.node_type.to_json()
    json["numberOfInputs"] = self.number_of_inputs
    json["numberOfOutputs"] = self.number_of_outputs
    json["channelCount"] = self.channel_count
    json["channelCountMode"] = self.channel_count_mode.to_json()
    json["channelInterpretation"] = self.channel_interpretation.to_json()
    return json

AudioNodeCreated dataclass

Notifies that a new AudioNode has been created.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioNodeCreated")
@dataclass
class AudioNodeCreated:
    """
    Notifies that a new AudioNode has been created.
    """

    node: AudioNode

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioNodeCreated:
        return cls(node=AudioNode.from_json(json["node"]))

node: AudioNode instance-attribute

__init__(node)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioNodeCreated:
    return cls(node=AudioNode.from_json(json["node"]))

AudioNodeWillBeDestroyed dataclass

Notifies that an existing AudioNode has been destroyed.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioNodeWillBeDestroyed")
@dataclass
class AudioNodeWillBeDestroyed:
    """
    Notifies that an existing AudioNode has been destroyed.
    """

    context_id: GraphObjectId
    node_id: GraphObjectId

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioNodeWillBeDestroyed:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            node_id=GraphObjectId.from_json(json["nodeId"]),
        )

context_id: GraphObjectId instance-attribute

node_id: GraphObjectId instance-attribute

__init__(context_id, node_id)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioNodeWillBeDestroyed:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        node_id=GraphObjectId.from_json(json["nodeId"]),
    )

AudioParam dataclass

Protocol object for AudioParam

Source code in zendriver/cdp/web_audio.py
@dataclass
class AudioParam:
    """
    Protocol object for AudioParam
    """

    param_id: GraphObjectId

    node_id: GraphObjectId

    context_id: GraphObjectId

    param_type: ParamType

    rate: AutomationRate

    default_value: float

    min_value: float

    max_value: float

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["paramId"] = self.param_id.to_json()
        json["nodeId"] = self.node_id.to_json()
        json["contextId"] = self.context_id.to_json()
        json["paramType"] = self.param_type.to_json()
        json["rate"] = self.rate.to_json()
        json["defaultValue"] = self.default_value
        json["minValue"] = self.min_value
        json["maxValue"] = self.max_value
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioParam:
        return cls(
            param_id=GraphObjectId.from_json(json["paramId"]),
            node_id=GraphObjectId.from_json(json["nodeId"]),
            context_id=GraphObjectId.from_json(json["contextId"]),
            param_type=ParamType.from_json(json["paramType"]),
            rate=AutomationRate.from_json(json["rate"]),
            default_value=float(json["defaultValue"]),
            min_value=float(json["minValue"]),
            max_value=float(json["maxValue"]),
        )

context_id: GraphObjectId instance-attribute

default_value: float instance-attribute

max_value: float instance-attribute

min_value: float instance-attribute

node_id: GraphObjectId instance-attribute

param_id: GraphObjectId instance-attribute

param_type: ParamType instance-attribute

rate: AutomationRate instance-attribute

__init__(param_id, node_id, context_id, param_type, rate, default_value, min_value, max_value)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioParam:
    return cls(
        param_id=GraphObjectId.from_json(json["paramId"]),
        node_id=GraphObjectId.from_json(json["nodeId"]),
        context_id=GraphObjectId.from_json(json["contextId"]),
        param_type=ParamType.from_json(json["paramType"]),
        rate=AutomationRate.from_json(json["rate"]),
        default_value=float(json["defaultValue"]),
        min_value=float(json["minValue"]),
        max_value=float(json["maxValue"]),
    )

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["paramId"] = self.param_id.to_json()
    json["nodeId"] = self.node_id.to_json()
    json["contextId"] = self.context_id.to_json()
    json["paramType"] = self.param_type.to_json()
    json["rate"] = self.rate.to_json()
    json["defaultValue"] = self.default_value
    json["minValue"] = self.min_value
    json["maxValue"] = self.max_value
    return json

AudioParamCreated dataclass

Notifies that a new AudioParam has been created.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioParamCreated")
@dataclass
class AudioParamCreated:
    """
    Notifies that a new AudioParam has been created.
    """

    param: AudioParam

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioParamCreated:
        return cls(param=AudioParam.from_json(json["param"]))

param: AudioParam instance-attribute

__init__(param)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioParamCreated:
    return cls(param=AudioParam.from_json(json["param"]))

AudioParamWillBeDestroyed dataclass

Notifies that an existing AudioParam has been destroyed.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.audioParamWillBeDestroyed")
@dataclass
class AudioParamWillBeDestroyed:
    """
    Notifies that an existing AudioParam has been destroyed.
    """

    context_id: GraphObjectId
    node_id: GraphObjectId
    param_id: GraphObjectId

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AudioParamWillBeDestroyed:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            node_id=GraphObjectId.from_json(json["nodeId"]),
            param_id=GraphObjectId.from_json(json["paramId"]),
        )

context_id: GraphObjectId instance-attribute

node_id: GraphObjectId instance-attribute

param_id: GraphObjectId instance-attribute

__init__(context_id, node_id, param_id)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AudioParamWillBeDestroyed:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        node_id=GraphObjectId.from_json(json["nodeId"]),
        param_id=GraphObjectId.from_json(json["paramId"]),
    )

AutomationRate

Bases: Enum

Enum of AudioParam::AutomationRate from the spec

Source code in zendriver/cdp/web_audio.py
class AutomationRate(enum.Enum):
    """
    Enum of AudioParam::AutomationRate from the spec
    """

    A_RATE = "a-rate"
    K_RATE = "k-rate"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> AutomationRate:
        return cls(json)

A_RATE = 'a-rate' class-attribute instance-attribute

K_RATE = 'k-rate' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> AutomationRate:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self.value

BaseAudioContext dataclass

Protocol object for BaseAudioContext

Source code in zendriver/cdp/web_audio.py
@dataclass
class BaseAudioContext:
    """
    Protocol object for BaseAudioContext
    """

    context_id: GraphObjectId

    context_type: ContextType

    context_state: ContextState

    #: Platform-dependent callback buffer size.
    callback_buffer_size: float

    #: Number of output channels supported by audio hardware in use.
    max_output_channel_count: float

    #: Context sample rate.
    sample_rate: float

    realtime_data: typing.Optional[ContextRealtimeData] = None

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["contextId"] = self.context_id.to_json()
        json["contextType"] = self.context_type.to_json()
        json["contextState"] = self.context_state.to_json()
        json["callbackBufferSize"] = self.callback_buffer_size
        json["maxOutputChannelCount"] = self.max_output_channel_count
        json["sampleRate"] = self.sample_rate
        if self.realtime_data is not None:
            json["realtimeData"] = self.realtime_data.to_json()
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> BaseAudioContext:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            context_type=ContextType.from_json(json["contextType"]),
            context_state=ContextState.from_json(json["contextState"]),
            callback_buffer_size=float(json["callbackBufferSize"]),
            max_output_channel_count=float(json["maxOutputChannelCount"]),
            sample_rate=float(json["sampleRate"]),
            realtime_data=(
                ContextRealtimeData.from_json(json["realtimeData"])
                if json.get("realtimeData", None) is not None
                else None
            ),
        )

callback_buffer_size: float instance-attribute

context_id: GraphObjectId instance-attribute

context_state: ContextState instance-attribute

context_type: ContextType instance-attribute

max_output_channel_count: float instance-attribute

realtime_data: typing.Optional[ContextRealtimeData] = None class-attribute instance-attribute

sample_rate: float instance-attribute

__init__(context_id, context_type, context_state, callback_buffer_size, max_output_channel_count, sample_rate, realtime_data=None)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> BaseAudioContext:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        context_type=ContextType.from_json(json["contextType"]),
        context_state=ContextState.from_json(json["contextState"]),
        callback_buffer_size=float(json["callbackBufferSize"]),
        max_output_channel_count=float(json["maxOutputChannelCount"]),
        sample_rate=float(json["sampleRate"]),
        realtime_data=(
            ContextRealtimeData.from_json(json["realtimeData"])
            if json.get("realtimeData", None) is not None
            else None
        ),
    )

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["contextId"] = self.context_id.to_json()
    json["contextType"] = self.context_type.to_json()
    json["contextState"] = self.context_state.to_json()
    json["callbackBufferSize"] = self.callback_buffer_size
    json["maxOutputChannelCount"] = self.max_output_channel_count
    json["sampleRate"] = self.sample_rate
    if self.realtime_data is not None:
        json["realtimeData"] = self.realtime_data.to_json()
    return json

ChannelCountMode

Bases: Enum

Enum of AudioNode::ChannelCountMode from the spec

Source code in zendriver/cdp/web_audio.py
class ChannelCountMode(enum.Enum):
    """
    Enum of AudioNode::ChannelCountMode from the spec
    """

    CLAMPED_MAX = "clamped-max"
    EXPLICIT = "explicit"
    MAX_ = "max"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> ChannelCountMode:
        return cls(json)

CLAMPED_MAX = 'clamped-max' class-attribute instance-attribute

EXPLICIT = 'explicit' class-attribute instance-attribute

MAX_ = 'max' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> ChannelCountMode:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self.value

ChannelInterpretation

Bases: Enum

Enum of AudioNode::ChannelInterpretation from the spec

Source code in zendriver/cdp/web_audio.py
class ChannelInterpretation(enum.Enum):
    """
    Enum of AudioNode::ChannelInterpretation from the spec
    """

    DISCRETE = "discrete"
    SPEAKERS = "speakers"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> ChannelInterpretation:
        return cls(json)

DISCRETE = 'discrete' class-attribute instance-attribute

SPEAKERS = 'speakers' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> ChannelInterpretation:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self.value

ContextChanged dataclass

Notifies that existing BaseAudioContext has changed some properties (id stays the same)..

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.contextChanged")
@dataclass
class ContextChanged:
    """
    Notifies that existing BaseAudioContext has changed some properties (id stays the same)..
    """

    context: BaseAudioContext

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> ContextChanged:
        return cls(context=BaseAudioContext.from_json(json["context"]))

context: BaseAudioContext instance-attribute

__init__(context)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ContextChanged:
    return cls(context=BaseAudioContext.from_json(json["context"]))

ContextCreated dataclass

Notifies that a new BaseAudioContext has been created.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.contextCreated")
@dataclass
class ContextCreated:
    """
    Notifies that a new BaseAudioContext has been created.
    """

    context: BaseAudioContext

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> ContextCreated:
        return cls(context=BaseAudioContext.from_json(json["context"]))

context: BaseAudioContext instance-attribute

__init__(context)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ContextCreated:
    return cls(context=BaseAudioContext.from_json(json["context"]))

ContextRealtimeData dataclass

Fields in AudioContext that change in real-time.

Source code in zendriver/cdp/web_audio.py
@dataclass
class ContextRealtimeData:
    """
    Fields in AudioContext that change in real-time.
    """

    #: The current context time in second in BaseAudioContext.
    current_time: float

    #: The time spent on rendering graph divided by render quantum duration,
    #: and multiplied by 100. 100 means the audio renderer reached the full
    #: capacity and glitch may occur.
    render_capacity: float

    #: A running mean of callback interval.
    callback_interval_mean: float

    #: A running variance of callback interval.
    callback_interval_variance: float

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["currentTime"] = self.current_time
        json["renderCapacity"] = self.render_capacity
        json["callbackIntervalMean"] = self.callback_interval_mean
        json["callbackIntervalVariance"] = self.callback_interval_variance
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> ContextRealtimeData:
        return cls(
            current_time=float(json["currentTime"]),
            render_capacity=float(json["renderCapacity"]),
            callback_interval_mean=float(json["callbackIntervalMean"]),
            callback_interval_variance=float(json["callbackIntervalVariance"]),
        )

callback_interval_mean: float instance-attribute

callback_interval_variance: float instance-attribute

current_time: float instance-attribute

render_capacity: float instance-attribute

__init__(current_time, render_capacity, callback_interval_mean, callback_interval_variance)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ContextRealtimeData:
    return cls(
        current_time=float(json["currentTime"]),
        render_capacity=float(json["renderCapacity"]),
        callback_interval_mean=float(json["callbackIntervalMean"]),
        callback_interval_variance=float(json["callbackIntervalVariance"]),
    )

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["currentTime"] = self.current_time
    json["renderCapacity"] = self.render_capacity
    json["callbackIntervalMean"] = self.callback_interval_mean
    json["callbackIntervalVariance"] = self.callback_interval_variance
    return json

ContextState

Bases: Enum

Enum of AudioContextState from the spec

Source code in zendriver/cdp/web_audio.py
class ContextState(enum.Enum):
    """
    Enum of AudioContextState from the spec
    """

    SUSPENDED = "suspended"
    RUNNING = "running"
    CLOSED = "closed"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> ContextState:
        return cls(json)

CLOSED = 'closed' class-attribute instance-attribute

RUNNING = 'running' class-attribute instance-attribute

SUSPENDED = 'suspended' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> ContextState:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self.value

ContextType

Bases: Enum

Enum of BaseAudioContext types

Source code in zendriver/cdp/web_audio.py
class ContextType(enum.Enum):
    """
    Enum of BaseAudioContext types
    """

    REALTIME = "realtime"
    OFFLINE = "offline"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> ContextType:
        return cls(json)

OFFLINE = 'offline' class-attribute instance-attribute

REALTIME = 'realtime' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> ContextType:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self.value

ContextWillBeDestroyed dataclass

Notifies that an existing BaseAudioContext will be destroyed.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.contextWillBeDestroyed")
@dataclass
class ContextWillBeDestroyed:
    """
    Notifies that an existing BaseAudioContext will be destroyed.
    """

    context_id: GraphObjectId

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> ContextWillBeDestroyed:
        return cls(context_id=GraphObjectId.from_json(json["contextId"]))

context_id: GraphObjectId instance-attribute

__init__(context_id)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ContextWillBeDestroyed:
    return cls(context_id=GraphObjectId.from_json(json["contextId"]))

GraphObjectId

Bases: str

An unique ID for a graph object (AudioContext, AudioNode, AudioParam) in Web Audio API

Source code in zendriver/cdp/web_audio.py
class GraphObjectId(str):
    """
    An unique ID for a graph object (AudioContext, AudioNode, AudioParam) in Web Audio API
    """

    def to_json(self) -> str:
        return self

    @classmethod
    def from_json(cls, json: str) -> GraphObjectId:
        return cls(json)

    def __repr__(self):
        return "GraphObjectId({})".format(super().__repr__())

__repr__()

Source code in zendriver/cdp/web_audio.py
def __repr__(self):
    return "GraphObjectId({})".format(super().__repr__())

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> GraphObjectId:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self

NodeParamConnected dataclass

Notifies that an AudioNode is connected to an AudioParam.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.nodeParamConnected")
@dataclass
class NodeParamConnected:
    """
    Notifies that an AudioNode is connected to an AudioParam.
    """

    context_id: GraphObjectId
    source_id: GraphObjectId
    destination_id: GraphObjectId
    source_output_index: typing.Optional[float]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> NodeParamConnected:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            source_id=GraphObjectId.from_json(json["sourceId"]),
            destination_id=GraphObjectId.from_json(json["destinationId"]),
            source_output_index=(
                float(json["sourceOutputIndex"])
                if json.get("sourceOutputIndex", None) is not None
                else None
            ),
        )

context_id: GraphObjectId instance-attribute

destination_id: GraphObjectId instance-attribute

source_id: GraphObjectId instance-attribute

source_output_index: typing.Optional[float] instance-attribute

__init__(context_id, source_id, destination_id, source_output_index)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> NodeParamConnected:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        source_id=GraphObjectId.from_json(json["sourceId"]),
        destination_id=GraphObjectId.from_json(json["destinationId"]),
        source_output_index=(
            float(json["sourceOutputIndex"])
            if json.get("sourceOutputIndex", None) is not None
            else None
        ),
    )

NodeParamDisconnected dataclass

Notifies that an AudioNode is disconnected to an AudioParam.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.nodeParamDisconnected")
@dataclass
class NodeParamDisconnected:
    """
    Notifies that an AudioNode is disconnected to an AudioParam.
    """

    context_id: GraphObjectId
    source_id: GraphObjectId
    destination_id: GraphObjectId
    source_output_index: typing.Optional[float]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> NodeParamDisconnected:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            source_id=GraphObjectId.from_json(json["sourceId"]),
            destination_id=GraphObjectId.from_json(json["destinationId"]),
            source_output_index=(
                float(json["sourceOutputIndex"])
                if json.get("sourceOutputIndex", None) is not None
                else None
            ),
        )

context_id: GraphObjectId instance-attribute

destination_id: GraphObjectId instance-attribute

source_id: GraphObjectId instance-attribute

source_output_index: typing.Optional[float] instance-attribute

__init__(context_id, source_id, destination_id, source_output_index)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> NodeParamDisconnected:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        source_id=GraphObjectId.from_json(json["sourceId"]),
        destination_id=GraphObjectId.from_json(json["destinationId"]),
        source_output_index=(
            float(json["sourceOutputIndex"])
            if json.get("sourceOutputIndex", None) is not None
            else None
        ),
    )

NodeType

Bases: str

Enum of AudioNode types

Source code in zendriver/cdp/web_audio.py
class NodeType(str):
    """
    Enum of AudioNode types
    """

    def to_json(self) -> str:
        return self

    @classmethod
    def from_json(cls, json: str) -> NodeType:
        return cls(json)

    def __repr__(self):
        return "NodeType({})".format(super().__repr__())

__repr__()

Source code in zendriver/cdp/web_audio.py
def __repr__(self):
    return "NodeType({})".format(super().__repr__())

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> NodeType:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self

NodesConnected dataclass

Notifies that two AudioNodes are connected.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.nodesConnected")
@dataclass
class NodesConnected:
    """
    Notifies that two AudioNodes are connected.
    """

    context_id: GraphObjectId
    source_id: GraphObjectId
    destination_id: GraphObjectId
    source_output_index: typing.Optional[float]
    destination_input_index: typing.Optional[float]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> NodesConnected:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            source_id=GraphObjectId.from_json(json["sourceId"]),
            destination_id=GraphObjectId.from_json(json["destinationId"]),
            source_output_index=(
                float(json["sourceOutputIndex"])
                if json.get("sourceOutputIndex", None) is not None
                else None
            ),
            destination_input_index=(
                float(json["destinationInputIndex"])
                if json.get("destinationInputIndex", None) is not None
                else None
            ),
        )

context_id: GraphObjectId instance-attribute

destination_id: GraphObjectId instance-attribute

destination_input_index: typing.Optional[float] instance-attribute

source_id: GraphObjectId instance-attribute

source_output_index: typing.Optional[float] instance-attribute

__init__(context_id, source_id, destination_id, source_output_index, destination_input_index)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> NodesConnected:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        source_id=GraphObjectId.from_json(json["sourceId"]),
        destination_id=GraphObjectId.from_json(json["destinationId"]),
        source_output_index=(
            float(json["sourceOutputIndex"])
            if json.get("sourceOutputIndex", None) is not None
            else None
        ),
        destination_input_index=(
            float(json["destinationInputIndex"])
            if json.get("destinationInputIndex", None) is not None
            else None
        ),
    )

NodesDisconnected dataclass

Notifies that AudioNodes are disconnected. The destination can be null, and it means all the outgoing connections from the source are disconnected.

Source code in zendriver/cdp/web_audio.py
@event_class("WebAudio.nodesDisconnected")
@dataclass
class NodesDisconnected:
    """
    Notifies that AudioNodes are disconnected. The destination can be null, and it means all the outgoing connections from the source are disconnected.
    """

    context_id: GraphObjectId
    source_id: GraphObjectId
    destination_id: GraphObjectId
    source_output_index: typing.Optional[float]
    destination_input_index: typing.Optional[float]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> NodesDisconnected:
        return cls(
            context_id=GraphObjectId.from_json(json["contextId"]),
            source_id=GraphObjectId.from_json(json["sourceId"]),
            destination_id=GraphObjectId.from_json(json["destinationId"]),
            source_output_index=(
                float(json["sourceOutputIndex"])
                if json.get("sourceOutputIndex", None) is not None
                else None
            ),
            destination_input_index=(
                float(json["destinationInputIndex"])
                if json.get("destinationInputIndex", None) is not None
                else None
            ),
        )

context_id: GraphObjectId instance-attribute

destination_id: GraphObjectId instance-attribute

destination_input_index: typing.Optional[float] instance-attribute

source_id: GraphObjectId instance-attribute

source_output_index: typing.Optional[float] instance-attribute

__init__(context_id, source_id, destination_id, source_output_index, destination_input_index)

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> NodesDisconnected:
    return cls(
        context_id=GraphObjectId.from_json(json["contextId"]),
        source_id=GraphObjectId.from_json(json["sourceId"]),
        destination_id=GraphObjectId.from_json(json["destinationId"]),
        source_output_index=(
            float(json["sourceOutputIndex"])
            if json.get("sourceOutputIndex", None) is not None
            else None
        ),
        destination_input_index=(
            float(json["destinationInputIndex"])
            if json.get("destinationInputIndex", None) is not None
            else None
        ),
    )

ParamType

Bases: str

Enum of AudioParam types

Source code in zendriver/cdp/web_audio.py
class ParamType(str):
    """
    Enum of AudioParam types
    """

    def to_json(self) -> str:
        return self

    @classmethod
    def from_json(cls, json: str) -> ParamType:
        return cls(json)

    def __repr__(self):
        return "ParamType({})".format(super().__repr__())

__repr__()

Source code in zendriver/cdp/web_audio.py
def __repr__(self):
    return "ParamType({})".format(super().__repr__())

from_json(json) classmethod

Source code in zendriver/cdp/web_audio.py
@classmethod
def from_json(cls, json: str) -> ParamType:
    return cls(json)

to_json()

Source code in zendriver/cdp/web_audio.py
def to_json(self) -> str:
    return self

disable()

Disables the WebAudio domain.

Source code in zendriver/cdp/web_audio.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Disables the WebAudio domain.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "WebAudio.disable",
    }
    json = yield cmd_dict

enable()

Enables the WebAudio domain and starts sending context lifetime events.

Source code in zendriver/cdp/web_audio.py
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Enables the WebAudio domain and starts sending context lifetime events.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "WebAudio.enable",
    }
    json = yield cmd_dict

get_realtime_data(context_id)

Fetch the realtime data from the registered contexts.

Parameters:

Name Type Description Default
context_id GraphObjectId
required

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, ContextRealtimeData]
Source code in zendriver/cdp/web_audio.py
def get_realtime_data(
    context_id: GraphObjectId,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, ContextRealtimeData]:
    """
    Fetch the realtime data from the registered contexts.

    :param context_id:
    :returns:
    """
    params: T_JSON_DICT = dict()
    params["contextId"] = context_id.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "WebAudio.getRealtimeData",
        "params": params,
    }
    json = yield cmd_dict
    return ContextRealtimeData.from_json(json["realtimeData"])