-
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
2x and 4x oversampling for WaveShaperNode #332
Conversation
0b45b68
to
6aac50e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Should we wait for it to be released to crates.io
? I don't want to use a git dependency for something that's not a rapidly-changing servo crate.
We could also publish a fork.
audio/Cargo.toml
Outdated
@@ -18,6 +18,10 @@ servo-media-player = { path = "../player" } | |||
servo-media-traits = { path = "../traits" } | |||
smallvec = "0.6.1" | |||
|
|||
[dependencies.speexdsp] | |||
git = "https://github.com/rust-av/speexdsp-rs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's not released yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like they're willing to make one soon! rust-av/speexdsp-rs#10
audio/wave_shaper_node.rs
Outdated
fn apply_curve(buf: &mut [f32], curve: &Vec<f32>) { | ||
buf.iter_mut().for_each(|sample| { | ||
let len = curve.len(); | ||
let curve_index: f32 = ((len - 1) as f32) * (*sample + 1.) / 2.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth moving (len - 1) / 2
and len
out of the closure. Probably will be done by the compiler anyway, but doesn't hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, I'll fix it up tomorrow
182bfdd
to
7acd6ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready to land once speexdsp releases
I prepared a crate with the stand alone resampler, if you could please confirm that the API exposed is fine for you I'll publish it. |
@khodzha ^^ |
9ab1116
to
79094ce
Compare
Updated PR to use this crate, API seems ok to me 🤷♂️ |
https://crates.io/crates/speexdsp-resampler published ! |
audio/wave_shaper_node.rs
Outdated
@@ -79,33 +93,68 @@ impl AudioNodeEngine for WaveShaperNode { | |||
AudioNodeType::WaveShaperNode | |||
} | |||
|
|||
fn process(&mut self, mut inputs: Chunk, _info: &BlockInfo) -> Chunk { | |||
fn process(&mut self, mut inputs: Chunk, info: &BlockInfo) -> Chunk { | |||
debug_assert!(inputs.len() == 1); | |||
|
|||
if inputs.blocks[0].is_silence() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Manishearth could you confirm whether tail-time here could be implemented like this:
if we hit two silent blocks in row after non-silent block, we explicit_silence()
them and run them through the waveshaping so all the tail-time from resampler would be spitted out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds correct.
79094ce
to
984bc8f
Compare
Added tail-time handling and properly handled the case when waveshaped silence is nonsilent |
984bc8f
to
1ab5c50
Compare
1ab5c50
to
a8a1f91
Compare
@bors-servo r+ thanks! |
📌 Commit a8a1f91 has been approved by |
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
☀️ Test successful - checks-travis |
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