/
types.go
180 lines (151 loc) · 5.87 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Code generated by cdpgen. DO NOT EDIT.
package webaudio
// GraphObjectID An unique ID for a graph object (AudioContext, AudioNode,
// AudioParam) in Web Audio API
type GraphObjectID string
// ContextType Enum of BaseAudioContext types
type ContextType string
// ContextType as enums.
const (
ContextTypeNotSet ContextType = ""
ContextTypeRealtime ContextType = "realtime"
ContextTypeOffline ContextType = "offline"
)
func (e ContextType) Valid() bool {
switch e {
case "realtime", "offline":
return true
default:
return false
}
}
func (e ContextType) String() string {
return string(e)
}
// ContextState Enum of AudioContextState from the spec
type ContextState string
// ContextState as enums.
const (
ContextStateNotSet ContextState = ""
ContextStateSuspended ContextState = "suspended"
ContextStateRunning ContextState = "running"
ContextStateClosed ContextState = "closed"
)
func (e ContextState) Valid() bool {
switch e {
case "suspended", "running", "closed":
return true
default:
return false
}
}
func (e ContextState) String() string {
return string(e)
}
// NodeType Enum of AudioNode types
type NodeType string
// ChannelCountMode Enum of AudioNode::ChannelCountMode from the spec
type ChannelCountMode string
// ChannelCountMode as enums.
const (
ChannelCountModeNotSet ChannelCountMode = ""
ChannelCountModeClampedMax ChannelCountMode = "clamped-max"
ChannelCountModeExplicit ChannelCountMode = "explicit"
ChannelCountModeMax ChannelCountMode = "max"
)
func (e ChannelCountMode) Valid() bool {
switch e {
case "clamped-max", "explicit", "max":
return true
default:
return false
}
}
func (e ChannelCountMode) String() string {
return string(e)
}
// ChannelInterpretation Enum of AudioNode::ChannelInterpretation from the
// spec
type ChannelInterpretation string
// ChannelInterpretation as enums.
const (
ChannelInterpretationNotSet ChannelInterpretation = ""
ChannelInterpretationDiscrete ChannelInterpretation = "discrete"
ChannelInterpretationSpeakers ChannelInterpretation = "speakers"
)
func (e ChannelInterpretation) Valid() bool {
switch e {
case "discrete", "speakers":
return true
default:
return false
}
}
func (e ChannelInterpretation) String() string {
return string(e)
}
// ParamType Enum of AudioParam types
type ParamType string
// AutomationRate Enum of AudioParam::AutomationRate from the spec
type AutomationRate string
// AutomationRate as enums.
const (
AutomationRateNotSet AutomationRate = ""
AutomationRateARate AutomationRate = "a-rate"
AutomationRateKRate AutomationRate = "k-rate"
)
func (e AutomationRate) Valid() bool {
switch e {
case "a-rate", "k-rate":
return true
default:
return false
}
}
func (e AutomationRate) String() string {
return string(e)
}
// ContextRealtimeData Fields in AudioContext that change in real-time.
type ContextRealtimeData struct {
CurrentTime float64 `json:"currentTime"` // The current context time in second in BaseAudioContext.
RenderCapacity float64 `json:"renderCapacity"` // 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.
CallbackIntervalMean float64 `json:"callbackIntervalMean"` // A running mean of callback interval.
CallbackIntervalVariance float64 `json:"callbackIntervalVariance"` // A running variance of callback interval.
}
// BaseAudioContext Protocol object for BaseAudioContext
type BaseAudioContext struct {
ContextID GraphObjectID `json:"contextId"` // No description.
ContextType ContextType `json:"contextType"` // No description.
ContextState ContextState `json:"contextState"` // No description.
RealtimeData *ContextRealtimeData `json:"realtimeData,omitempty"` // No description.
CallbackBufferSize float64 `json:"callbackBufferSize"` // Platform-dependent callback buffer size.
MaxOutputChannelCount float64 `json:"maxOutputChannelCount"` // Number of output channels supported by audio hardware in use.
SampleRate float64 `json:"sampleRate"` // Context sample rate.
}
// AudioListener Protocol object for AudioListener
type AudioListener struct {
ListenerID GraphObjectID `json:"listenerId"` // No description.
ContextID GraphObjectID `json:"contextId"` // No description.
}
// AudioNode Protocol object for AudioNode
type AudioNode struct {
NodeID GraphObjectID `json:"nodeId"` // No description.
ContextID GraphObjectID `json:"contextId"` // No description.
NodeType NodeType `json:"nodeType"` // No description.
NumberOfInputs float64 `json:"numberOfInputs"` // No description.
NumberOfOutputs float64 `json:"numberOfOutputs"` // No description.
ChannelCount float64 `json:"channelCount"` // No description.
ChannelCountMode ChannelCountMode `json:"channelCountMode"` // No description.
ChannelInterpretation ChannelInterpretation `json:"channelInterpretation"` // No description.
}
// AudioParam Protocol object for AudioParam
type AudioParam struct {
ParamID GraphObjectID `json:"paramId"` // No description.
NodeID GraphObjectID `json:"nodeId"` // No description.
ContextID GraphObjectID `json:"contextId"` // No description.
ParamType ParamType `json:"paramType"` // No description.
Rate AutomationRate `json:"rate"` // No description.
DefaultValue float64 `json:"defaultValue"` // No description.
MinValue float64 `json:"minValue"` // No description.
MaxValue float64 `json:"maxValue"` // No description.
}