From a7b1910ebf52c185d6d6953d7b9f7a3876ae9224 Mon Sep 17 00:00:00 2001 From: Zane has to use Windows Date: Wed, 24 Jul 2024 11:11:14 -0400 Subject: [PATCH 1/3] wip: try using hex --- src/components/Keyboard/Keyboard.tsx | 12 +++++++++--- src/components/Quiz/Quiz.tsx | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/Keyboard/Keyboard.tsx b/src/components/Keyboard/Keyboard.tsx index 5e71ca1..09b9503 100644 --- a/src/components/Keyboard/Keyboard.tsx +++ b/src/components/Keyboard/Keyboard.tsx @@ -78,9 +78,14 @@ const Keyboard = () => { listen('midi_message', (event) => { const payload = event.payload as { message: number[] } - const [command, note, velocity] = payload.message + const [status, note, velocity] = payload.message - if (command === 144 || command === 155) { + const command = status & 0xf0 + + console.log(status, command) + + if (command === 0x90) { + // Note on setActiveNotes((an) => ({ ...an, [note]: true, @@ -89,7 +94,8 @@ const Keyboard = () => { // some midi keyboards don't send the off signal, // they just set the velocity to 0 - if (command === 128 || command === 139 || velocity === 0) { + if (command === 0x80 || velocity === 0) { + // Note off setActiveNotes((an) => ({ ...an, [note]: false, diff --git a/src/components/Quiz/Quiz.tsx b/src/components/Quiz/Quiz.tsx index e7d8463..a1f1e9f 100644 --- a/src/components/Quiz/Quiz.tsx +++ b/src/components/Quiz/Quiz.tsx @@ -120,9 +120,12 @@ const Quiz = () => { listen('midi_message', (event) => { const payload = event.payload as { message: number[] } - const [command, note, velocity] = payload.message + const [status, note, velocity] = payload.message - if (command === 144 || command === 155) { + const command = status & 0xf0 + + if (command === 0x90) { + // Note off setChordStack?.((cs) => [...cs, note]) setActiveNotes((an) => ({ ...an, @@ -130,7 +133,8 @@ const Quiz = () => { })) } - if (command === 128 || command === 139 || velocity === 0) { + if (command === 0x80 || velocity === 0) { + // Note on // remove midiNumber from chordStack setChordStack?.((cs) => { const removalIdx = cs.indexOf(note) From db7c78fd51e98351091fe8b817b4e86cf1ce3a43 Mon Sep 17 00:00:00 2001 From: Zane Helton Date: Wed, 24 Jul 2024 11:26:53 -0400 Subject: [PATCH 2/3] fix: change midir to v0.8.0 --- src-tauri/Cargo.lock | 91 +++++++++++--------------------------------- src-tauri/Cargo.toml | 2 +- 2 files changed, 23 insertions(+), 70 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 9e0aad3..6c578fc 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -43,13 +43,14 @@ dependencies = [ [[package]] name = "alsa" -version = "0.9.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37fe60779335388a88c01ac6c3be40304d1e349de3ada3b15f7808bb90fa9dce" +checksum = "5915f52fe2cf65e83924d037b6c5290b7cee097c6b5c8700746e6168a343fd6b" dependencies = [ "alsa-sys", - "bitflags 2.6.0", + "bitflags 1.3.2", "libc", + "nix 0.23.2", ] [[package]] @@ -565,11 +566,10 @@ dependencies = [ [[package]] name = "coremidi" -version = "0.8.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "964eb3e10ea8b0d29c797086aab3ca730f75e06dced0cb980642fd274a5cca30" +checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5" dependencies = [ - "block", "core-foundation", "core-foundation-sys", "coremidi-sys", @@ -1777,7 +1777,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core", ] [[package]] @@ -2129,6 +2129,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "memalloc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df39d232f5c40b0891c10216992c2f250c054105cb1e56f0fc9032db6203ecc1" + [[package]] name = "memchr" version = "2.5.0" @@ -2173,19 +2179,19 @@ dependencies = [ [[package]] name = "midir" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe36f39751eb1f449490d4a236e8642c8efee1a87fa81785b063289b689dc84e" +checksum = "2c1c68e2b589cce71b14a10d7d1599a845673f9decde80fa9e8500fdccd50dca" dependencies = [ "alsa", "bitflags 1.3.2", "coremidi", "js-sys", "libc", - "parking_lot", + "memalloc", "wasm-bindgen", "web-sys", - "windows 0.56.0", + "windows 0.32.0", ] [[package]] @@ -4114,7 +4120,7 @@ dependencies = [ "unicode-segmentation", "uuid", "windows 0.39.0", - "windows-implement 0.39.0", + "windows-implement", "x11-dl", ] @@ -5072,7 +5078,7 @@ dependencies = [ "webview2-com-macros", "webview2-com-sys", "windows 0.39.0", - "windows-implement 0.39.0", + "windows-implement", ] [[package]] @@ -5188,7 +5194,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" dependencies = [ - "windows-implement 0.39.0", + "windows-implement", "windows_aarch64_msvc 0.39.0", "windows_i686_gnu 0.39.0", "windows_i686_msvc 0.39.0", @@ -5202,17 +5208,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ - "windows-core 0.52.0", - "windows-targets 0.52.5", -] - -[[package]] -name = "windows" -version = "0.56.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" -dependencies = [ - "windows-core 0.56.0", + "windows-core", "windows-targets 0.52.5", ] @@ -5235,18 +5231,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "windows-core" -version = "0.56.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" -dependencies = [ - "windows-implement 0.56.0", - "windows-interface", - "windows-result", - "windows-targets 0.52.5", -] - [[package]] name = "windows-implement" version = "0.39.0" @@ -5257,43 +5241,12 @@ dependencies = [ "windows-tokens", ] -[[package]] -name = "windows-implement" -version = "0.56.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.68", -] - -[[package]] -name = "windows-interface" -version = "0.56.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.68", -] - [[package]] name = "windows-metadata" version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278" -[[package]] -name = "windows-result" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" -dependencies = [ - "windows-targets 0.52.5", -] - [[package]] name = "windows-sys" version = "0.36.1" @@ -5762,7 +5715,7 @@ dependencies = [ "webkit2gtk-sys", "webview2-com", "windows 0.39.0", - "windows-implement 0.39.0", + "windows-implement", ] [[package]] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 15e20d9..6e223a3 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,7 +18,7 @@ tauri-build = { version = "1.5.3", features = [] } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } tauri = { version = "1.6.8", features = [ "updater", "api-all"] } -midir = "0.10.0" +midir = "0.8.0" tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } [dependencies.sentry-tauri] From a17d7e9e44497d11a833a0ed8b6c25ea58cfcc75 Mon Sep 17 00:00:00 2001 From: Zane Helton Date: Wed, 24 Jul 2024 11:31:02 -0400 Subject: [PATCH 3/3] chore: remove console.log() --- src/components/Keyboard/Keyboard.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/Keyboard/Keyboard.tsx b/src/components/Keyboard/Keyboard.tsx index 09b9503..191bd50 100644 --- a/src/components/Keyboard/Keyboard.tsx +++ b/src/components/Keyboard/Keyboard.tsx @@ -82,8 +82,6 @@ const Keyboard = () => { const command = status & 0xf0 - console.log(status, command) - if (command === 0x90) { // Note on setActiveNotes((an) => ({