From fc39fea43d2b704abe5750494290385d3c06563b Mon Sep 17 00:00:00 2001 From: mborik128 Date: Fri, 6 Jan 2023 17:49:21 +0100 Subject: [PATCH] Fix some optimizators to handle tone only improvement --- src/compiler/optimizer.ts | 45 ++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/compiler/optimizer.ts b/src/compiler/optimizer.ts index ff91c3f..2ea8500 100644 --- a/src/compiler/optimizer.ts +++ b/src/compiler/optimizer.ts @@ -47,11 +47,16 @@ export class CompilerOptimizer { return this.patList.reduce>( (set, patData) => { for (let i = 0; i < patData.length; i++) { - const v = patData[i]; - if ((v & 0x80) > 0) { + const t = patData[i]; + if ((t & 0x80) > 0) { + // omit empty lines continue; } let s = patData[++i]; + if ((s & 0x20) > 0) { + // omit only tone changes + continue; + } let o = patData[++i]; if ((s & 0x80) > 0) { i++; @@ -208,11 +213,16 @@ export class CompilerOptimizer { private replaceSampleInPatterns(oldSmpNum: number, newSmpNum: number) { this.patList?.forEach(patData => { for (let i = 0; i < patData.length; i++) { - const v = patData[i]; - if ((v & 0x80) > 0) { + const t = patData[i]; + if ((t & 0x80) > 0) { + // omit empty lines continue; } const s = patData[++i]; + if ((s & 0x20) > 0) { + // omit only tone changes + continue; + } const si = i; const o = patData[++i]; if ((s & 0x80) > 0) { @@ -238,11 +248,16 @@ export class CompilerOptimizer { private renumberSamplesInPatterns(smpNum: number): void { this.patList?.forEach(patData => { for (let i = 0; i < patData.length; i++) { - const v = patData[i]; - if ((v & 0x80) > 0) { + const t = patData[i]; + if ((t & 0x80) > 0) { + // omit empty lines continue; } const s = patData[++i]; + if ((s & 0x20) > 0) { + // omit only tone changes + continue; + } const si = i; const o = patData[++i]; if ((s & 0x80) > 0) { @@ -377,11 +392,16 @@ export class CompilerOptimizer { private replaceOrnamentInPatterns(oldOrnNum: number, newOrnNum: number): void { this.patList?.forEach(patData => { for (let i = 0; i < patData.length; i++) { - const v = patData[i]; - if ((v & 0x80) > 0) { + const t = patData[i]; + if ((t & 0x80) > 0) { + // omit empty lines continue; } const s = patData[++i]; + if ((s & 0x20) > 0) { + // omit only tone changes + continue; + } const o = patData[++i]; const oi = i; if ((s & 0x80) > 0) { @@ -407,11 +427,16 @@ export class CompilerOptimizer { private renumberOrnamentsInPatterns(ornNum: number): void { this.patList?.forEach(patData => { for (let i = 0; i < patData.length; i++) { - const v = patData[i]; - if ((v & 0x80) > 0) { + const t = patData[i]; + if ((t & 0x80) > 0) { + // omit empty lines continue; } const s = patData[++i]; + if ((s & 0x20) > 0) { + // omit only tone changes + continue; + } const o = patData[++i]; const oi = i; if ((s & 0x80) > 0) {