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

Can't connect an oscillator to an envelope #44

Open
Metamere opened this issue Dec 11, 2024 · 7 comments
Open

Can't connect an oscillator to an envelope #44

Metamere opened this issue Dec 11, 2024 · 7 comments

Comments

@Metamere
Copy link

There seems to be an issue with the current version that prevents anything from being connected to an envelope. I have been unable to get envelopes to work in a sketch of mine, so I started experimenting using the examples that have an oscillator connected to an envelope, such as this one. When I update the version of p5.sound.min.js to the current one, then I get an error that prevents the program from running. If I disconnect things from the envelope, then the error goes away.

Error: error connecting to node: [object Object]
TypeError: Failed to execute 'connect' on 'AudioNode': Overload resolution failed.
at StereoPannerNode.t [as connect] (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/addons/p5.sound.min.js:2:20784)
at n.value (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/addons/p5.sound.min.js:2:98899)
at r.value (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/addons/p5.sound.min.js:2:123628)
at setup (/sketch.js:26:7)
at _setup (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/p5.js:66282:25)
at _runIfPreloadsAreDone (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/p5.js:66228:27)
at p5._decrementPreload (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/p5.js:66239:25)
at p5. (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.2/addons/p5.sound.min.js:2:98292)

@ogbabydiesal
Copy link
Collaborator

hi @Metamere i just confirmed the example you linked to does indeed work with the minimized p5.sound library found here: https://github.com/processing/p5.sound.js/releases/tag/v0.1.0

let us know if you are still having errors, maybe you are using a different release of p5.sound.min.js? or maybe i'm missing something but give it another try!

@Metamere
Copy link
Author

Hey, thanks for looking into things @ogbabydiesal. I guess I was confused, and thought that the 1.11.2 was the latest version. It seems I must be trying to use the new envelope setup with the older version, and it doesn't work. I can't find any good examples of how to make them work on the old version, though. And the new version doesn't have many of the features that I have been using, so I'm kind of at a loss on where to go from here. Do you have an example of how the envelope used to fit in a full signal chain so I can compare and understand what has changed?

@ogbabydiesal
Copy link
Collaborator

ogbabydiesal commented Dec 13, 2024

thanks for testing the new library and putting it through its paces - really interested to hear what features you would like so that we can discuss and implement if we feel its in the scope of the library. how are you using p5.sound.js? can you share some sketches in the editor?

there should be a writeup coming out soon that details the scope, changes and explains some of the deprecations in the new library- for now the collection you referenced is the best resource for a demonstration of features. but we could def use some more examples for sure -

the envelope in the new p5.sound.js library references this tonejs class btw - https://tonejs.github.io/docs/15.0.4/classes/AmplitudeEnvelope.html

ps. maybe we can make the envelope backwards compatible 🤔

@Metamere
Copy link
Author

I started working with p5.sound.js a couple of years ago with a sketch where I wanted to make a learning resource for the recorder. Over time it developed into a bigger music theory and performance instrument app. https://openprocessing.org/sketch/1779333. I was able to make the sound quality better this week with some effects and a different oscillator type for the drone sound. I tried using Tone.js with it, but found it completely inscrutable and unusable for the synths and such. Though I did actually find Tone.js a bit easier to work with for doing sample based instruments and kits, like in these sketches: https://openprocessing.org/sketch/1782970, https://openprocessing.org/sketch/1782970. I'd like to be able to use the new p5.sound for all of these, but also some more complex audio-visual type sketches. I was experimenting with that this week, and made this sketch for the weekly challenge: https://openprocessing.org/sketch/2485775. I started with one of your example sketches, and thought I was working with the new version, though it turned out not to be the case. I would like to try updating it and seeing if I can make it work. Does it look doable? Thanks for all your work on this project.

@Metamere
Copy link
Author

Metamere commented Dec 13, 2024

Well, I tried updating, and it seems the lowpass filter is replaced by biquad, which is fine. Then reverb doesn't have a drywet method though, and I don't see how to work something equivalent. Oh, by the way, it seems that the version of Tone.js you're using has the annoying issue where it pops up a message in open processing when it runs, saying "%c * Tone.js v15.0.2 * background: #000; color: #fff". A friend gave me a version of it that corrected that issue, and I used it in those couple sketches I linked. You could grab that, and carry over the minor changes to correct that issue. Oh, nice, I just saw your new fork of my sketch! That's cool that it still works with the new version. But are the effects just 100 wet, or some other fixed value? Is a control for that a planned addition for later? Either way, it sounds pretty great.

@ogbabydiesal
Copy link
Collaborator

yep was just about to respond:

p5.monosynth doesn't exist anymore but if you look at the tone.js documentation from where it originated you will see that it is just an oscillator, a filter and two envelopes (one for oscillator amplitude and one for filter cutoff), https://tonejs.github.io/examples/monoSynth

p5.LowPass() needs to be implemented as a subclass but you can make a low pass filter by creating a new instance of the p5.Biquad('lowpass') class.

Reverbs and delays in your sketch should be really similar.

you could also recreate your reflections on time piece in p5.sound.js - the Tone.Sampler class is awesome however and the way it works with Tone.Player is probably the most straightforward way to do things as it streamlines things a bit. but you could use the SoundFile() class and setPath() method to achieve something similar.

just forked your last sketch and updated it to work with the new p5.sound.js to send it over to ya
https://openprocessing.org/sketch/2487011

but yes dry wet will be implemented and its great to see your sketches so that i can/we can figure out the roadmap

@ogbabydiesal
Copy link
Collaborator

i've just implemented p5.LowPass, and p5.HighPass, and p5.BandPass directly now without having to specify p5.Biquad with a filter type - there isn't a new release for it just yet but if you build the library from the source code it's there - we should issue a new release soonish~

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

No branches or pull requests

2 participants