diff --git a/packages/tonal/voicings.mjs b/packages/tonal/voicings.mjs index a99a043b..f93a54d0 100644 --- a/packages/tonal/voicings.mjs +++ b/packages/tonal/voicings.mjs @@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see . */ -import { stack, register } from '@strudel.cycles/core'; +import { stack, register, silence, logger } from '@strudel.cycles/core'; import { renderVoicing } from './tonleiter.mjs'; import _voicings from 'chord-voicings'; import { complex, simple } from './ireal.mjs'; @@ -199,11 +199,15 @@ export const voicing = register('voicing', function (pat) { let { dictionary = 'default', chord, anchor, offset, mode, n, octaves, ...rest } = value; dictionary = typeof dictionary === 'string' ? voicingRegistry[dictionary] : { dictionary, mode: 'below', anchor: 'c5' }; - let notes = renderVoicing({ ...dictionary, chord, anchor, offset, mode, n, octaves }); - - return stack(...notes) - .note() - .set(rest); // rest does not include voicing controls anymore! + try { + let notes = renderVoicing({ ...dictionary, chord, anchor, offset, mode, n, octaves }); + return stack(...notes) + .note() + .set(rest); // rest does not include voicing controls anymore! + } catch (err) { + logger(`[voicing]: unknown chord "${chord}"`); + return silence; + } }) .outerJoin(); });