diff --git a/luda-editor/new-client/Cargo.lock b/luda-editor/new-client/Cargo.lock index 2eba5fb1c..46b0801c3 100644 --- a/luda-editor/new-client/Cargo.lock +++ b/luda-editor/new-client/Cargo.lock @@ -72,6 +72,28 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alsa" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" +dependencies = [ + "alsa-sys", + "bitflags 2.4.1", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "android-activity" version = "0.5.0" @@ -199,45 +221,43 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.69.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "cexpr", "clang-sys", "lazy_static", "lazycell", + "log", "peeking_take_while", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.105", + "syn 2.0.71", + "which", ] [[package]] name = "bindgen" -version = "0.69.1" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags 2.4.1", "cexpr", "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", + "itertools", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", "syn 2.0.71", - "which", ] [[package]] @@ -415,6 +435,15 @@ dependencies = [ "libloading 0.7.4", ] +[[package]] +name = "cmake" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +dependencies = [ + "cc", +] + [[package]] name = "cobs" version = "0.2.3" @@ -480,6 +509,49 @@ dependencies = [ "libc", ] +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ce857aa0b77d77287acc1ac3e37a05a8c95a2af3647d23b15f263bdaeb7562b" +dependencies = [ + "bindgen 0.70.1", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -553,6 +625,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "dbus" version = "0.9.7" @@ -681,28 +759,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" -[[package]] -name = "ffmpeg-next" -version = "6.1.0" -dependencies = [ - "bitflags 1.3.2", - "ffmpeg-sys-next", - "libc", -] - -[[package]] -name = "ffmpeg-sys-next" -version = "6.1.0" -dependencies = [ - "bindgen 0.64.0", - "cc", - "flate2", - "libc", - "num_cpus", - "pkg-config", - "tar", -] - [[package]] name = "filetime" version = "0.2.23" @@ -1123,6 +1179,15 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.4" @@ -1303,6 +1368,15 @@ dependencies = [ "walkdir", ] +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "macro-common-lib" version = "0.1.0" @@ -1377,8 +1451,8 @@ version = "0.1.0" dependencies = [ "anyhow", "bytes", + "cpal", "dashmap 5.5.3", - "ffmpeg-next", "futures", "http", "http-body", @@ -1393,10 +1467,14 @@ dependencies = [ "namui-skia", "namui-type", "num", + "ogg", "opener", + "opusic-sys", "percent-encoding", + "pin-project", "rand", "rayon", + "rubato", "rusqlite", "serde", "serde_json", @@ -1598,6 +1676,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1702,6 +1791,38 @@ dependencies = [ "memchr", ] +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + +[[package]] +name = "ogg" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5477016638150530ba21dec7caac835b29ef69b20865751d2973fce6be386cf1" +dependencies = [ + "byteorder", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -1726,6 +1847,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "opusic-sys" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5674e9b17161beea3d6ae7416a18cdf48f53f6ecf47a3434acd6224b067b4802" +dependencies = [ + "cmake", + "libc", +] + [[package]] name = "orbclient" version = "0.3.47" @@ -1860,6 +1991,15 @@ dependencies = [ "syn 2.0.71", ] +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + [[package]] name = "proc-macro-crate" version = "2.0.1" @@ -2031,6 +2171,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "realfft" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953d9f7e5cdd80963547b456251296efc2626ed4e3cbf36c869d9564e0220571" +dependencies = [ + "rustfft", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -2161,6 +2310,18 @@ dependencies = [ "macro-common-lib", ] +[[package]] +name = "rubato" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5d18b486e7d29a408ef3f825bc1327d8f87af091c987ca2f5b734625940e234" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "realfft", +] + [[package]] name = "rusqlite" version = "0.31.0" @@ -2203,6 +2364,21 @@ dependencies = [ "semver", ] +[[package]] +name = "rustfft" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43806561bc506d0c5d160643ad742e3161049ac01027b5e6d7524091fd401d86" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", + "version_check", +] + [[package]] name = "rustix" version = "0.38.28" @@ -2548,6 +2724,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + [[package]] name = "strict-num" version = "0.1.1" @@ -2820,6 +3002,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -3232,6 +3424,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.5", +] + [[package]] name = "windows" version = "0.56.0" @@ -3251,6 +3453,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.5", +] + [[package]] name = "windows-core" version = "0.56.0" diff --git a/luda-editor/new-client/src/asset_manage_page.rs b/luda-editor/new-client/src/asset_manage_page.rs index 3dd8c2ed0..2dda73d3c 100644 --- a/luda-editor/new-client/src/asset_manage_page.rs +++ b/luda-editor/new-client/src/asset_manage_page.rs @@ -3,6 +3,7 @@ use luda_rpc::{asset::reserve_team_asset_upload, AssetKind}; use namui::*; use namui_prebuilt::table::*; use network::http; +use psd_sprite::encode_psd_sprite; use tokio::sync::mpsc::UnboundedReceiver; pub struct AssetManagePage<'a> { @@ -24,11 +25,15 @@ impl Component for AssetManagePage<'_> { toast::negative("에셋 파일 선택 실패"); return; }; + let Ok(encoded_bytes) = encode_psd_sprite(&bytes) else { + toast::negative("에셋 인코딩 실패"); + return; + }; match server_connection() .reserve_team_asset_upload(RefRequest { team_id: &team_id, asset_name: &name, - byte_size: bytes.len() as u64, + byte_size: encoded_bytes.len() as u64, asset_kind: &AssetKind::Sprite, }) .await @@ -37,7 +42,7 @@ impl Component for AssetManagePage<'_> { presigned_put_uri, headers, .. - }) => match upload_asset(presigned_put_uri, headers, bytes).await { + }) => match upload_asset(presigned_put_uri, headers, encoded_bytes).await { Ok(_) => toast::positive("에셋 업로드 성공".to_string()), Err(_) => toast::negative("에셋 업로드 실패".to_string()), }, diff --git a/luda-editor/new-client/src/select_asset_file.js b/luda-editor/new-client/src/select_asset_file.js index f9707e878..77eb8b717 100644 --- a/luda-editor/new-client/src/select_asset_file.js +++ b/luda-editor/new-client/src/select_asset_file.js @@ -30,3 +30,7 @@ inputElement.click(); function namui_onDrop() { inputElement.remove(); } + +function namui_onData() { + return; +} diff --git a/luda-editor/psd-sprite-render/Cargo.lock b/luda-editor/psd-sprite-render/Cargo.lock index 6f346f6c6..58ccb52e7 100644 --- a/luda-editor/psd-sprite-render/Cargo.lock +++ b/luda-editor/psd-sprite-render/Cargo.lock @@ -78,6 +78,28 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alsa" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" +dependencies = [ + "alsa-sys", + "bitflags 2.6.0", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + [[package]] name = "android-activity" version = "0.5.2" @@ -205,45 +227,43 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", - "peeking_take_while", + "log", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.75", + "which", ] [[package]] name = "bindgen" -version = "0.69.4" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", - "log", - "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", "syn 2.0.75", - "which", ] [[package]] @@ -421,6 +441,15 @@ dependencies = [ "libloading", ] +[[package]] +name = "cmake" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +dependencies = [ + "cc", +] + [[package]] name = "cobs" version = "0.2.3" @@ -486,6 +515,49 @@ dependencies = [ "libc", ] +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ce857aa0b77d77287acc1ac3e37a05a8c95a2af3647d23b15f263bdaeb7562b" +dependencies = [ + "bindgen 0.70.1", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -545,6 +617,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + [[package]] name = "dbus" version = "0.9.7" @@ -685,28 +763,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" -[[package]] -name = "ffmpeg-next" -version = "6.1.0" -dependencies = [ - "bitflags 1.3.2", - "ffmpeg-sys-next", - "libc", -] - -[[package]] -name = "ffmpeg-sys-next" -version = "6.1.0" -dependencies = [ - "bindgen 0.64.0", - "cc", - "flate2", - "libc", - "num_cpus", - "pkg-config", - "tar", -] - [[package]] name = "filetime" version = "0.2.24" @@ -1294,6 +1350,15 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "macro-common-lib" version = "0.1.0" @@ -1360,8 +1425,8 @@ version = "0.1.0" dependencies = [ "anyhow", "bytes", + "cpal", "dashmap", - "ffmpeg-next", "futures", "http", "http-body", @@ -1376,10 +1441,14 @@ dependencies = [ "namui-skia", "namui-type", "num", + "ogg", "opener", + "opusic-sys", "percent-encoding", + "pin-project", "rand", "rayon", + "rubato", "rusqlite", "serde", "serde_json", @@ -1561,6 +1630,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -1663,6 +1743,38 @@ dependencies = [ "memchr", ] +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + +[[package]] +name = "ogg" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5477016638150530ba21dec7caac835b29ef69b20865751d2973fce6be386cf1" +dependencies = [ + "byteorder", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -1687,6 +1799,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "opusic-sys" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5674e9b17161beea3d6ae7416a18cdf48f53f6ecf47a3434acd6224b067b4802" +dependencies = [ + "cmake", + "libc", +] + [[package]] name = "orbclient" version = "0.3.47" @@ -1730,12 +1852,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -1827,6 +1943,15 @@ dependencies = [ "syn 2.0.75", ] +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -1992,6 +2117,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "realfft" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953d9f7e5cdd80963547b456251296efc2626ed4e3cbf36c869d9564e0220571" +dependencies = [ + "rustfft", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -2112,6 +2246,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rubato" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5d18b486e7d29a408ef3f825bc1327d8f87af091c987ca2f5b734625940e234" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "realfft", +] + [[package]] name = "rusqlite" version = "0.31.0" @@ -2154,6 +2300,21 @@ dependencies = [ "semver", ] +[[package]] +name = "rustfft" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43806561bc506d0c5d160643ad742e3161049ac01027b5e6d7524091fd401d86" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", + "version_check", +] + [[package]] name = "rustix" version = "0.38.34" @@ -2498,6 +2659,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + [[package]] name = "strict-num" version = "0.1.1" @@ -2779,6 +2946,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -3177,6 +3354,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.56.0" @@ -3196,6 +3383,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.56.0" diff --git a/namui/namui-cli/webCode/src/insertJs.ts b/namui/namui-cli/webCode/src/insertJs.ts index bbd050ba3..9db1c406b 100644 --- a/namui/namui-cli/webCode/src/insertJs.ts +++ b/namui/namui-cli/webCode/src/insertJs.ts @@ -112,13 +112,14 @@ export function insertJsHandleOnMainThread( sendDataQueueMap: new Map(), }); - script.textContent = `const namui_sendData = (data) => { - window.namui_onDataFromJs(${jsId}, data); - } - ${js} - window.namui_onDrop_${jsId} = namui_onDrop; - window.namui_onDataFromRust_${jsId} = namui_onData; - `; + script.textContent = `{ + const namui_sendData = (data) => { + window.namui_onDataFromJs(${jsId}, data); + } + ${js} + window.namui_onDrop_${jsId} = namui_onDrop; + window.namui_onDataFromRust_${jsId} = namui_onData; + }`; document.body.appendChild(script); }, onInsertJsDrop({ diff --git a/namui/namui/src/system/audio/opus.rs b/namui/namui/src/system/audio/opus.rs index 21eb6f59b..b8466ec81 100644 --- a/namui/namui/src/system/audio/opus.rs +++ b/namui/namui/src/system/audio/opus.rs @@ -157,31 +157,32 @@ where let mut sample_count = 0; while !interleaved_samples.is_empty() { - let frame_size = if interleaved_samples.len() > MAX_FRAME_SIZE { + let frame_size = if interleaved_samples.len() > MAX_FRAME_SIZE * channel_count { MAX_FRAME_SIZE } else { MIN_FRAME_SIZE }; + let pcm_len = frame_size * channel_count; let mut output_buffer: Vec = vec![0; 8192]; - let frame = { - if interleaved_samples.len() > frame_size { - Cow::Borrowed(&interleaved_samples[..frame_size]) + let pcm = { + if interleaved_samples.len() > pcm_len { + Cow::Borrowed(&interleaved_samples[..pcm_len]) } else { - let mut frame = Vec::with_capacity(frame_size); + let mut frame = Vec::with_capacity(pcm_len); frame.extend_from_slice(interleaved_samples); - frame.extend(vec![0.0; frame_size - interleaved_samples.len()]); + frame.extend(vec![0.0; pcm_len - interleaved_samples.len()]); Cow::Owned(frame) } }; - assert_eq!(frame_size, frame.len()); + assert_eq!(pcm_len, pcm.len()); - let is_end = frame_size >= interleaved_samples.len(); + let is_end = pcm_len >= interleaved_samples.len(); let output_len = opus_encode_float( encoder, - frame.as_ptr(), + pcm.as_ptr(), frame_size as c_int, output_buffer.as_mut_ptr(), output_buffer.len() as c_int, @@ -196,7 +197,8 @@ where sample_count += frame_size; - let absgp = lookahead as usize + sample_count; + // https://wiki.xiph.org/OggOpus#Granule_Position + let granule_position = lookahead as usize + sample_count; writer.write_packet( output_buffer, @@ -206,11 +208,10 @@ where } else { ogg::PacketWriteEndInfo::NormalPacket }, - absgp as u64, + granule_position as u64, )?; - interleaved_samples = - &interleaved_samples[(frame_size.min(interleaved_samples.len()))..]; + interleaved_samples = &interleaved_samples[(pcm_len.min(interleaved_samples.len()))..]; } } diff --git a/namui/sample/websocket/Cargo.toml b/namui/sample/websocket/Cargo.toml index 49fc03a86..949214240 100644 --- a/namui/sample/websocket/Cargo.toml +++ b/namui/sample/websocket/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [package.metadata.namui] -targets = ["wasm32-wasip1-threads"] +targets = ["wasm32-wasi-web"] [dependencies] namui = { path = "../../namui" }