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.
This commit is contained in:
@@ -17,7 +17,7 @@ import kotlin.math.PI
|
|||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.sin
|
import kotlin.math.sin
|
||||||
|
|
||||||
val POLYPHONICS = 10
|
val POLYPHONICS = 20
|
||||||
val PI2 = PI * 2
|
val PI2 = PI * 2
|
||||||
|
|
||||||
@ExperimentalJsExport
|
@ExperimentalJsExport
|
||||||
@@ -155,12 +155,12 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun playMidi(bytes: Int32Array) {
|
private fun playMidi(bytes: Int32Array) {
|
||||||
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) != 0xf0
|
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) {
|
||||||
console.log("Wrong channel", midiChannel, bytes)
|
console.log("Wrong channel", midiChannel, bytes)
|
||||||
return
|
return
|
||||||
@@ -338,7 +338,7 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
val sampleDelta = midiNote.sampleDelta
|
val sampleDelta = midiNote.sampleDelta
|
||||||
|
|
||||||
for (i in 0 until samples) {
|
for (i in 0 until samples) {
|
||||||
var targetVolume = note.velocity / 127f * 10f
|
var targetVolume = note.velocity / 127f * 1f
|
||||||
targetVolume *= ADSR.calculate(
|
targetVolume *= ADSR.calculate(
|
||||||
attack,
|
attack,
|
||||||
decay,
|
decay,
|
||||||
@@ -401,7 +401,6 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
left[i] = left[i] + waveValue * note.actualVolume * volume * amModulation
|
left[i] = left[i] + waveValue * note.actualVolume * volume * amModulation
|
||||||
right[i] = right[i] + waveValue * note.actualVolume * volume * amModulation
|
right[i] = right[i] + waveValue * note.actualVolume * volume * amModulation
|
||||||
|
|
||||||
|
|
||||||
// comb filter delay
|
// comb filter delay
|
||||||
val delaySampleIndex =
|
val delaySampleIndex =
|
||||||
(note.sample + note.combDelayBuffer.length) % note.combDelayBuffer.length
|
(note.sample + note.combDelayBuffer.length) % note.combDelayBuffer.length
|
||||||
@@ -428,10 +427,13 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if sin enable
|
// if sin enable
|
||||||
|
|
||||||
|
/*
|
||||||
for (i in 0 until samples) {
|
for (i in 0 until samples) {
|
||||||
left[i] = sin(left[i] * PI2).toFloat()
|
left[i] = sin(left[i] * PI2).toFloat()
|
||||||
right[i] = sin(right[i] * PI2).toFloat()
|
right[i] = sin(right[i] * PI2).toFloat()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
val delaySamples = (delay * leftDelayBuffer.length).toInt()
|
val delaySamples = (delay * leftDelayBuffer.length).toInt()
|
||||||
for (i in 0 until samples) {
|
for (i in 0 until samples) {
|
||||||
@@ -466,5 +468,5 @@ class VstChipProcessor : AudioWorkletProcessor() {
|
|||||||
fun main() {
|
fun main() {
|
||||||
registerProcessor("vst-chip-processor", VstChipProcessor::class.js)
|
registerProcessor("vst-chip-processor", VstChipProcessor::class.js)
|
||||||
|
|
||||||
println("VstChipProcessor registered!")
|
println("'vst-chip-processor' registered!")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ object Midi {
|
|||||||
hex.append(data[index].toString(16))
|
hex.append(data[index].toString(16))
|
||||||
hex.append(" ")
|
hex.append(" ")
|
||||||
}
|
}
|
||||||
console.log("Midi message:", hex)
|
//console.log("Midi message:", hex)
|
||||||
VstChipWorklet.postMessage(
|
VstChipWorklet.postMessage(
|
||||||
message.data
|
message.data
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user