Skip to content

Commit

Permalink
Fix some optimizators to handle tone only improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mborik committed Jan 6, 2023
1 parent 8f22868 commit a30992f
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions src/compiler/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ export class CompilerOptimizer {
return this.patList.reduce<Set<number>>(
(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++;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit a30992f

Please sign in to comment.