use serde::{Deserialize, Serialize};
pub type GraphObjectId = String;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ContextType {
#[serde(rename = "realtime")]
Realtime,
#[serde(rename = "offline")]
Offline,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ContextState {
#[serde(rename = "suspended")]
Suspended,
#[serde(rename = "running")]
Running,
#[serde(rename = "closed")]
Closed,
#[serde(rename = "interrupted")]
Interrupted,
#[serde(untagged)]
Unrecognized(String),
}
pub type NodeType = String;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ChannelCountMode {
#[serde(rename = "clamped-max")]
ClampedMax,
#[serde(rename = "explicit")]
Explicit,
#[serde(rename = "max")]
Max,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ChannelInterpretation {
#[serde(rename = "discrete")]
Discrete,
#[serde(rename = "speakers")]
Speakers,
#[serde(untagged)]
Unrecognized(String),
}
pub type ParamType = String;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AutomationRate {
#[serde(rename = "a-rate")]
ARate,
#[serde(rename = "k-rate")]
KRate,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ContextRealtimeData {
#[serde(rename = "currentTime")]
pub current_time: f64,
#[serde(rename = "renderCapacity")]
pub render_capacity: f64,
#[serde(rename = "callbackIntervalMean")]
pub callback_interval_mean: f64,
#[serde(rename = "callbackIntervalVariance")]
pub callback_interval_variance: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BaseAudioContext {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "contextType")]
pub context_type: ContextType,
#[serde(rename = "contextState")]
pub context_state: ContextState,
#[serde(
rename = "realtimeData",
default,
skip_serializing_if = "Option::is_none"
)]
pub realtime_data: Option<ContextRealtimeData>,
#[serde(rename = "callbackBufferSize")]
pub callback_buffer_size: f64,
#[serde(rename = "maxOutputChannelCount")]
pub max_output_channel_count: f64,
#[serde(rename = "sampleRate")]
pub sample_rate: f64,
#[serde(rename = "renderQuantumSize")]
pub render_quantum_size: f64,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AudioListener {
#[serde(rename = "listenerId")]
pub listener_id: GraphObjectId,
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AudioNode {
#[serde(rename = "nodeId")]
pub node_id: GraphObjectId,
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "nodeType")]
pub node_type: NodeType,
#[serde(rename = "numberOfInputs")]
pub number_of_inputs: f64,
#[serde(rename = "numberOfOutputs")]
pub number_of_outputs: f64,
#[serde(rename = "channelCount")]
pub channel_count: f64,
#[serde(rename = "channelCountMode")]
pub channel_count_mode: ChannelCountMode,
#[serde(rename = "channelInterpretation")]
pub channel_interpretation: ChannelInterpretation,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AudioParam {
#[serde(rename = "paramId")]
pub param_id: GraphObjectId,
#[serde(rename = "nodeId")]
pub node_id: GraphObjectId,
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "paramType")]
pub param_type: ParamType,
pub rate: AutomationRate,
#[serde(rename = "defaultValue")]
pub default_value: f64,
#[serde(rename = "minValue")]
pub min_value: f64,
#[serde(rename = "maxValue")]
pub max_value: f64,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}
impl crate::typed::Command for EnableParams {
const METHOD: &'static str = "WebAudio.enable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}
impl crate::typed::Command for DisableParams {
const METHOD: &'static str = "WebAudio.disable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetRealtimeDataParams {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetRealtimeDataReturns {
#[serde(rename = "realtimeData")]
pub realtime_data: ContextRealtimeData,
}
impl crate::typed::Command for GetRealtimeDataParams {
const METHOD: &'static str = "WebAudio.getRealtimeData";
type Returns = GetRealtimeDataReturns;
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ContextCreatedEvent {
pub context: BaseAudioContext,
}
impl crate::typed::Event for ContextCreatedEvent {
const METHOD: &'static str = "WebAudio.contextCreated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ContextWillBeDestroyedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
}
impl crate::typed::Event for ContextWillBeDestroyedEvent {
const METHOD: &'static str = "WebAudio.contextWillBeDestroyed";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ContextChangedEvent {
pub context: BaseAudioContext,
}
impl crate::typed::Event for ContextChangedEvent {
const METHOD: &'static str = "WebAudio.contextChanged";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AudioListenerCreatedEvent {
pub listener: AudioListener,
}
impl crate::typed::Event for AudioListenerCreatedEvent {
const METHOD: &'static str = "WebAudio.audioListenerCreated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AudioListenerWillBeDestroyedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "listenerId")]
pub listener_id: GraphObjectId,
}
impl crate::typed::Event for AudioListenerWillBeDestroyedEvent {
const METHOD: &'static str = "WebAudio.audioListenerWillBeDestroyed";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AudioNodeCreatedEvent {
pub node: AudioNode,
}
impl crate::typed::Event for AudioNodeCreatedEvent {
const METHOD: &'static str = "WebAudio.audioNodeCreated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AudioNodeWillBeDestroyedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "nodeId")]
pub node_id: GraphObjectId,
}
impl crate::typed::Event for AudioNodeWillBeDestroyedEvent {
const METHOD: &'static str = "WebAudio.audioNodeWillBeDestroyed";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AudioParamCreatedEvent {
pub param: AudioParam,
}
impl crate::typed::Event for AudioParamCreatedEvent {
const METHOD: &'static str = "WebAudio.audioParamCreated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AudioParamWillBeDestroyedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "nodeId")]
pub node_id: GraphObjectId,
#[serde(rename = "paramId")]
pub param_id: GraphObjectId,
}
impl crate::typed::Event for AudioParamWillBeDestroyedEvent {
const METHOD: &'static str = "WebAudio.audioParamWillBeDestroyed";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NodesConnectedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "sourceId")]
pub source_id: GraphObjectId,
#[serde(rename = "destinationId")]
pub destination_id: GraphObjectId,
#[serde(
rename = "sourceOutputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub source_output_index: Option<f64>,
#[serde(
rename = "destinationInputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub destination_input_index: Option<f64>,
}
impl crate::typed::Event for NodesConnectedEvent {
const METHOD: &'static str = "WebAudio.nodesConnected";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NodesDisconnectedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "sourceId")]
pub source_id: GraphObjectId,
#[serde(rename = "destinationId")]
pub destination_id: GraphObjectId,
#[serde(
rename = "sourceOutputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub source_output_index: Option<f64>,
#[serde(
rename = "destinationInputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub destination_input_index: Option<f64>,
}
impl crate::typed::Event for NodesDisconnectedEvent {
const METHOD: &'static str = "WebAudio.nodesDisconnected";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NodeParamConnectedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "sourceId")]
pub source_id: GraphObjectId,
#[serde(rename = "destinationId")]
pub destination_id: GraphObjectId,
#[serde(
rename = "sourceOutputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub source_output_index: Option<f64>,
}
impl crate::typed::Event for NodeParamConnectedEvent {
const METHOD: &'static str = "WebAudio.nodeParamConnected";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct NodeParamDisconnectedEvent {
#[serde(rename = "contextId")]
pub context_id: GraphObjectId,
#[serde(rename = "sourceId")]
pub source_id: GraphObjectId,
#[serde(rename = "destinationId")]
pub destination_id: GraphObjectId,
#[serde(
rename = "sourceOutputIndex",
default,
skip_serializing_if = "Option::is_none"
)]
pub source_output_index: Option<f64>,
}
impl crate::typed::Event for NodeParamDisconnectedEvent {
const METHOD: &'static str = "WebAudio.nodeParamDisconnected";
}