From 4c00356dffffe7ba022197f9cee1137335c27e67 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Mon, 9 Dec 2024 19:51:57 +0100 Subject: [PATCH] Increase polyphony and comment out debug logs Updated the polyphony level from 10 to 20 to enhance sound capability and commented out several debug logs for cleaner console output. Additionally, commented out a block of code related to sine wave modulation that appears unnecessary at this stage. The console log message for registering the processor was slightly modified for consistency. --- .../kotlin/nl/astraeus/vst/chip/ChipProcessor.kt | 14 ++++++++------ .../kotlin/nl/astraeus/vst/chip/midi/Midi.kt | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) 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 95d2942..2efa7cf 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 @@ -17,7 +17,7 @@ import kotlin.math.PI import kotlin.math.min import kotlin.math.sin -val POLYPHONICS = 10 +val POLYPHONICS = 20 val PI2 = PI * 2 @ExperimentalJsExport @@ -155,12 +155,12 @@ class VstChipProcessor : AudioWorkletProcessor() { } private fun playMidi(bytes: Int32Array) { - console.log("playMidi", bytes) + //console.log("playMidi", bytes) if (bytes.length > 0) { var cmdByte = bytes[0] val channelCmd = ((cmdByte shr 4) and 0xf) != 0xf0 val channel = cmdByte and 0xf - println("Channel cmd: $channelCmd") + //println("Channel cmd: $channelCmd") if (channelCmd && channel != midiChannel) { console.log("Wrong channel", midiChannel, bytes) return @@ -338,7 +338,7 @@ class VstChipProcessor : AudioWorkletProcessor() { val sampleDelta = midiNote.sampleDelta for (i in 0 until samples) { - var targetVolume = note.velocity / 127f * 10f + var targetVolume = note.velocity / 127f * 1f targetVolume *= ADSR.calculate( attack, decay, @@ -401,7 +401,6 @@ class VstChipProcessor : AudioWorkletProcessor() { left[i] = left[i] + waveValue * note.actualVolume * volume * amModulation right[i] = right[i] + waveValue * note.actualVolume * volume * amModulation - // comb filter delay val delaySampleIndex = (note.sample + note.combDelayBuffer.length) % note.combDelayBuffer.length @@ -428,10 +427,13 @@ class VstChipProcessor : AudioWorkletProcessor() { } // if sin enable + + /* for (i in 0 until samples) { left[i] = sin(left[i] * PI2).toFloat() right[i] = sin(right[i] * PI2).toFloat() } + */ val delaySamples = (delay * leftDelayBuffer.length).toInt() for (i in 0 until samples) { @@ -466,5 +468,5 @@ class VstChipProcessor : AudioWorkletProcessor() { fun main() { registerProcessor("vst-chip-processor", VstChipProcessor::class.js) - println("VstChipProcessor registered!") + println("'vst-chip-processor' registered!") } diff --git a/src/jsMain/kotlin/nl/astraeus/vst/chip/midi/Midi.kt b/src/jsMain/kotlin/nl/astraeus/vst/chip/midi/Midi.kt index 1d969ef..9648a0a 100644 --- a/src/jsMain/kotlin/nl/astraeus/vst/chip/midi/Midi.kt +++ b/src/jsMain/kotlin/nl/astraeus/vst/chip/midi/Midi.kt @@ -124,7 +124,7 @@ object Midi { hex.append(data[index].toString(16)) hex.append(" ") } - console.log("Midi message:", hex) + //console.log("Midi message:", hex) VstChipWorklet.postMessage( message.data )