From 35f5a5d11ad1d3d4f030d06458d7f63e697e091e Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sun, 9 Jul 2023 16:53:41 +0200 Subject: [PATCH] feat: add voiceOffset (2) --- packages/core/controls.mjs | 1 + packages/tonal/test/tonleiter.test.mjs | 1 + packages/tonal/voicings.mjs | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index a9f15617..88cf0afb 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -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. diff --git a/packages/tonal/test/tonleiter.test.mjs b/packages/tonal/test/tonleiter.test.mjs index 866d1cbc..f38f1f25 100644 --- a/packages/tonal/test/tonleiter.test.mjs +++ b/packages/tonal/test/tonleiter.test.mjs @@ -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 }); }); diff --git a/packages/tonal/voicings.mjs b/packages/tonal/voicings.mjs index 8f877394..2e7d0db8 100644 --- a/packages/tonal/voicings.mjs +++ b/packages/tonal/voicings.mjs @@ -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)); }