From 52c7495f43466cdd413a08419fb9c31bb6645a2d Mon Sep 17 00:00:00 2001 From: rnentjes Date: Sun, 8 Dec 2024 20:10:14 +0100 Subject: [PATCH] Refactor MainView onClick and cleanup project config Moved the onClickFunction outside of the START button div in MainView for better event handling. Removed outdated project directory from gradle.xml to clean up project configuration. Corrected sampleRate calculation in ChipProcessor for accurate audio processing. --- .idea/gradle.xml | 1 - .../kotlin/nl/astraeus/vst/chip/ChipProcessor.kt | 2 +- .../kotlin/nl/astraeus/vst/chip/view/MainView.kt | 16 +++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 181281b..1554c53 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,7 +10,6 @@ diff --git a/audio-worklet/src/jsMain/kotlin/nl/astraeus/vst/chip/ChipProcessor.kt b/audio-worklet/src/jsMain/kotlin/nl/astraeus/vst/chip/ChipProcessor.kt index 6fcc7e2..95d2942 100644 --- a/audio-worklet/src/jsMain/kotlin/nl/astraeus/vst/chip/ChipProcessor.kt +++ b/audio-worklet/src/jsMain/kotlin/nl/astraeus/vst/chip/ChipProcessor.kt @@ -85,7 +85,7 @@ class VstChipProcessor : AudioWorkletProcessor() { var recordingSample = 0 var recordingStart = 0 - val sampleLength = 1 / 48000.0 //sampleRate.toDouble() + val sampleLength = 1 / sampleRate.toDouble() val rightDelayBuffer = Float32Array(sampleRate) val leftDelayBuffer = Float32Array(sampleRate) 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 01f0eac..126d9f0 100644 --- a/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt +++ b/src/jsMain/kotlin/nl/astraeus/vst/chip/view/MainView.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalJsExport::class) + package nl.astraeus.vst.chip.view import kotlinx.browser.window @@ -119,13 +121,13 @@ object MainView : Komponent(), CssName { div(StartBoxCss.name) { div(StartButtonCss.name) { +"START" - onClickFunction = { - VstChipWorklet.create { - started = true - requestUpdate() - WebsocketClient.send("LOAD\n") - } - } + } + } + onClickFunction = { + VstChipWorklet.create { + started = true + requestUpdate() + WebsocketClient.send("LOAD\n") } } }