Playing with settings

This commit is contained in:
2024-08-12 20:36:30 +02:00
parent f2269c8865
commit b412dd9b4e
9 changed files with 248 additions and 74 deletions

View File

@@ -1,7 +1,11 @@
package nl.astraeus.vst.chip
import kotlin.js.ExperimentalJsExport
import kotlin.js.JsExport
import kotlin.js.JsName
@ExperimentalJsExport
@JsExport
data class PatchDTO(
@JsName("waveform")
val waveform: Int = 0,
@@ -31,4 +35,10 @@ data class PatchDTO(
var sustain: Double = 0.5,
@JsName("release")
var release: Double = 0.2,
@JsName("delay")
var delay: Double = 0.0,
@JsName("delayDepth")
var delayDepth: Double = 0.0,
@JsName("feedback")
var feedback: Double = 0.0,
)

View File

@@ -45,28 +45,49 @@ object VstChipWorklet : AudioNode(
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4a, (value * 127).toInt())
uInt8ArrayOf(0xb0 + midiChannel, 0x40, (value * 127).toInt())
)
}
var fmModAmp = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4b, (value * 127).toInt())
uInt8ArrayOf(0xb0 + midiChannel, 0x41, (value * 127).toInt())
)
}
var amModFreq = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4c, (value * 127).toInt())
uInt8ArrayOf(0xb0 + midiChannel, 0x42, (value * 127).toInt())
)
}
var amModAmp = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4d, (value * 127).toInt())
uInt8ArrayOf(0xb0 + midiChannel, 0x43, (value * 127).toInt())
)
}
var feedback = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x50, (value * 127).toInt())
)
}
var delay = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4e, (value * 127).toInt())
)
}
var delayDepth = 0.0
set(value) {
field = value
super.postMessage(
uInt8ArrayOf(0xb0 + midiChannel, 0x4f, (value * 127).toInt())
)
}
@@ -146,22 +167,22 @@ object VstChipWorklet : AudioNode(
MainView.requestUpdate()
}
0x4b.toByte() -> {
0x40.toByte() -> {
fmModFreq = value / 127.0
MainView.requestUpdate()
}
0x4c.toByte() -> {
0x41.toByte() -> {
fmModAmp = value / 127.0
MainView.requestUpdate()
}
0x47.toByte() -> {
0x42.toByte() -> {
amModFreq = value / 127.0
MainView.requestUpdate()
}
0x48.toByte() -> {
0x43.toByte() -> {
amModAmp = value / 127.0
MainView.requestUpdate()
}
@@ -181,6 +202,9 @@ object VstChipWorklet : AudioNode(
decay = patch.decay
sustain = patch.sustain
release = patch.release
delay = patch.delay
delayDepth = patch.delayDepth
feedback = patch.feedback
}
fun save(): PatchDTO {
@@ -196,7 +220,10 @@ object VstChipWorklet : AudioNode(
attack = attack,
decay = decay,
sustain = sustain,
release = release
release = release,
delay = delay,
delayDepth = delayDepth,
feedback = feedback
)
}

View File

@@ -37,6 +37,7 @@ import nl.astraeus.vst.chip.audio.VstChipWorklet
import nl.astraeus.vst.chip.audio.VstChipWorklet.midiChannel
import nl.astraeus.vst.chip.midi.Midi
import nl.astraeus.vst.chip.ws.WebsocketClient
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
@@ -236,12 +237,12 @@ object MainView : Komponent(), CssName {
}
div(ControlsCss.name) {
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.volume,
label = "Volume",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -262,12 +263,12 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.fmModFreq,
label = "FM Freq",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -275,12 +276,12 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.fmModAmp,
label = "FM Ampl",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -288,12 +289,12 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.amModFreq,
label = "AM Freq",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -301,27 +302,66 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.amModAmp,
label = "AM Ampl",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
VstChipWorklet.amModAmp = value
}
)
include(
ExpKnobComponent(
value = VstChipWorklet.feedback,
label = "Feedback",
minValue = 0.005,
maxValue = 1.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
VstChipWorklet.feedback = value
}
)
include(
ExpKnobComponent(
value = VstChipWorklet.delay,
label = "Delay",
minValue = 0.005,
maxValue = 1.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
VstChipWorklet.delay = value
}
)
include(
ExpKnobComponent(
value = VstChipWorklet.delayDepth,
label = "Delay depth",
minValue = 0.005,
maxValue = 1.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
VstChipWorklet.delayDepth = value
}
)
}
div(ControlsCss.name) {
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.attack,
label = "Attack",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -329,12 +369,12 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.decay,
label = "Decay",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->
@@ -355,12 +395,12 @@ object MainView : Komponent(), CssName {
}
)
include(
KnobComponent(
ExpKnobComponent(
value = VstChipWorklet.release,
label = "Release",
minValue = 0.0,
minValue = 0.005,
maxValue = 1.0,
step = 2.0 / 127.0,
step = 5.0 / 127.0,
width = 100,
height = 120,
) { value ->

View File

@@ -17,7 +17,7 @@ object WebsocketClient {
close()
websocket = if (window.location.hostname.contains("localhost") || window.location.hostname.contains("192.168")) {
WebSocket("ws://${window.location.hostname}:9000/ws")
WebSocket("ws://${window.location.hostname}:${window.location.port}/ws")
} else {
WebSocket("wss://${window.location.hostname}/ws")
}