Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limiter to Playground runtime #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mark-mxwl
Copy link
Contributor

Closes: #4

Added limiter function to runtime.js using el.compress with limiter-style settings. The current settings preserve approx. 1 dB headroom at max input. Also updated package.json to the latest versions of @elemaudio/core and @elemaudio/web-renderer to ensure correct type classification w/ isNode.

Copy link

netlify bot commented Apr 30, 2024

Deploy Preview for prismatic-pudding-943ac5 ready!

Name Link
🔨 Latest commit 9700955
🔍 Latest deploy log https://app.netlify.com/sites/prismatic-pudding-943ac5/deploys/66a4508974fd24000855ea98
😎 Deploy Preview https://deploy-preview-11--prismatic-pudding-943ac5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@nick-thompson nick-thompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mark-mxwl thanks so much for doing this, and I'm sorry for the delay! The code change looks great but it does open up a little version complexity that I describe below. Let me know what you think!

@@ -44,9 +46,11 @@ export class Runtime {
throw new Error('Missing render function on default export');

const userOutput = render();
// This limiter setting preserves approx. 1 dB of headroom.
const limit = (input) => el.compress(1, 10, -4, 20, input, input);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compress function that we're using right here comes from the el library imported from @elemaudio/core version at the top of the file. But the userOutput signal that we get from invoking the user module is built using the el export of whatever version @elemaudio/core is loaded in the user module.

It's really quite rare that there would be a conflict between these versions, but these versions do sometimes have requirements onto the renderer. For example, the core library might export a utility that uses a native node that only a recent version of the renderer knows about.

I do anticipate the next major version bringing some breaking changes, so we could arrive in a situation here where the user code is running a v4 web-renderer instance and v4 elemaudio/core but the limiter here is written against v3 elemaudio/core, and we could be getting into tricky territory there.

Even if this wouldn't be a problem, I think it'd be safer to make sure that we try to use the el.compress function from the same version that the user is running. Luckily, we know exactly what version that is because we force it using the importMap script above. Then on line 16 we fetch a matching web-renderer version. I think the fix here would be to add another line right below 16 which fetches the appropriate elemaudio/core version and grabs the el library out of that, then uses that compress function here to apply the limiting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting back, @nick-thompson. I see your concern, and I totally agree that keeping the versions aligned on import is a much better solution. I'll try to knock out the changes this weekend.

const WebRenderer = pkg.default;

this.el = coreLib.el;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added coreLib import for version matching, and this.el to the runtime constructor. Great suggestion 👌

@@ -44,9 +47,11 @@ export class Runtime {
throw new Error('Missing render function on default export');

const userOutput = render();
// This limiter preserves approx. .5 dB of headroom at max input.
const limit = (input) => this.el.compress(1, 50, -4.5, 50, input, input);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the limiter a bit harder to account for any ludicrous experimentation. 🦾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fallback Limiter in Playground
2 participants