oldabove and oldroot, documentation

This commit is contained in:
eefano
2026-06-08 21:09:23 +02:00
parent 422b03699a
commit e38811d325
4 changed files with 21 additions and 4 deletions
+9 -2
View File
@@ -2352,11 +2352,18 @@ export const { offset } = registerControl('offset');
**/
export const { octaves } = registerControl('octaves');
/**
* Remove anchor note from the voicing. Useful for melody harmonization
* How the voicing is aligned to the anchor
* - `below`: top note <= anchor
* - `duck`: top note <= anchor, anchor excluded
* - `above`: bottom note >= anchor
* - `root`: bottom note is the lowest root of the chord >= anchor
*
* - `oldabove` : old (buggy) behavior of above, kept for legacy reason
* - `oldroot` : old (buggy) behavior of root, kept for legacy reason
*
* @name mode
* @tags tonal
* @param {string | Pattern} modeName one of {below | above | duck | root}
* @param {string | Pattern} modeName one of {below | above | duck | root | oldabove | oldroot}
* @example
* mode("<below above duck root>").chord("C").voicing()
*
+5 -1
View File
@@ -134,12 +134,16 @@ let modeTarget = {
duck: (v) => v.slice(-1)[0],
above: (v) => v[0],
root: (v) => v[0],
oldabove: (v) => v[0],
oldroot: (v) => v[0],
};
let modeMult = {
below: 1,
duck: 1,
above: -1,
root: -1,
oldabove: 1,
oldroot: 1,
};
export function renderVoicing({ chord, dictionary, offset = 0, n, mode = 'below', anchor = 'c5', octaves = 1 }) {
@@ -163,7 +167,7 @@ export function renderVoicing({ chord, dictionary, offset = 0, n, mode = 'below'
}
return diff * mult;
});
if (mode === 'root') {
if (mode === 'root' || mode === 'oldroot') {
bestIndex = 0;
}
+3
View File
@@ -185,6 +185,9 @@ export const rootNotes = register('rootNotes', function (octave, pat) {
* - `below`: top note <= anchor
* - `duck`: top note <= anchor, anchor excluded
* - `above`: bottom note >= anchor
* - `root`: bottom note is the lowest root of the chord >= anchor
* - `oldabove` : old (buggy) behavior of above, kept for legacy reason
* - `oldroot` : old (buggy) behavior of root, kept for legacy reason
* - `offset`: whole number that shifts the voicing up or down to the next voicing
* - `n`: if set, the voicing is played like a scale. Overshooting numbers will be octaved
*
+4 -1
View File
@@ -287,7 +287,10 @@ The modes are:
- `below`: the top note of the voicing is lower than or equal to the anchor (default)
- `above`: the bottom note of the voicing is higher than or equal to the anchor
- `duck`: the top note of the voicing is lower than the anchor
- `root`: the bottom note of the voicing is always the root note closest to the anchor
- `root`: the bottom note of the voicing is always the lowest root note higher than or equal to the anchor
- `oldabove` : old (buggy) behavior of above, kept for legacy reasons
- `oldroot` : old (buggy) behavior of root, kept for legacy reasons
The `anchor` can also be set from within the `mode` function: