thenfour / WaveSabre

fork of WaveSabre fixing some issues, adding ImGui VST editors
MIT License
1 stars 0 forks source link

unisono voice mod source value is not correct on 1st note on #35

Closed thenfour closed 1 year ago

thenfour commented 1 year ago

steps to repro:

2nd note you play you'll hear the properly modulated delay.

thenfour commented 1 year ago

the issue is in the order that things are processed, and the fact that mod matrix doesn't run when voices aren't active. so when you hit the 1st note on, it goes like:

  1. note on triggered from synth device...
  2. envelope is triggered, and immediately attempts to read mod values and advance through 0-length stages. We're already broken because the mod matrix is empty.
  3. sample is processed.
    1. first envelopes are run, because they're more mod sources than destinations (though they are both).
    2. then mod matrix finally runs, and envelope mod destinations are populated
  4. next sample is processed.
    1. envelopes run and FINALLY can correctly read modulated params.

so there's not a great way to do this in the mod matrix, nor do i want to do it that way. better to be flexible at the destination read. the cheapest way to do this is to put a couple-sample delay on the envelope to make sure the mod matrix has had time to run.

unfortunately it's still not perfect, because of the recalc period the mod matrix ramps its destination values over time. so the theoretical 1-sample delay is not enough, but a full recalc period is too long IMO (and youll find oscillator phase not being what you'd expect etc).

this change compromises simplicity, small code size, and expected results.