-
Notifications
You must be signed in to change notification settings - Fork 49
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
Implement WaveShaper node #205
Comments
For ease of implementation, don't both supporting oversampling at first. |
WaveShaper node implementation without oversampling Issue at hand: #205
I'd like to take a shot at oversampling, but how should it be implemented? Is adapting speex resampler code ok? Or maybe its better to use some existing lib? |
Adapting the speex code seems like a reasonable choice. |
Ok, thanks, I'm not sure in my ability but I'll try. |
Yeah, https://github.com/xiph/speexdsp/blob/master/libspeexdsp/resample.c looks pretty complicated :( It might be worth trying out https://github.com/suhr/resample/blob/master/src/lib.rs? |
@jdm i arrived at some 2x upsampling implementation but im not sure how to structure Right now block's buffer is hardcoded to store So idk how to proceed here, should I store something like frequency multiplier in a block? |
@khodzha don't, use 2x or 4x the blocks before wave shaping. Firefox does something similar. WaveShaper is supposed to downsample after upsampling so it's fine if a block is temporarily representing only half or quarter of a frame. |
To be honest I'm kind of stuck wondering if my oversampling is useful at all, probably I'm missing something? I dont have any experience with digital signal processing Right now my 2x oversampling implementation upsamples like in https://github.com/suhr/resample/blob/master/src/lib.rs using method described here: https://ccrma.stanford.edu/~jos/resample/ So I upsample with this process, apply waveshaping curve and then downsample by simply throwing out every odd sample. The problem is since both upsampling and downsampling leave every even sample as it is this whole process outputs same numbers whether there is oversampling or not. |
Huh. This is true, the spec slightly mentions that filters can be applied but it's frustratingly vague. Perhaps file a spec bug? And/or look at the Firefox code. |
I want to try out oversampling with libspeex-dsp first |
Using https://github.com/rust-av/speexdsp-rs I get noise with 2x oversampling (and even more with 4x) both with quality=0 (used in firefox) and quality=5 (and right-padding a block with 0f32 since quality=5 requires more than 128 insamples to produce 256 outsamples) 😞 |
2x and 4x oversampling for WaveShaperNode Issue #205 Finally managed to defeat the noise I mentioned in the issue I'm not sure if ditching FrameIterator and operating on raw vecs was a good thing 🤷♂️ Also spec mentions tail-time but I'm not sure how to handle that
@Manishearth should we close this? |
Spec: https://webaudio.github.io/web-audio-api/#waveshapernode
Reference processing code: https://searchfox.org/mozilla-central/source/dom/media/webaudio/WaveShaperNode.cpp
The text was updated successfully, but these errors were encountered: