Delay and history definition order - Error in Rnbo, but not Max

Da Xu's icon

Hi folks,

I am running into a strange issue. I am trying to convert one of my gen~ patches into external via Rnbo.

The patch works in Max, however when I reference it in Rnbo, it throws up some very strange error.

Codegen Error Error: Gen parsing failed: SyntaxError: Expected "!=", "!=p", "&&", "(", ",", ".", ";", "<<", "<=", "<=p", "<p", "=", "==", "==p", ">=", ">=p", ">>", ">p", "?", "[", "^^", "||", [\-*+/%], or [\-/+*%\^&|<>] but "h" found.

at C:\Users\mouren\Documents\Max 8\Packages\RNBO\server\node_modules\@rnbo\xam-runner\lib\runner.js:143:27

at new Promise (<anonymous>)

at XAMCodegenInvocation.call (C:\Users\mouren\Documents\Max 8\Packages\RNBO\server\node_modules\@rnbo\xam-runner\lib\runner.js:71:16)

at C:\Users\mouren\Documents\Max 8\Packages\RNBO\server\dist\controllers\controllerInterface.js:291:39

at AsyncLocalStorage.run (node:async_hooks:346:14)

at Object.codegenInProcessJSON (C:\Users\mouren\Documents\Max 8\Packages\RNBO\server\dist\controllers\controllerInterface.js:287:76)

at handleServerStreaming (C:\Users\mouren\Documents\Max 8\Packages\RNBO\server\node_modules\@grpc\grpc-js\src\server.ts:973:11)

at processTicksAndRejections (node:internal/process/task_queues:95:5)

There were errors that referenced some lines in my gen~ patch:

RNBO: found: 'h',

RNBO: location: {

RNBO: start: { offset: 817, line: 32, column: 9 },

RNBO: end: { offset: 818, line: 32, column: 10 }

RNBO: }

I looked at that line. What I saw in the Code box was a bunch of declarations for Delay and History, but interrupted by an assignment from in to a variable. I did not write the code in this order, it was generated by gen~.

One thing to note is that I am using nested gen~ patches, and each nested patch uses about 8 delay lines, plus history.

I remember reading somewhere that all Delays and History had to be defined at the top of the file?

Could that be the reason why Rnbo is freaking out? But why is Max not throwing up any errors and been happily running the code for the past few months.

While I am at it, is there any best practices with regard to nested gen~ patches and encapsulation? What if I include multiple copies of the same gen~ subpatch?

Any help would be greatly appreciated.

Thank you