Skip to content

Commit

Permalink
patch name goes here
Browse files Browse the repository at this point in the history
Fix DLS tuning (again)
Fix DLS presets not being sorted
Fix duplicate presets in soundfont overwriting names
add more defaults
remove "dls conversion" popup when loading from memory
  • Loading branch information
spessasus committed Sep 24, 2024
1 parent 841ab03 commit 5e360c2
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 56 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.25",
"version": "3.20.24",
"type": "module",
"scripts": {
"start": "node src/website/server/server.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,33 @@ class BasicSoundFont
*/
getPreset(bankNr, programNr)
{
// check for exact match
let preset = this.presets.find(p => p.bank === bankNr && p.program === programNr);
if (!preset)
{
preset = this.presets.find(p => p.program === programNr && p.bank !== 128);
// no match...
if(bankNr === 128)
{
// drum preset: find any preset with bank 128
preset = this.presets.find(p => p.bank === 128 && p.program === programNr);
if(!preset)
{
preset = this.presets.find(p => p.bank === 128);
}
}
else
{
// non drum preset: find any preset with the given program that is not a drum preset
preset = this.presets.find(p => p.program === programNr && p.bank !== 128);
}
if(preset)
{
SpessaSynthWarn(`%cPreset ${bankNr}.${programNr} not found. Replaced with %c${preset.presetName} (${preset.bank}.${preset.program})`,
consoleColors.warn,
consoleColors.recognized);
}
}
// no preset, use the first one available
if(!preset)
{
SpessaSynthWarn(`Preset ${programNr} not found. Defaulting to`, this.presets[0].presetName);
Expand Down
7 changes: 6 additions & 1 deletion src/spessasynth_lib/soundfont/dls/dls_soundfont.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class DLSSoundFont extends BasicSoundFont
this.soundFontInfo["isng"] = "EMU8000";

// set some defaults
this.soundFontInfo["INAM"] = "Unnamed DLS";
this.soundFontInfo["IENG"] = "Unknown";
this.soundFontInfo["IPRD"] = "SpessaSynth DLS";
this.soundFontInfo["ICRD"] = new Date().toDateString();

Expand All @@ -61,7 +63,7 @@ class DLSSoundFont extends BasicSoundFont
this.soundFontInfo[infoPart.header] = readBytesAsString(infoPart.chunkData, infoPart.size);
}
}
this.soundFontInfo["ICMT"] = (this.soundFontInfo["ICMT"] || "") + "\nConverted from DLS to SF2 with SpessaSynth";
this.soundFontInfo["ICMT"] = (this.soundFontInfo["ICMT"] || "(No description)") + "\nConverted from DLS to SF2 with SpessaSynth";
if(this.soundFontInfo["ISBJ"])
{
// merge it
Expand Down Expand Up @@ -101,6 +103,9 @@ class DLSSoundFont extends BasicSoundFont
}
this.readDLSInstrumentList(instrumentListChunk);

// sort presets
this.presets.sort((a, b) => (a.program - b.program) + (a.bank - b.bank));

SpessaSynthInfo(`%cParsing finished! %c"${this.soundFontInfo["INAM"] || "UNNAMED"}"%c has %c${this.presets.length} %cpresets,
%c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,
consoleColors.info,
Expand Down
1 change: 1 addition & 0 deletions src/spessasynth_lib/soundfont/dls/dls_zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class DLSZone extends BasicInstrumentZone
this.isGlobal = false;

// correct tuning if needed
samplePitchCorrection -= sample.samplePitchCorrection;
const coarseTune = Math.trunc(samplePitchCorrection / 100);
if(coarseTune !== 0)
{
Expand Down
14 changes: 7 additions & 7 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 @@ -259,6 +259,15 @@ export function systemExclusive(messageData, channelOffset = 0)
// http://www.bandtrax.com.au/sysex.htm
// https://cdn.roland.com/assets/media/pdf/AT-20R_30R_MI.pdf
case 0x41:
function notRecognized()
{
// this is some other GS sysex...
SpessaSynthWarn(`%cUnrecognized Roland %cGS %cSysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.recognized,
consoleColors.warn,
consoleColors.unrecognized);
}
if(messageData[2] === 0x42 && messageData[3] === 0x12)
{
// this is a GS sysex
Expand Down Expand Up @@ -294,6 +303,8 @@ export function systemExclusive(messageData, channelOffset = 0)
switch (messageData[6])
{
default:
// this is some other GS sysex...
notRecognized();
break;

case 0x15:
Expand Down Expand Up @@ -340,15 +351,17 @@ export function systemExclusive(messageData, channelOffset = 0)
case 0x4B:
// scale tuning
const cents = messageValue - 64;
SpessaSynthInfo(`%cChannel %c${channel}%c tuning. Cents %c${cents}%c, with %c${arrayToHexString(messageData)}`,
SpessaSynthInfo(`%cChannel %c${channel}%c scale tuning. Cents %c${cents}%c, with %c${arrayToHexString(messageData)}`,
consoleColors.info,
consoleColors.recognized,
consoleColors.info,
consoleColors.value,
consoleColors.info,
consoleColors.value);
this.setChannelTuning(channel, cents);
break;
}
return;
}
else
// this is a global system parameter
Expand Down Expand Up @@ -390,11 +403,7 @@ export function systemExclusive(messageData, channelOffset = 0)
}
}
// this is some other GS sysex...
SpessaSynthWarn(`%cUnrecognized Roland %cGS %cSysEx: %c${arrayToHexString(messageData)}`,
consoleColors.warn,
consoleColors.recognized,
consoleColors.warn,
consoleColors.unrecognized);
notRecognized();
return;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ export class WorkletSoundfontManager
for (let i = this.soundfontList.length - 1; i >= 0; i--)
{
const font = this.soundfontList[i];
/**
* prevent preset names from the same soudfont from being overriden
* if the soundfont has two presets with matching bank and program
* @type {Set<string>}
*/
const presets = new Set();
for(const p of font.soundfont.presets)
{
const presetString = `${p.bank + font.bankOffset}-${p.program}`;
if(presets.has(presetString))
{
continue;
}
presets.add(presetString);
presetList[presetString] = p.presetName;
}
}
Expand Down
14 changes: 10 additions & 4 deletions src/website/manager/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class Manager
saveBlob(blob, name)
{
const url = URL.createObjectURL(blob);
/**
* @type {HTMLAnchorElement}
*/
const a = document.createElement("a");
a.href = url;
a.download = name;
Expand Down Expand Up @@ -174,7 +177,10 @@ class Manager
// set up keyboard
this.keyboard = new MidiKeyboard(this.channelColors, this.synth);

// set up renderer
/**
* set up renderer
* @type {HTMLCanvasElement}
*/
const canvas = document.getElementById("note_canvas");

canvas.width = window.innerWidth * window.devicePixelRatio;
Expand Down Expand Up @@ -279,6 +285,9 @@ class Manager
if (videoSource === null) {
return;
}
/**
* @type {HTMLVideoElement}
*/
const video = document.createElement("video");
video.src = videoSource;
video.classList.add("secret_video");
Expand Down Expand Up @@ -309,9 +318,6 @@ class Manager
}
});
this.renderer.render(false, true);
setTimeout(() => {
this.doDLSCheck()
}, 1000);
}

doDLSCheck()
Expand Down
36 changes: 18 additions & 18 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 5e360c2

Please sign in to comment.