Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.37k stars 976 forks source link

allow worklet-based effects to be used with native contexts #1131

Closed marcelblum closed 4 months ago

marcelblum commented 1 year ago

This is a fix for the following bug which occurs when trying to instantiate any effect node that uses an AudioWorklet (BitCrusher, JCReverb, etc.) if using Tone with a native context (non-Standardized Audio Context):

Screenshot 2022-10-15 015036

If there's any better way than this to check if a context is from Standardized Audio Context or not, let me know! ~~This is using context.constructor.name.includes("AudioContext") which catches native online & offline contexts consistently AFAICT, whereas with those created by Standardized Audio Context context.constructor.name is always an empty string.~~ Now using context instanceof window.BaseAudioContext per @chrisguttandin's suggestion.

codecov[bot] commented 1 year ago

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

:exclamation: No coverage uploaded for pull request base (dev@56fea7c). Click here to learn what that means.

:exclamation: Current head 843870c differs from pull request most recent head fbd1135. Consider uploading reports for the commit fbd1135 to get more accurate results

Files Patch % Lines
Tone/core/context/AudioContext.ts 50.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #1131 +/- ## ====================================== Coverage ? 98.43% ====================================== Files ? 184 Lines ? 7724 Branches ? 681 ====================================== Hits ? 7603 Misses ? 34 Partials ? 87 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

marcelblum commented 1 year ago

Dang I wasn't seeing those tests fail locally, will investigate soon.

tambien commented 4 months ago

🙏🏻 @marcelblum and @chrisguttandin