File tree Expand file tree Collapse file tree 3 files changed +16
-21
lines changed
tests/worklets/mdn-audioworklet-example/src/commonMain/kotlin/mdn/audioworklet/example Expand file tree Collapse file tree 3 files changed +16
-21
lines changed Original file line number Diff line number Diff line change 1
1
package mdn.audioworklet.example
2
2
3
3
import web.audio.AudioParamName
4
+ import web.audio.AudioWorkletProcessorName
4
5
5
- internal val HISS_GENERATOR : String =
6
- " hiss-generator"
6
+ internal val HISS_GENERATOR : AudioWorkletProcessorName =
7
+ AudioWorkletProcessorName ( " hiss-generator" )
7
8
8
9
internal val GAIN : AudioParamName =
9
10
AudioParamName (" gain" )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import js.typedarrays.Float32Array
6
6
import web.audio.AudioParamDescriptor
7
7
import web.audio.AudioParamName
8
8
import web.audio.AudioWorkletProcessor
9
- import web.audio.AudioWorkletProcessorCompanion
9
+ import web.audio.AudioWorkletProcessorReference
10
10
import kotlin.random.Random
11
11
12
12
/* *
@@ -78,22 +78,15 @@ class HissGeneratorProcessor : AudioWorkletProcessor() {
78
78
return true
79
79
}
80
80
81
- companion object : AudioWorkletProcessorCompanion {
82
- override val parameterDescriptors: ReadonlyArray <AudioParamDescriptor > =
83
- arrayOf(
84
- AudioParamDescriptor (
85
- name = GAIN ,
86
- defaultValue = 0.2f ,
87
- minValue = 0f ,
88
- maxValue = 1f ,
89
- )
81
+ companion object : AudioWorkletProcessorReference <HissGeneratorProcessor >(
82
+ value = HissGeneratorProcessor ::class .js,
83
+ parameterDescriptors = arrayOf(
84
+ AudioParamDescriptor (
85
+ name = GAIN ,
86
+ defaultValue = 0.2f ,
87
+ minValue = 0f ,
88
+ maxValue = 1f ,
90
89
)
91
-
92
- // TODO: Remove when `@JsStatic` will work in development mode
93
- val classRef: JsClass <out AudioWorkletProcessor > by lazy {
94
- val klass = HissGeneratorProcessor ::class .js
95
- klass.asDynamic().parameterDescriptors = parameterDescriptors
96
- klass
97
- }
98
- }
90
+ )
91
+ )
99
92
}
Original file line number Diff line number Diff line change 1
1
package mdn.audioworklet.example
2
2
3
3
import web.audio.AudioWorkletModule
4
+ import web.audio.registerProcessor
4
5
5
6
val HissGeneratorWorkletModule = AudioWorkletModule { self ->
6
- self.registerProcessor(HISS_GENERATOR , HissGeneratorProcessor .classRef )
7
+ self.registerProcessor(HISS_GENERATOR , HissGeneratorProcessor )
7
8
}
You can’t perform that action at this time.
0 commit comments