Skip to content

Commit

Permalink
DLS scale tuning compatibility layer
Browse files Browse the repository at this point in the history
  • Loading branch information
spessasus committed Nov 17, 2024
1 parent c66aa3e commit 70b6d62
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 54 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.23.1",
"version": "3.23.2",
"type": "module",
"scripts": {
"start": "node src/website/server/server.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class BasicZone
*/
getGeneratorValue(generatorType, notFoundValue)
{
return this.generators.find(g => g.generatorType === generatorType)?.generatorValue || notFoundValue;
return this.generators.find(g => g.generatorType === generatorType)?.generatorValue ?? notFoundValue;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function writeIns(preset)
{
if (!z.isGlobal)
{
arrs.push(writeDLSRegion.apply(this, [z]));
arrs.push(writeDLSRegion.apply(this, [z, globalZone]));
}
return arrs;
}, []));
Expand Down
19 changes: 17 additions & 2 deletions src/spessasynth_lib/soundfont/basic_soundfont/write_dls/rgn2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { writeArticulator } from "./art2.js";

/**
* @param zone {BasicInstrumentZone}
* @param globalZone {BasicInstrumentZone}
* @this {BasicSoundFont}
* @returns {IndexedByteArray}
*/
export function writeDLSRegion(zone)
export function writeDLSRegion(zone, globalZone)
{
// region header
const rgnhData = new IndexedByteArray(14);
Expand All @@ -32,10 +33,24 @@ export function writeDLSRegion(zone)
rgnhData
);

let rootKey = zone.getGeneratorValue(generatorTypes.overridingRootKey, zone.sample.samplePitch);

// a lot of soundfonts like to set scaletuning to 0 in drums and keep the key at 60
// since we implement scaletuning via a dls articulator and fluid doesn't support these,
// change the root key here
const scaleTuning = zone.getGeneratorValue(
generatorTypes.scaleTuning,
globalZone.getGeneratorValue(generatorTypes.scaleTuning, 100)
);
if (scaleTuning === 0 && zone.keyRange.max - zone.keyRange.min === 0)
{
rootKey = zone.keyRange.min;
}

// wavesample (Wsmp)
const wsmp = writeWavesample(
zone.sample,
zone.getGeneratorValue(generatorTypes.overridingRootKey, zone.sample.samplePitch),
rootKey,
zone.getGeneratorValue(
generatorTypes.fineTune,
0
Expand Down
18 changes: 9 additions & 9 deletions src/spessasynth_lib/synthetizer/worklet_processor.min.js

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/website/minified/demo_main.min.js

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions src/website/minified/local_main.min.js

Large diffs are not rendered by default.

0 comments on commit 70b6d62

Please sign in to comment.