fix: scaleTranspose for scales without C in it

This commit is contained in:
Felix Roos 2022-02-28 21:39:53 +01:00
parent 349aa45f54
commit 125d190ff1

View File

@ -34,11 +34,11 @@ function scaleTranspose(scale: string, offset: number, note: string) {
while (Math.abs(i - noteIndex) < Math.abs(offset)) {
i += direction;
const index = mod(i, notes.length);
if (direction < 0 && n === 'C') {
if (direction < 0 && n[0] === 'C') {
o += direction;
}
n = notes[index];
if (direction > 0 && n === 'C') {
if (direction > 0 && n[0] === 'C') {
o += direction;
}
}
@ -54,7 +54,9 @@ Pattern.prototype._transpose = function (intervalOrSemitones: string | number) {
const semitones = typeof interval === 'string' ? Interval.semitones(interval) || 0 : interval;
return event.withValue(() => event.value + semitones);
}
return event.withValue(() => Note.transpose(event.value, interval));
// TODO: move simplify to player to preserve enharmonics
// tone.js doesn't understand multiple sharps flats e.g. F##3 has to be turned into G3
return event.withValue(() => Note.simplify(Note.transpose(event.value, interval)));
});
};