File tree Expand file tree Collapse file tree 2 files changed +20
-21
lines changed
tests/worklets/mdn-audioworklet-example/src/commonMain/kotlin/mdn/audioworklet/example Expand file tree Collapse file tree 2 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,7 @@ import kotlin.random.Random
15
15
* @class HissGeneratorProcessor
16
16
* @extends AudioWorkletProcessor
17
17
**/
18
- private class HissGeneratorProcessor : AudioWorkletProcessor () {
19
- companion object : AudioWorkletProcessorCompanion {
20
- override val parameterDescriptors: ReadonlyArray <AudioParamDescriptor > =
21
- arrayOf(
22
- AudioParamDescriptor (
23
- name = GAIN ,
24
- defaultValue = 0.2f ,
25
- minValue = 0f ,
26
- maxValue = 1f ,
27
- )
28
- )
29
- }
30
-
18
+ class HissGeneratorProcessor : AudioWorkletProcessor () {
31
19
/* *
32
20
* Called by the browser's audio subsystem with
33
21
* packets of audio data to be processed.
@@ -89,12 +77,23 @@ private class HissGeneratorProcessor : AudioWorkletProcessor() {
89
77
90
78
return true
91
79
}
92
- }
93
80
94
- // TODO: Remove when `@JsStatic` will work in development mode
95
- val HissGeneratorProcessorClass : JsClass <out AudioWorkletProcessor >
96
- get() {
97
- val klass = HissGeneratorProcessor ::class .js
98
- klass.asDynamic().parameterDescriptors = HissGeneratorProcessor .parameterDescriptors
99
- return klass
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
+ )
90
+ )
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
+ }
100
98
}
99
+ }
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ package mdn.audioworklet.example
3
3
import web.audio.AudioWorkletModule
4
4
5
5
val HissGeneratorWorkletModule = AudioWorkletModule { self ->
6
- self.registerProcessor(" hiss-generator" , HissGeneratorProcessorClass )
6
+ self.registerProcessor(" hiss-generator" , HissGeneratorProcessor .classRef )
7
7
}
You can’t perform that action at this time.
0 commit comments