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

Trying to figure out web_sys::AudioWorkletProcessor #2308

Closed
SephReed opened this issue Sep 15, 2020 · 1 comment
Closed

Trying to figure out web_sys::AudioWorkletProcessor #2308

SephReed opened this issue Sep 15, 2020 · 1 comment
Labels

Comments

@SephReed
Copy link

SephReed commented Sep 15, 2020

Summary

I'd like to create and register an AudioWorkletProcessor using Rust. I'm still not sure if it's possible.

Additional Details

I've also put up a question on StackOverflow.

I'm currently stuck on having to extend AudioWorkletProcessor for the sake of overriding the process() function. And I'm also not yet sure if it's going to be possible to access AudioWorkletGlobalScope. On top of all this, I have no idea if it will play well with webpack / or any other bundler. This is what I've got so far:

use wasm_bindgen::prelude::*;
use web_sys::{ AudioWorkletGlobalScope };

#[wasm_bindgen]
pub fn create_worklet_node() {
  AudioWorkletGlobalScope::register_processor(/* MISSING ARGUMENTS */);
}


#[wasm_bindgen]
extern "C" {
  #[wasm_bindgen(extends = web_sys::AudioWorkletProcessor)]
  type MyAudioWorkletProcessor;
}

#[wasm_bindgen]
impl MyAudioWorkletProcessor {
  pub fn process() {
    // this would throw an error if I was doing it right... :/ 
  }
}

Potential Incentive

I think that multi-threaded audio processing is an extremely good example of the power of wasm, so I'd probably not be the only person who could really use an example of how to set up an AudioWorklet using Rust.

Thanks for this project!

@alexcrichton
Copy link
Contributor

I think this is covered by #210, so I'm going to close this in favor of that.

(although if it's got pieces which aren't part of that, please feel free to file a new issue!)

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

No branches or pull requests

2 participants