-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
p5.sound 0.3.12 #3988
p5.sound 0.3.12 #3988
Conversation
thanks @therewasaguy I'm looking at website stuff this week, so I will check this one out and see if I can figure anything out on this |
The I don't fully understand the problem you have (no idea what AudioWorklet does or how it works), but that's just me not understanding WebAudio enough, so I'm not sure I will be of much help here. In any case if the example rendering code is to be changed, the changes should be made over at the website repo as well. |
Thank you @lmccart! Let me know if you figure anything out. @limzykenneth that's really good info, thank you! The problem is basically that we need to ensure that some Promises (AudioWorklet module loaders) have resolved before we try to use those modules. We can hack into p5 preload to do that here https://github.com/processing/p5.js-sound/pull/369/files#diff-2a7f5646d78d97940147769cd4a2fc21R25 . But that causes issues with the website's custom render method for sketches that don't have a preload as part of their "runnable" code. |
Is it possible to save the promise onto a private instance variable (eg. something attached as One potential problem I see with the above is if there's a chain of dependencies throughout the whole code base and because of this all of them needs to refer to upstream promises, but if there isn't such a thing it may work? |
Hi @therewasaguy @lmccart @limzykenneth, sorry for not chiming in on this thread earlier. I've done some local testing with the p5.js website and the latest build of p5.sound, and I think I have a solution on the p5.js-website side of things in the render.js file. I think that the problem is that when This can be solved by deleting the Here's what that would look like (these lines would replace the block of code in render.js starting at line 234): // Actually runs the code to get functions into scope.
if (p.preload) {
delete p.preload;
}
with (p) {
eval(runnable);
}
_found.forEach(function(name) {
p[name] = eval(name);
});
p.setup = p.setup || function() {
p.createCanvas(100, 100);
p.background(200);
}
p.preload = p.preload || function() {} I've tested this fix locally on Chrome, Firefox, and Safari, and it seems to work across all 3 browsers. If you're okay with this proposal, I'll open a PR to the p5.js-website repo. Let me know what you think! |
@oshoham thanks for looking into this. this fix seems reasonable to me, we would welcome a PR to the p5.js-website repo. when you make the change, please include some notes about why this is being done, so others that access it in the future can follow. thank you! |
🎉 thank you @oshoham!!! I would +1 that PR to the p5.js-website repo. A comment linking to this might help clarify why this line In the long run, maybe we can address this from another angle in the sound library. If we only create the AudioContext on a user gesture, and wait for that Promise/callback before creating any p5.sound objects, we could also wait for the AudioWorklet modules to load as part of that sound initialization...I'm just starting to think this through in https://github.com/processing/p5.js-sound/issues/389, please chime in! |
wait, I'm not sure if this solution works when loading a page directly for an example that does not have a "preload" method but uses the sound library. For example, try typing
But it wasn't actually found, so it fails on |
38dc6b4
to
35020e1
Compare
@therewasaguy You're totally right, thanks for catching that! Sorry for taking so long to get around to this, but I finally found the time to open a PR on the p5-website repo with a fix that accounts for the problem that Jason brought up: processing/p5.js-website#524 |
- improved inline documentation - all examples start audio on user gesture processing/p5.js-sound#403 - AudioWorklet replaces the deprecated ScriptProcessorNode (when available) in p5.SoundRecorder, p5.Amplitude, and p5.SoundFile, as part of @oshoham's GSoC project https://github.com/processing/p5.js/blob/master/developer_docs/project_wrapups/orenshoham_gsoc_2019.md processing/p5.js-sound#369 processing/p5.js-sound#373 - p5 library compiled with webpack so it looks a little different and we had to remove comments that were tripping up YUIDoc here in the p5.js repo - p5.SoundFile: stop() won't stop a soundfile loop https://github.com/processing/p5.js-sound/issues/401 - p5.SoundFile: addCue() not triggering function calls https://github.com/processing/p5.js-sound/issues/371 - p5.SoundFile: jump() only called if soundfile is playing processing/p5.js-sound#404 - p5.SoundFile: save() bugfix processing/p5.js-sound#406 - remove bad console call (processing/p5.js-sound#378)
92542d2
to
61ac195
Compare
I think this is ready, thanks to processing/p5.js-website#524 Also! In the meantime, add a few bugfixes
and updated inline documentation examples so that every example starts audio on a user gesture and abides by autoplay policies (processing/p5.js-sound#403) |
awesome, thanks @therewasaguy and @oshosham! |
Cool, do you think this might fix https://github.com/processing/p5.js-sound/issues/387 ? |
visiting this link as provided in however resuming the audioContext does the job ! |
@endurance21 The sketch in the provided link is still using v0.3.11 of p5.Sound so any fix would not be present in there. Can you try with the latest version and open a new issue if the problem is still there? |
@limzykenneth |
The editor has not been updated to use the latest version of the library yet. You can change that yourself by editing the |
@limzykenneth i tried |
@limzykenneth is this the problem with web editor or with p5.sound , because it works well with localhost but problem exists when the sketch is shared or downloaded for presentation ! i think this might be problem with web-editor as well ? |
@endurance21 Can you post your findings over at https://github.com/processing/p5.js-sound/issues/387 so we can track it centrally instead of discussing on this PR. Thanks. |
Hello! We have an update to p5 sound library:
BUT it is currently blocked by https://github.com/processing/p5.js-sound/issues/382: AudioWorklet preload conflicts with example 'render' script
^ Anyone have ideas for how to address that? cc @limzykenneth I thought you might since you've worked on the render.js script recently (if the fix should happen there). Or @meiamsome since you've recently added a Promise-based preload mechanism?