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

oscillator waveforms are not band limited #195

Open
Avataren opened this issue Sep 7, 2023 · 6 comments
Open

oscillator waveforms are not band limited #195

Avataren opened this issue Sep 7, 2023 · 6 comments

Comments

@Avataren
Copy link
Contributor

Avataren commented Sep 7, 2023

It seems like all the non sine waveforms are not band limited, which creates a ton of aliasing when generating sound.
Are there any plans to implement this? It's an important part of the web audio spec on oscillators.

It could be that I'm just missing a custom node that does this, so if there already is a solution for this, I'd love to hear it :)

@Avataren
Copy link
Contributor Author

Avataren commented Sep 7, 2023

I did discover the PolyBlep node after digging around a little, but for some reason I'm not able to schedule frequency changes on this node.

polyBlep->frequency()->setValueAtTime(110, currentTime); // does not work, but does work on oscilltor node
but using setValue works
polyBlep->frequency()->setValue(110); // works

Connecting nodes for an LFO, like oscillator->gain->(polyBlep.frequency) also does not work, but works fine for oscillators.

@Avataren
Copy link
Contributor Author

Avataren commented Sep 7, 2023

I managed to fix this by basically duplicating the amplitude logic for frequencies in PolyBLEPNode::processPolyBLEP

@Avataren
Copy link
Contributor Author

Avataren commented Sep 7, 2023

Another problem is the lack of detune param on the PolyBLEPNode.

@Avataren
Copy link
Contributor Author

Avataren commented Sep 7, 2023

I managed to implement the detune param for the polyBlepNode as well by studying the code for oscillator.

@Avataren
Copy link
Contributor Author

Avataren commented Sep 8, 2023

For the polyBlepNode to be a useful substitution for the oscillatorNode, it might also be a good idea to support a pure sine waveform. I added this to my fork, so I don't have to swap out the node just to get a sinewave.

@meshula
Copy link
Member

meshula commented Sep 10, 2023

Thanks for these notes. PolyBLEP is still under construction, but should ultimately be controllable as you note. We haven't worked on PolyBLEP recently, but parameter rate control was the thing holding back a replacement of the OscillatorNode implementation. I'd be delighted to get a pull request that takes PolyBLEP over the finish line.

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

No branches or pull requests

2 participants