From ad698c7002557107fd3d8bd43f5a131d564d0e0f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 30 Jan 2025 21:45:27 +0100 Subject: [PATCH] fix: empty strudel pane --- src/strudel.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/strudel.js b/src/strudel.js index 2a9d076..f21784d 100644 --- a/src/strudel.js +++ b/src/strudel.js @@ -124,8 +124,10 @@ export class StrudelSession { injectPatternMethods() { const self = this; Pattern.prototype.p = function (id) { + // allows muting a pattern x with x_ or _x if (typeof id === 'string' && (id.startsWith('_') || id.endsWith('_'))) { - // allows muting a pattern x with x_ or _x + // makes sure we dont hit the warning that no pattern was returned: + self.pPatterns[id] = silence; return silence; } if (id === '$') { @@ -188,17 +190,16 @@ export class StrudelSession { let patterns = Object.values(this.pPatterns); pattern = stack(...patterns); } + if (!pattern?._Pattern) { + console.warn( + `[strudel] no pattern found in doc ${docId}. falling back to silence. (you always need to use $: in nudel)`, + ); + pattern = silence; + } if (this.allTransform) { pattern = this.allTransform(pattern); } - // fix `pattern.fmap is not a function` exception, - // which happens when the pattern is the hubda function. - // TODO: figure out why this is happening, that sounds like a bug with the nudel std lib. - if (typeof pattern === 'function') { - return; - } - // fft wiring if (this.enableAutoAnalyze) { pattern = pattern.fmap((value) => {