From 0cfd6f31d5a6e429163e0b53d8525629f30466f8 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Thu, 27 Jun 2024 16:40:33 +0200 Subject: [PATCH] Add input --- .../astraeus/vst/chip/audio/VstChipWorklet.kt | 1 + .../nl/astraeus/vst/chip/view/MainView.kt | 18 ++++++++++++++---- src/{jvmMain => jsMain}/resources/index.html | 0 3 files changed, 15 insertions(+), 4 deletions(-) rename src/{jvmMain => jsMain}/resources/index.html (100%) diff --git a/src/jsMain/kotlin/nl/astraeus/vst/chip/audio/VstChipWorklet.kt b/src/jsMain/kotlin/nl/astraeus/vst/chip/audio/VstChipWorklet.kt index b07cd70..38f3905 100644 --- a/src/jsMain/kotlin/nl/astraeus/vst/chip/audio/VstChipWorklet.kt +++ b/src/jsMain/kotlin/nl/astraeus/vst/chip/audio/VstChipWorklet.kt @@ -6,6 +6,7 @@ object VstChipWorklet : AudioNode( "vst-chip-worklet.js", "vst-chip-processor" ) { + var volume = 0.75 override fun onMessage(message: MessageEvent) { console.log("Message from worklet: ", message) diff --git a/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt b/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt index b3eb1e7..76936a0 100644 --- a/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt +++ b/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt @@ -11,12 +11,13 @@ import nl.astraeus.komp.HtmlBuilder import nl.astraeus.komp.Komponent import nl.astraeus.vst.chip.audio.VstChipWorklet import nl.astraeus.vst.chip.midi.Midi -import nl.astraeus.vst.ui.components.ExpKnobComponent +import nl.astraeus.vst.ui.components.KnobComponent import nl.astraeus.vst.ui.css.Css import nl.astraeus.vst.ui.css.Css.defineCss import nl.astraeus.vst.ui.css.Css.noTextSelect import nl.astraeus.vst.ui.css.CssName import nl.astraeus.vst.ui.css.hover +import nl.astraeus.vst.util.formatDouble import org.khronos.webgl.Uint8Array import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLSelectElement @@ -170,9 +171,18 @@ object MainView : Komponent(), CssName { } div { include( - ExpKnobComponent( - - ) + KnobComponent( + value = VstChipWorklet.volume, + label = "Volume", + minValue = 0.0, + maxValue = 1.0, + step = 2.0 / 127.0, + width = 200, + height = 160 + ) { value -> + println("Value changed: ${formatDouble(value, 2)}") + VstChipWorklet.volume = value + } ) } } diff --git a/src/jvmMain/resources/index.html b/src/jsMain/resources/index.html similarity index 100% rename from src/jvmMain/resources/index.html rename to src/jsMain/resources/index.html