mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
fix for transpose(): preserve hap value object structure
This commit is contained in:
parent
1525992d73
commit
b870ab204a
@ -103,6 +103,8 @@ export const transpose = register('transpose', function (intervalOrSemitones, pa
|
|||||||
const semitones = typeof interval === 'string' ? Interval.semitones(interval) || 0 : interval;
|
const semitones = typeof interval === 'string' ? Interval.semitones(interval) || 0 : interval;
|
||||||
return hap.withValue(() => hap.value + semitones);
|
return hap.withValue(() => hap.value + semitones);
|
||||||
}
|
}
|
||||||
|
if (typeof hap.value === 'object')
|
||||||
|
return hap.withValue(() => ({ ...hap.value, note: Note.simplify(Note.transpose(hap.value.note, interval)) }));
|
||||||
// TODO: move simplify to player to preserve enharmonics
|
// 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
|
// tone.js doesn't understand multiple sharps flats e.g. F##3 has to be turned into G3
|
||||||
return hap.withValue(() => Note.simplify(Note.transpose(hap.value, interval)));
|
return hap.withValue(() => Note.simplify(Note.transpose(hap.value, interval)));
|
||||||
@ -133,6 +135,11 @@ export const scaleTranspose = register('scaleTranspose', function (offset /* : n
|
|||||||
if (!hap.context.scale) {
|
if (!hap.context.scale) {
|
||||||
throw new Error('can only use scaleTranspose after .scale');
|
throw new Error('can only use scaleTranspose after .scale');
|
||||||
}
|
}
|
||||||
|
if (typeof hap.value === 'object')
|
||||||
|
return hap.withValue(() => ({
|
||||||
|
...hap.value,
|
||||||
|
note: scaleOffset(hap.context.scale, Number(offset), hap.value.note),
|
||||||
|
}));
|
||||||
if (typeof hap.value !== 'string') {
|
if (typeof hap.value !== 'string') {
|
||||||
throw new Error('can only use scaleTranspose with notes');
|
throw new Error('can only use scaleTranspose with notes');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user