feat: add voiceOffset (2)

This commit is contained in:
Felix Roos 2023-07-09 16:53:41 +02:00
parent d1fe50e271
commit 35f5a5d11a
3 changed files with 4 additions and 2 deletions

View File

@ -578,6 +578,7 @@ const generic_params = [
['chord'], // https://github.com/tidalcycles/strudel/issues/506
['voiceBelow', 'voicebelow'], // https://github.com/tidalcycles/strudel/issues/506
['voiceMax', 'voicemax'], // https://github.com/tidalcycles/strudel/issues/506
['voiceOffset', 'voiceoffset'], // https://github.com/tidalcycles/strudel/issues/506
/**
* Sets the level of reverb.

View File

@ -113,5 +113,6 @@ describe('tonleiter', () => {
expect(voiceBelow('D5', 'Cm7', voicingDictionary)).toEqual(['Eb4', 'G4', 'Bb4', 'D5']);
expect(voiceBelow('G5', 'Cm7', voicingDictionary)).toEqual(['Bb4', 'D5', 'Eb5', 'G5']);
// expect(voiceBelow('G4', 'Cm7', voicingDictionary)).toEqual(['Bb3', 'D4', 'Eb4', 'G4']);
// TODO: test with offset
});
});

View File

@ -139,13 +139,13 @@ export const rootNotes = register('rootNotes', function (octave, pat) {
export const voicing = register('voicing', function (dictionary, pat) {
return pat
.fmap((value) => {
let { voiceMax: max, voiceBelow: below, chord, ...rest } = value;
let { voiceMax: max, voiceBelow: below, voiceOffset: offset, chord, ...rest } = value;
let top = max || below;
top = top?.note || top || 'c5';
if (typeof dictionary === 'string') {
dictionary = voicingRegistry[dictionary]?.dictionary;
}
let notes = voiceBelow(top, chord, dictionary);
let notes = voiceBelow(top, chord, dictionary, offset);
if (below) {
notes = notes.filter((n) => note2midi(n) !== note2midi(top));
}