RNBO JS Library "rnbo_fround is not defined"

Pedro Botsaris's icon

Hi there,

I am getting the following

ReferenceError: rnbo_fround is not defined
at Object.constrainParameterValue (eval at evalFunction (index-35b72d3c.js:27:1285), <anonymous>:51:39)

when attempting to set a parameter like so

class RNBO {
constructor(device) {
this.device = device;

this.device.parameters.forEach((p) => {
this[p.name] = device.parametersById.get(p.id);
});
}
set(param, value) {
try {
if (this.hasParameter(param)) {
this[param].value = value
return
}
} catch (e) {
// error logic.
}
// invalid param logic
}
}

Note that I abstracted the rnbo library behind a class but above should be the same as:

const p = device.parametersById.get("some_param_id");
p.value = value

This only happens after I build. When serving the app with vite run dev, I don't get this issue.

Also worth mentioning that I noticed this issue enum values as well when exporting `steps` for the numeric parameters.

I am bundling my app using vite 4.4.5 and try on both rnbo 1.2.3 and 1.2.1.

CharBoogie's icon

Did you end up finding a solution? I'm having the same issue...

Thanks!!

Charlie

Florian Demmer's icon

Hi Charlie,

just to double check, which version of RNBO are you using?

Thanks,
Florian

CharBoogie's icon

I am using 1.2.6. Thanks.

CharBoogie's icon

For some context...

I am loading a rnbo patcher that makes use of gen inside. I load it in a Svelte component, and store the param ID's in an object. I pass that to another component which deals with setting the params.


This is and has been working well for me in my build process, and for a few deployments (firebase) so far.

I have just encountered this 'rnbo_fround' issue though. It seems to occur when I try to access certain params, but it is hard to pinpoint the issue. Like Pedro, this is only an issue when I have built and deployed, never in my localhost dev server.

I've got it working now by creating a new param with a different name, but I had to try this twice before it worked. Almost seems like chance.

Any advice here would be greatly appreciated! I'd love to understand if there is something I am doing wrong, or if this is a bug.

Thanks so much!

Charlie



Florian Demmer's icon

OK I recall that this came up before. Can you ensure that the build tasks don't optimize the code from @rnbo/js? Unless I'm mistaken it basically drops some of the internals as an optimization during the treeshake step due to them being unused. However, your RNBO patch is inserted, loaded and evaluated at runtime so some of these utilities only come into scope at that point in time, which cannot be detected by the optimizers Svelte / Rollup are using at build time.

We'll look into safe-guarding against this, but in the meantime I hope this does the trick?

Let us know!

Thanks
Florian

James Bradbury's icon

I faced this problem with Svelte specifically also.

It is indeed a tree-shaking issue as Florian pointed out and you can solve it in the meantime by adjusting your vite settings. At the time my solve looked something like this, though the configuration syntax is slightly different between Svelte versions and Svelte/SvelteKit:

const config = {
	kit: {
		adapter: adapter(),
		trailingSlash: 'always',
		// hydrate the <div id="svelte"> element in src/app.html

		vite: {
			build: {
				rollupOptions: {
					treeshake: false
				}
			}
		}
	}
};

The most important being that you passup the treeshake: false to the rollup options.

CharBoogie's icon

Worked for me as well!

Thank you so much for clearing this up Florian and James!