Skip to content

Commit

Permalink
Made bank loading respect priority (load order).
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Aug 1, 2024
1 parent c83bedb commit b6d47eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/basic/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ let RootDisplay = class extends CustomEventSource {
});
};
});
console.debug(`Voice names: ${allCount} total, ${loadCount} loaded, ${prioCount} overridden by priority.`);
console.debug(`Voice names: ${allCount} total, ${loadCount} loaded (${loadCount - prioCount} + ${prioCount}).`);
upThis?.device.forceVoiceRefresh();
};
async loadMapPaths(paths) {
Expand Down
22 changes: 14 additions & 8 deletions src/state/bankReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,11 @@ let VoiceBank = class {
mode
};
};
async load(text, allowOverwrite, name = "(internal)") {
async load(text, allowOverwrite, name = "(internal)", priority) {
let upThis = this;
let sig = []; // Significance
let loadCount = 0, allCount = 0;
text.split("\n").forEach(function (e, i) {
let loadCount = 0, allCount = 0, prioCount = 0;
text.split("\n").forEach(async function (e, i) {
let assign = e.split("\t"), to = [];
if (i == 0) {
assign.forEach(function (e0, i0) {
Expand Down Expand Up @@ -763,13 +763,19 @@ let VoiceBank = class {
poly,
type,
drum,
level
level,
priority
};
/*if (loadCount > 889 && loadCount < 910) {
console.debug(e);
console.debug(voiceObject);
};*/
if (!writeArray[(msb << 8) | lsb] || allowOverwrite) {
let overwriteByPriority = false;
if (priority < writeArray[(msb << 8) | lsb]?.priority) {
overwriteByPriority = true;
prioCount ++;
};
if (!writeArray[(msb << 8) | lsb] || overwriteByPriority || allowOverwrite) {
/*if (msb == 63 && lsb == 32) {
console.debug(`Voice object written to voice pool.`);
};*/
Expand All @@ -782,7 +788,7 @@ let VoiceBank = class {
};
});
if (!allowOverwrite) {
console.debug(`Map "${name}": ${allCount} total, ${loadCount} loaded.`);
console.debug(`Map "${name}": ${allCount} total, ${loadCount} loaded (${loadCount - prioCount} + ${prioCount}).`);
};
};
clearRange(options) {
Expand All @@ -808,9 +814,9 @@ let VoiceBank = class {
async loadFiles(...type) {
this.init();
let upThis = this;
type.forEach(async function (e) {
type.forEach(async function (e, i) {
try {
upThis.load(await (await fetch(`./data/bank/${e}.tsv`)).text(), false, e);
upThis.load(await (await fetch(`./data/bank/${e}.tsv`)).text(), false, e, i);
} catch (err) {
console.error(`Failed loading "${e}.tsv".`);
};
Expand Down
2 changes: 1 addition & 1 deletion src/state/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ let OctaviaDevice = class extends CustomEventSource {
// GS Track Occupation
#trkRedir = new Uint8Array(allocated.ch);
#trkAsReq = new Uint8Array(allocated.tr); // Track Assignment request
baseBank = new VoiceBank("gm2", "xg", "gs", "ns5r", "sd", "gmega", "plg-vl", "plg-pf", "plg-dx", "plg-an", "plg-dr", "plg-sg", "kross", "s90es"); // Load all possible voice banks
baseBank = new VoiceBank("gm2", "ns5r", "xg", "gs", "sd", "gmega", "plg-vl", "plg-pf", "plg-dx", "plg-an", "plg-dr", "plg-sg", "kross", "s90es"); // Load all possible voice banks
userBank = new VoiceBank("gm"); // User-defined bank for MT-32, X5DR and NS5R
initOnReset = false; // If this is true, Octavia will re-init upon mode switches
aiEfxName = "";
Expand Down

0 comments on commit b6d47eb

Please sign in to comment.