Skip to content

Commit 06a5e7f

Browse files
Fix temperament widget playing incorrect notes for default temperaments
Use note names instead of raw frequencies when playing notes in the temperament widget for default temperaments (non-12EDO). This ensures the synth applies the correct temperament mapping via _getFrequency() instead of bypassing it with raw frequency values. The fix: - Sets synth's inTemperament and changeInTemperament before playing - Converts note arrays to string format (e.g., ["C", 4] -> "C4") - Handles Unicode sharps/flats conversion to ASCII - Maintains backward compatibility for edit modes and custom temperaments Fixes #4033
1 parent 74b88f5 commit 06a5e7f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

js/widgets/temperament.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,12 +1896,34 @@ function TemperamentWidget() {
18961896
const duration = 1 / 2;
18971897
let notes;
18981898

1899+
// Ensure the synth's temperament is set correctly
1900+
this._logo.synth.inTemperament = this.inTemperament;
1901+
this._logo.synth.changeInTemperament = true;
1902+
18991903
if (docById("wheelDiv4") === null) {
1900-
notes = this.frequencies[pitchNumber];
1904+
// For edit modes, use frequencies directly
19011905
if (this.editMode == "equal" && this.eqTempHzs && this.eqTempHzs.length) {
19021906
notes = this.eqTempHzs[pitchNumber];
19031907
} else if (this.editMode == "ratio" && this.NEqTempHzs && this.NEqTempHzs.length) {
19041908
notes = this.NEqTempHzs[pitchNumber];
1909+
} else {
1910+
// For default temperaments, use note names so the synth can apply temperament mapping
1911+
if (isCustomTemperament(this.inTemperament)) {
1912+
// For custom temperaments, use frequency or custom frequency method
1913+
notes = this.frequencies[pitchNumber];
1914+
} else {
1915+
// For default temperaments (non-12EDO), use note names
1916+
// Convert note array to string format (e.g., ["C", 4] -> "C4")
1917+
if (this.notes[pitchNumber] && Array.isArray(this.notes[pitchNumber])) {
1918+
const noteName = this.notes[pitchNumber][0];
1919+
const octave = this.notes[pitchNumber][1];
1920+
// Replace Unicode sharps/flats with ASCII equivalents
1921+
notes = noteName.replace(//g, "b").replace(//g, "#") + octave;
1922+
} else {
1923+
// Fallback to frequency if note format is unexpected
1924+
notes = this.frequencies[pitchNumber];
1925+
}
1926+
}
19051927
}
19061928
} else {
19071929
notes = this.tempRatios1[pitchNumber] * this.frequencies[0];

0 commit comments

Comments
 (0)