Skip to content

Commit

Permalink
Fix broken optimization with modulators reaching max values
Browse files Browse the repository at this point in the history
  • Loading branch information
spessasus committed Sep 30, 2024
1 parent f074e9d commit 1d5f65d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SpessaSynth",
"version": "3.20.33",
"version": "3.20.34",
"type": "module",
"scripts": {
"start": "node src/website/server/server.js"
Expand Down
18 changes: 9 additions & 9 deletions src/spessasynth_lib/synthetizer/worklet_processor.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ export class WorkletVolumeEnvelope
// fallthrough

case 1:
let gain;
// attack phase: ramp from 0 to attenuation
while(env.currentSampleTime < env.attackEnd)
{
Expand All @@ -339,8 +338,7 @@ export class WorkletVolumeEnvelope

// Special case: linear gain ramp instead of linear db ramp
let linearAttenuation = 1 - (env.attackEnd - env.currentSampleTime) / env.attackDuration; // 0 to 1
gain = linearAttenuation * decibelAttenuationToGain(env.attenuation + decibelOffset)
audioBuffer[filledBuffer] *= gain;
audioBuffer[filledBuffer] *= linearAttenuation * decibelAttenuationToGain(env.attenuation + decibelOffset);
// set current attenuation to peak as its invalid during this phase
env.currentAttenuationDb = env.attenuation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export function computeModulators(voice, controllerTable, sourceUsesCC = -1, sou
modulatedGenerators.set(generators);
modulators.forEach(mod => {
const limits = generatorLimits[mod.modulatorDestination];
if(modulatedGenerators[mod.modulatorDestination] === limits.min || modulatedGenerators[mod.modulatorDestination] === limits.max) return;
const newValue = modulatedGenerators[mod.modulatorDestination] + computeWorkletModulator(controllerTable, mod, voice);
modulatedGenerators[mod.modulatorDestination] = Math.max(limits.min, Math.min(newValue, limits.max));
});
Expand Down Expand Up @@ -163,7 +162,6 @@ export function computeModulators(voice, controllerTable, sourceUsesCC = -1, sou
{
const limits = generatorLimits[mod.modulatorDestination];
const current = modulatedGenerators[mod.modulatorDestination];
if(current === limits.min || current === limits.max) return;
const newValue = current + computeWorkletModulator(controllerTable, m, voice);
modulatedGenerators[mod.modulatorDestination] = Math.max(limits.min, Math.min(newValue, limits.max));
}
Expand Down
1 change: 0 additions & 1 deletion src/website/js/utils/drop_file_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class DropFileHandler
{
// riff, check if RMID, otherwise soundfont
const rmid = buf.slice(8, 12);
console.log(decoder.decode(rmid))
if(decoder.decode(rmid) === "RMID")
{
// RMID
Expand Down
34 changes: 17 additions & 17 deletions src/website/minified/demo_main.min.js

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/website/minified/local_main.min.js

Large diffs are not rendered by default.

0 comments on commit 1d5f65d

Please sign in to comment.