Cleanup
This commit is contained in:
@@ -149,7 +149,7 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
console.log("playMidi", bytes)
|
console.log("playMidi", bytes)
|
||||||
if (bytes.length > 0) {
|
if (bytes.length > 0) {
|
||||||
var cmdByte = bytes[0]
|
var cmdByte = bytes[0]
|
||||||
val channelCmd = ((cmdByte shr 4) and 0xf) in 0x8 .. 0xe
|
val channelCmd = ((cmdByte shr 4) and 0xf) != 0xf0
|
||||||
val channel = cmdByte and 0xf
|
val channel = cmdByte and 0xf
|
||||||
println("Channel cmd: $channelCmd")
|
println("Channel cmd: $channelCmd")
|
||||||
if (channelCmd && channel != midiChannel) {
|
if (channelCmd && channel != midiChannel) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "2.0.0"
|
kotlin("multiplatform") version "2.0.20-Beta1"
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
|
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package nl.astraeus.vst.chip.audio
|
|||||||
|
|
||||||
import nl.astraeus.vst.chip.view.MainView
|
import nl.astraeus.vst.chip.view.MainView
|
||||||
import nl.astraeus.vst.chip.view.WaveformView
|
import nl.astraeus.vst.chip.view.WaveformView
|
||||||
|
import nl.astraeus.vst.ui.util.uInt8ArrayOf
|
||||||
import org.khronos.webgl.Float32Array
|
import org.khronos.webgl.Float32Array
|
||||||
import org.khronos.webgl.Uint8Array
|
import org.khronos.webgl.Uint8Array
|
||||||
import org.khronos.webgl.get
|
import org.khronos.webgl.get
|
||||||
@@ -18,46 +19,53 @@ object VstChipWorklet : AudioNode(
|
|||||||
postMessage("waveform\n$value")
|
postMessage("waveform\n$value")
|
||||||
}
|
}
|
||||||
var midiChannel = 0
|
var midiChannel = 0
|
||||||
|
set(value) {
|
||||||
|
check(value in 0..15) {
|
||||||
|
"Midi channel must be between 0 and 15."
|
||||||
|
}
|
||||||
|
field = value
|
||||||
|
postMessage("set_channel\n${midiChannel}")
|
||||||
|
}
|
||||||
var volume = 0.75
|
var volume = 0.75
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x46.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x46, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var dutyCycle = 0.5
|
var dutyCycle = 0.5
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x4a.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x4a, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var fmModFreq = 0.0
|
var fmModFreq = 0.0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x4b.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x4b, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var fmModAmp = 0.0
|
var fmModAmp = 0.0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x4c.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x4c, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var amModFreq = 0.0
|
var amModFreq = 0.0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x47.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x47, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var amModAmp = 0.0
|
var amModAmp = 0.0
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
super.postMessage(
|
super.postMessage(
|
||||||
Uint8Array(arrayOf(0xb0.toByte(), 0x48.toByte(), (value * 127).toInt().toByte()))
|
uInt8ArrayOf(0xb0 + midiChannel, 0x48, (value * 127).toInt())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var recording: Float32Array? = null
|
var recording: Float32Array? = null
|
||||||
@@ -125,10 +133,4 @@ object VstChipWorklet : AudioNode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setChannel(channel: Int) {
|
|
||||||
midiChannel = channel
|
|
||||||
|
|
||||||
postMessage("set_channel\n${midiChannel}")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ object MainView : Komponent(), CssName {
|
|||||||
onInputFunction = { event ->
|
onInputFunction = { event ->
|
||||||
val target = event.target as HTMLInputElement
|
val target = event.target as HTMLInputElement
|
||||||
println("onInput channel: $target")
|
println("onInput channel: $target")
|
||||||
VstChipWorklet.setChannel(target.value.toInt())
|
VstChipWorklet.midiChannel = target.value.toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user