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

AudioWorklet (Naive draft) #826

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.DS_Store
recorded.wav
rls*.log
.vscode/
68 changes: 58 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ edition = "2021"
rust-version = "1.70"

[features]
asio = ["asio-sys", "num-traits"] # Only available on Windows. See README for setup instructions.
oboe-shared-stdcxx = ["oboe/shared-stdcxx"] # Only available on Android. See README for what it does.
asio = [
"asio-sys",
"num-traits",
] # Only available on Windows. See README for setup instructions.
oboe-shared-stdcxx = [
"oboe/shared-stdcxx",
] # Only available on Android. See README for what it does.
wasm-bindgen-test = [
"wasm-bindgen"
]

[dependencies]
dasp_sample = "0.11"
Expand All @@ -25,6 +33,12 @@ clap = { version = "4.0", features = ["derive"] }
[target.'cfg(target_os = "android")'.dev-dependencies]
ndk-glue = "0.7"

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
wasm-bindgen-test = "0.3.4"
console_log = "*"
rand = "0.8.5"
getrandom = {version = "*", features = ["js"]}

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.52.0", features = [
"Win32_Media_Audio",
Expand All @@ -37,8 +51,8 @@ windows = { version = "0.52.0", features = [
"Win32_System_SystemServices",
"Win32_System_Variant",
"Win32_Media_Multimedia",
"Win32_UI_Shell_PropertiesSystem"
]}
"Win32_UI_Shell_PropertiesSystem",
] }
asio-sys = { version = "0.2", path = "asio-sys", optional = true }
num-traits = { version = "0.2.6", optional = true }
parking_lot = "0.12"
Expand All @@ -51,28 +65,62 @@ jack = { version = "0.11", optional = true }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
core-foundation-sys = "0.8.2" # For linking to CoreFoundation.framework and handling device name `CFString`s.
mach2 = "0.4" # For access to mach_timebase type.
mach2 = "0.4" # For access to mach_timebase type.
parking_lot = "0.12"

[target.'cfg(target_os = "macos")'.dependencies]
coreaudio-rs = { version = "0.11", default-features = false, features = ["audio_unit", "core_audio"] }
coreaudio-rs = { version = "0.11", default-features = false, features = [
"audio_unit",
"core_audio",
] }

[target.'cfg(target_os = "ios")'.dependencies]
coreaudio-rs = { version = "0.11", default-features = false, features = ["audio_unit", "core_audio", "audio_toolbox"] }
coreaudio-rs = { version = "0.11", default-features = false, features = [
"audio_unit",
"core_audio",
"audio_toolbox",
] }

[target.'cfg(target_os = "emscripten")'.dependencies]
wasm-bindgen = { version = "0.2.89" }
wasm-bindgen-futures = "0.4.33"
js-sys = { version = "0.3.35" }
web-sys = { version = "0.3.35", features = [ "AudioContext", "AudioContextOptions", "AudioBuffer", "AudioBufferSourceNode", "AudioNode", "AudioDestinationNode", "Window", "AudioContextState"] }
web-sys = { version = "0.3.35", features = [
"AudioContext",
"AudioContextOptions",
"AudioBuffer",
"AudioBufferSourceNode",
"AudioNode",
"AudioDestinationNode",
"Window",
"AudioContextState",
"ChannelCountMode"
] }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
wasm-bindgen = { version = "0.2.58", optional = true }
js-sys = { version = "0.3.35" }
web-sys = { version = "0.3.35", features = [ "AudioContext", "AudioContextOptions", "AudioBuffer", "AudioBufferSourceNode", "AudioNode", "AudioDestinationNode", "Window", "AudioContextState"] }
web-sys = { version = "0.3.35", features = [
"AudioContext",
"AudioContextOptions",
"AudioWorklet",
"AudioWorkletNode",
"MessagePort",
"MessageEvent",
"AudioNode",
"AudioDestinationNode",
"Window",
"AudioContextState",
"MediaDevices",
"MediaStreamConstraints",
"AbortController",
"AbortSignal",
] }
wasm-bindgen-futures = { version = "0.4.40" }
log = "*"

[target.'cfg(target_os = "android")'.dependencies]
oboe = { version = "0.5", features = [ "java-interface" ] }
oboe = { version = "0.5", features = ["java-interface"] }
ndk = { version = "0.8", default-features = false }
ndk-context = "0.1"
jni = "0.19"
Expand Down
6 changes: 4 additions & 2 deletions examples/wasm-beep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ wasm-bindgen = "0.2.45"
# compared to the default allocator's ~10K. However, it is slower than the default
# allocator, so it's not enabled by default.
wee_alloc = { version = "0.4.2", optional = true }
console_error_panic_hook = "0.1.5"
console_log = "*"
log= "*"

# The `web-sys` crate allows you to interact with the various browser APIs,
# like the DOM.
Expand All @@ -37,5 +40,4 @@ features = ["console"]
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled
# in debug mode.
[target."cfg(debug_assertions)".dependencies]
console_error_panic_hook = "0.1.5"
# [target."cfg(debug_assertions)".dependencies]
4 changes: 3 additions & 1 deletion examples/wasm-beep/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
pub fn main_js() -> Result<(), JsValue> {
// This provides better error messages in debug mode.
// It's disabled in release mode, so it doesn't bloat up the file size.
#[cfg(debug_assertions)]
// #[cfg(debug_assertions)]
console_error_panic_hook::set_once();
console_log::init_with_level(log::Level::Debug);
log::info!("init log");

Ok(())
}
Expand Down
5 changes: 4 additions & 1 deletion examples/wasm-beep/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

Expand All @@ -21,6 +20,10 @@ module.exports = {
static: {
directory: dist
},
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
}
},
plugins: [
new HtmlWebpackPlugin({
Expand Down
Loading
Loading