Skip to content

Commit

Permalink
Fix duplicate pitches in phrase maker (#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
apsinghdev authored Jan 2, 2024
1 parent 3fa57e6 commit 8d3db90
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions js/widgets/phrasemaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,8 @@ class PhraseMaker {
}
this._markedColsInRow.push(thisRow);
}

// create a 'Set' object that contains only unique values
const uniqueFrequencies = new Set();
const sortableList = [];
let drumName;
// Make a list to sort, skipping drums and graphics.
Expand All @@ -2148,26 +2149,21 @@ class PhraseMaker {
}

// We want to sort based on frequency, so we convert all notes to frequency.
if (MATRIXSYNTHS.indexOf(this.rowLabels[i]) !== -1) {
// Deprecated
sortableList.push([
this.rowArgs[i],
this.rowLabels[i],
this.rowArgs[i],
i,
this._noteStored[i]
]);
} else {
const frequencyKey = noteToFrequency(
this.rowLabels[i] + this.rowArgs[i],
this.activity.turtles.ithTurtle(0).singer.keySignature
);

if (!uniqueFrequencies.has(frequencyKey)) {
sortableList.push([
noteToFrequency(
this.rowLabels[i] + this.rowArgs[i],
this.activity.turtles.ithTurtle(0).singer.keySignature
),
frequencyKey,
this.rowLabels[i],
this.rowArgs[i],
i,
this._noteStored[i]
]);

uniqueFrequencies.add(frequencyKey);
}
}

Expand Down

0 comments on commit 8d3db90

Please sign in to comment.