From d5cd7987b36743a5a5329e7af0c71973a9602bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Thu, 26 Feb 2026 19:37:19 -0500 Subject: [PATCH 1/9] Midi working --- Cargo.lock | 134 +++++++++++++-------------- crates/processing_render/src/lib.rs | 27 ++++++ crates/processing_render/src/midi.rs | 42 +++++++++ examples/midi.rs | 6 +- 4 files changed, 141 insertions(+), 68 deletions(-) create mode 100644 crates/processing_render/src/midi.rs diff --git a/Cargo.lock b/Cargo.lock index b2244a8..398f1d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,9 +222,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" @@ -507,7 +507,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bevy" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_internal", ] @@ -515,7 +515,7 @@ dependencies = [ [[package]] name = "bevy_a11y" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "accesskit", "bevy_app", @@ -527,7 +527,7 @@ dependencies = [ [[package]] name = "bevy_android" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "android-activity", ] @@ -535,7 +535,7 @@ dependencies = [ [[package]] name = "bevy_animation" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_animation_macros", "bevy_app", @@ -567,7 +567,7 @@ dependencies = [ [[package]] name = "bevy_animation_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "quote", @@ -577,7 +577,7 @@ dependencies = [ [[package]] name = "bevy_anti_alias" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -599,7 +599,7 @@ dependencies = [ [[package]] name = "bevy_app" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_derive", "bevy_ecs", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "bevy_asset" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "async-broadcast", "async-channel", @@ -664,7 +664,7 @@ dependencies = [ [[package]] name = "bevy_asset_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -675,7 +675,7 @@ dependencies = [ [[package]] name = "bevy_audio" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -692,7 +692,7 @@ dependencies = [ [[package]] name = "bevy_camera" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -717,7 +717,7 @@ dependencies = [ [[package]] name = "bevy_color" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_math", "bevy_reflect", @@ -732,7 +732,7 @@ dependencies = [ [[package]] name = "bevy_core_pipeline" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -760,7 +760,7 @@ dependencies = [ [[package]] name = "bevy_derive" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "quote", @@ -770,7 +770,7 @@ dependencies = [ [[package]] name = "bevy_dev_tools" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -801,7 +801,7 @@ dependencies = [ [[package]] name = "bevy_diagnostic" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "atomic-waker", "bevy_app", @@ -818,7 +818,7 @@ dependencies = [ [[package]] name = "bevy_ecs" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "arrayvec", "bevy_ecs_macros", @@ -845,7 +845,7 @@ dependencies = [ [[package]] name = "bevy_ecs_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -856,7 +856,7 @@ dependencies = [ [[package]] name = "bevy_encase_derive" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "encase_derive_impl", @@ -865,7 +865,7 @@ dependencies = [ [[package]] name = "bevy_feathers" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "accesskit", "bevy_a11y", @@ -894,7 +894,7 @@ dependencies = [ [[package]] name = "bevy_gilrs" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -909,7 +909,7 @@ dependencies = [ [[package]] name = "bevy_gizmos" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -928,7 +928,7 @@ dependencies = [ [[package]] name = "bevy_gizmos_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "quote", @@ -938,7 +938,7 @@ dependencies = [ [[package]] name = "bevy_gizmos_render" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "bevy_gltf" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "async-lock", "base64", @@ -998,7 +998,7 @@ dependencies = [ [[package]] name = "bevy_image" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1026,7 +1026,7 @@ dependencies = [ [[package]] name = "bevy_input" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -1042,7 +1042,7 @@ dependencies = [ [[package]] name = "bevy_input_focus" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -1058,7 +1058,7 @@ dependencies = [ [[package]] name = "bevy_internal" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_a11y", "bevy_android", @@ -1114,7 +1114,7 @@ dependencies = [ [[package]] name = "bevy_light" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1138,7 +1138,7 @@ dependencies = [ [[package]] name = "bevy_log" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "android_log-sys", "bevy_app", @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "bevy_macro_utils" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "proc-macro2", "quote", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "bevy_material" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_asset", "bevy_derive", @@ -1188,7 +1188,7 @@ dependencies = [ [[package]] name = "bevy_material_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "quote", @@ -1198,7 +1198,7 @@ dependencies = [ [[package]] name = "bevy_math" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "approx", "arrayvec", @@ -1217,7 +1217,7 @@ dependencies = [ [[package]] name = "bevy_mesh" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1274,7 +1274,7 @@ dependencies = [ [[package]] name = "bevy_pbr" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "arrayvec", "bevy_app", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "bevy_picking" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1338,7 +1338,7 @@ dependencies = [ [[package]] name = "bevy_platform" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "critical-section", "foldhash 0.2.0", @@ -1359,7 +1359,7 @@ dependencies = [ [[package]] name = "bevy_post_process" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1383,12 +1383,12 @@ dependencies = [ [[package]] name = "bevy_ptr" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" [[package]] name = "bevy_reflect" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "assert_type_match", "bevy_platform", @@ -1416,7 +1416,7 @@ dependencies = [ [[package]] name = "bevy_reflect_derive" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "indexmap", @@ -1429,7 +1429,7 @@ dependencies = [ [[package]] name = "bevy_render" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "async-channel", "bevy_app", @@ -1481,7 +1481,7 @@ dependencies = [ [[package]] name = "bevy_render_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -1492,7 +1492,7 @@ dependencies = [ [[package]] name = "bevy_scene" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "bevy_shader" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_asset", "bevy_platform", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "bevy_sprite" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1556,7 +1556,7 @@ dependencies = [ [[package]] name = "bevy_sprite_render" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1588,7 +1588,7 @@ dependencies = [ [[package]] name = "bevy_state" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -1603,7 +1603,7 @@ dependencies = [ [[package]] name = "bevy_state_macros" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_macro_utils", "quote", @@ -1613,7 +1613,7 @@ dependencies = [ [[package]] name = "bevy_tasks" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "async-channel", "async-executor", @@ -1631,7 +1631,7 @@ dependencies = [ [[package]] name = "bevy_text" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1658,7 +1658,7 @@ dependencies = [ [[package]] name = "bevy_time" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -1672,7 +1672,7 @@ dependencies = [ [[package]] name = "bevy_transform" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_ecs", @@ -1689,7 +1689,7 @@ dependencies = [ [[package]] name = "bevy_ui" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "accesskit", "bevy_a11y", @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "bevy_ui_render" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1754,7 +1754,7 @@ dependencies = [ [[package]] name = "bevy_ui_widgets" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "accesskit", "bevy_a11y", @@ -1773,7 +1773,7 @@ dependencies = [ [[package]] name = "bevy_utils" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "async-channel", "bevy_platform", @@ -1784,7 +1784,7 @@ dependencies = [ [[package]] name = "bevy_window" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "bevy_app", "bevy_asset", @@ -1802,7 +1802,7 @@ dependencies = [ [[package]] name = "bevy_winit" version = "0.19.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#3fea954eaaf25947af172ff5ba6e14e5771f78ff" +source = "git+https://github.com/bevyengine/bevy?branch=main#1b3b01e94003cbcf652f842057ebab547b400b0e" dependencies = [ "accesskit", "accesskit_winit", @@ -2204,9 +2204,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "combine" @@ -6474,9 +6474,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ "matchers", "nu-ansi-term", diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index 296e6b3..f0047e7 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -4,6 +4,7 @@ mod graphics; pub mod image; pub mod light; pub mod material; +pub mod midi; pub mod render; pub mod sketch; pub(crate) mod surface; @@ -1262,3 +1263,29 @@ pub fn gltf_light(gltf_entity: Entity, index: usize) -> error::Result { .unwrap() }) } + +#[cfg(not(target_arch = "wasm32"))] +pub fn midi_refresh_ports() -> error::Result<()> { + app_mut(|app| { + let world = app.world_mut(); + world.run_system_cached(midi::refresh_ports).unwrap() + }) +} + +#[cfg(not(target_arch = "wasm32"))] +pub fn midi_connect(port: usize) -> error::Result<()> { + app_mut(|app| { + let world = app.world_mut(); + world.run_system_cached_with(midi::connect, port).unwrap() + }) +} + +#[cfg(not(target_arch = "wasm32"))] +pub fn midi_play_notes(note: u8) -> error::Result<()> { + app_mut(|app| { + let world = app.world_mut(); + world + .run_system_cached_with(midi::play_notes, note) + .unwrap() + }) +} diff --git a/crates/processing_render/src/midi.rs b/crates/processing_render/src/midi.rs new file mode 100644 index 0000000..0651a86 --- /dev/null +++ b/crates/processing_render/src/midi.rs @@ -0,0 +1,42 @@ +use crate::error::Result; +use bevy::prelude::*; + +use bevy_midi::prelude::*; + +pub struct MidiPlugin; + +impl Plugin for MidiPlugin { + fn build(&self, app: &mut App) { + // TODO: Update `bevy_midi` to treat connections as entities + // in order to support hot-plugging + app.insert_resource(MidiOutputSettings { + port_name: "output", + }); + + app.add_plugins(MidiOutputPlugin); + } +} + +pub fn connect(In(port): In, output: Res) -> Result<()> { + if let Some((_, port)) = output.ports().get(port) { + output.connect(port.clone()); + } + Ok(()) +} + +pub fn disconnect() -> Result<()> { + Ok(()) +} + +pub fn refresh_ports(output: Res) -> Result<()> { + output.refresh_ports(); + Ok(()) +} + +pub fn play_notes(In(note): In, output: Res) -> Result<()> { + output.send([0b1001_0000, note, 127].into()); // Note on, channel 1, max velocity + + // output.send([0b1000_0000, note, 127].into()); // Note on, channel 1, max velocity + + Ok(()) +} diff --git a/examples/midi.rs b/examples/midi.rs index 38d44f2..3abd9f6 100644 --- a/examples/midi.rs +++ b/examples/midi.rs @@ -26,7 +26,9 @@ fn sketch() -> error::Result<()> { let surface = glfw_ctx.create_surface(width, height)?; let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?; - processing_midi::connect(0); + midi_refresh_ports()?; + midi_connect(0)?; + midi_play_notes(60)?; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; @@ -43,6 +45,8 @@ fn sketch() -> error::Result<()> { )?; graphics_end_draw(graphics)?; + + midi_play_notes(60)?; } Ok(()) } From c9e6e98cdca8db613ae703ab62727dfd9229d464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 28 Feb 2026 00:41:16 -0500 Subject: [PATCH 2/9] midi example is sufficient --- Cargo.lock | 27 +++++++++++++++++++++++++-- Cargo.toml | 1 + crates/processing_render/src/lib.rs | 4 ++-- crates/processing_render/src/midi.rs | 6 ++++-- examples/midi.rs | 10 ++++++++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 398f1d3..7e9130a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1930,7 +1930,7 @@ dependencies = [ "cc", "cfg-if 1.0.4", "constant_time_eq", - "cpufeatures", + "cpufeatures 0.2.17", ] [[package]] @@ -2119,6 +2119,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +dependencies = [ + "cfg-if 1.0.4", + "cpufeatures 0.3.0", + "rand_core 0.10.0", +] + [[package]] name = "clang-sys" version = "1.8.1" @@ -2488,6 +2499,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.5.0" @@ -3142,6 +3162,7 @@ dependencies = [ "cfg-if 1.0.4", "libc", "r-efi 6.0.0", + "rand_core 0.10.0", "wasip2", "wasip3", ] @@ -3661,7 +3682,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" dependencies = [ - "cpufeatures", + "cpufeatures 0.2.17", ] [[package]] @@ -5312,6 +5333,7 @@ dependencies = [ "processing_midi", "processing_render", "processing_webcam", + "rand 0.10.0", "tracing", "tracing-subscriber", "wasm-bindgen-futures", @@ -5555,6 +5577,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" dependencies = [ + "chacha20", "getrandom 0.4.2", "rand_core 0.10.0", ] diff --git a/Cargo.toml b/Cargo.toml index 5596ae9..8453856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ web-sys = { version = "0.3", features = ["Window"] } [dev-dependencies] glfw = "0.60.0" +rand = "0.10.0" [target.'cfg(target_os = "linux")'.dev-dependencies] glfw = { version = "0.60.0", features = ["wayland"] } diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index f0047e7..dbf80f6 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -1281,11 +1281,11 @@ pub fn midi_connect(port: usize) -> error::Result<()> { } #[cfg(not(target_arch = "wasm32"))] -pub fn midi_play_notes(note: u8) -> error::Result<()> { +pub fn midi_play_notes(note: u8, duration: u64) -> error::Result<()> { app_mut(|app| { let world = app.world_mut(); world - .run_system_cached_with(midi::play_notes, note) + .run_system_cached_with(midi::play_notes, (note, duration)) .unwrap() }) } diff --git a/crates/processing_render/src/midi.rs b/crates/processing_render/src/midi.rs index 0651a86..485f4d7 100644 --- a/crates/processing_render/src/midi.rs +++ b/crates/processing_render/src/midi.rs @@ -33,10 +33,12 @@ pub fn refresh_ports(output: Res) -> Result<()> { Ok(()) } -pub fn play_notes(In(note): In, output: Res) -> Result<()> { +pub fn play_notes(In((note, duration)): In<(u8, u64)>, output: Res) -> Result<()> { output.send([0b1001_0000, note, 127].into()); // Note on, channel 1, max velocity - // output.send([0b1000_0000, note, 127].into()); // Note on, channel 1, max velocity + std::thread::sleep(std::time::Duration::from_millis(duration)); + + output.send([0b1000_0000, note, 127].into()); // Note on, channel 1, max velocity Ok(()) } diff --git a/examples/midi.rs b/examples/midi.rs index 3abd9f6..88e75d3 100644 --- a/examples/midi.rs +++ b/examples/midi.rs @@ -4,6 +4,8 @@ use glfw::GlfwContext; use processing::prelude::*; use processing_render::render::command::DrawCommand; +use rand::prelude::*; + fn main() { match sketch() { Ok(_) => { @@ -28,7 +30,8 @@ fn sketch() -> error::Result<()> { midi_refresh_ports()?; midi_connect(0)?; - midi_play_notes(60)?; + + let mut rng = rand::rng(); while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; @@ -46,7 +49,10 @@ fn sketch() -> error::Result<()> { graphics_end_draw(graphics)?; - midi_play_notes(60)?; + let note = rng.random_range(57..68); + let note_duration = rng.random_range(25..250); + midi_play_notes(note, note_duration)?; } + Ok(()) } From 62a678d9902b53fe44ac22b80c11c9f1d26c9aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 28 Feb 2026 15:30:58 -0500 Subject: [PATCH 3/9] Implement disconnect --- crates/processing_render/src/midi.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/processing_render/src/midi.rs b/crates/processing_render/src/midi.rs index 485f4d7..4491cee 100644 --- a/crates/processing_render/src/midi.rs +++ b/crates/processing_render/src/midi.rs @@ -24,7 +24,8 @@ pub fn connect(In(port): In, output: Res) -> Result<()> { Ok(()) } -pub fn disconnect() -> Result<()> { +pub fn disconnect(output: Res) -> Result<()> { + output.disconnect(); Ok(()) } From a8795822332ceb1f361a613c8933f5d0913e8cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Fri, 6 Mar 2026 10:00:41 -0500 Subject: [PATCH 4/9] midi python example --- crates/processing_pyo3/examples/midi.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 crates/processing_pyo3/examples/midi.py diff --git a/crates/processing_pyo3/examples/midi.py b/crates/processing_pyo3/examples/midi.py new file mode 100644 index 0000000..6e574be --- /dev/null +++ b/crates/processing_pyo3/examples/midi.py @@ -0,0 +1,26 @@ +from processing import * +import random + +def setup(): + size(800, 600) + + # Refresh midi port list, and connect to first one + midi_refresh_ports() + midi_connect(0) + +def draw(): + background(220) + + fill(255, 0, 100) + stroke(1) + stroke_weight(2) + rect(100, 100, 200, 150) + + # pick a random note value, and duration value for that note + # then send the midi command + note = random.randit(57,68) + note_duration = random.randit(25, 250) + midi_play_notes(note, note_duration) + +# TODO: this should happen implicitly on module load somehow +run() From 48783f9682162492b5f9472276a6f3bb7de046de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Fri, 6 Mar 2026 11:15:49 -0500 Subject: [PATCH 5/9] python methods --- crates/processing_pyo3/examples/midi.py | 4 ++-- crates/processing_pyo3/src/lib.rs | 27 +++++++++++++++++++++++++ crates/processing_pyo3/src/midi.rs | 15 ++++++++++++++ crates/processing_render/src/lib.rs | 8 ++++++++ crates/processing_render/src/midi.rs | 2 +- 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 crates/processing_pyo3/src/midi.rs diff --git a/crates/processing_pyo3/examples/midi.py b/crates/processing_pyo3/examples/midi.py index 6e574be..1af87d1 100644 --- a/crates/processing_pyo3/examples/midi.py +++ b/crates/processing_pyo3/examples/midi.py @@ -18,8 +18,8 @@ def draw(): # pick a random note value, and duration value for that note # then send the midi command - note = random.randit(57,68) - note_duration = random.randit(25, 250) + note = random.randint(57,68) + note_duration = random.randint(25, 250) midi_play_notes(note, note_duration) # TODO: this should happen implicitly on module load somehow diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 1bf1b0a..7234853 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -12,12 +12,14 @@ mod glfw; mod gltf; mod graphics; pub(crate) mod material; +mod midi; pub(crate) mod shader; #[cfg(feature = "webcam")] mod webcam; use graphics::{Geometry, Graphics, Image, Light, Topology, get_graphics, get_graphics_mut}; use material::Material; + use pyo3::{ exceptions::PyRuntimeError, prelude::*, @@ -94,6 +96,10 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(metallic, m)?)?; m.add_function(wrap_pyfunction!(emissive, m)?)?; m.add_function(wrap_pyfunction!(unlit, m)?)?; + m.add_function(wrap_pyfunction!(midi_connect, m)?)?; + m.add_function(wrap_pyfunction!(midi_disconnect, m)?)?; + m.add_function(wrap_pyfunction!(midi_refresh_ports, m)?)?; + m.add_function(wrap_pyfunction!(midi_play_notes, m)?)?; #[cfg(feature = "webcam")] { @@ -589,3 +595,24 @@ fn create_webcam( ) -> PyResult { webcam::Webcam::new(width, height, framerate) } + +#[pyfunction] +#[pyo3(pass_module)] +fn midi_connect(module: &Bound<'_, PyModule>, port: usize) -> PyResult<()> { + midi::connect(port) +} +#[pyfunction] +#[pyo3(pass_module)] +fn midi_disconnect(module: &Bound<'_, PyModule>) -> PyResult<()> { + midi::disconnect() +} +#[pyfunction] +#[pyo3(pass_module)] +fn midi_refresh_ports(module: &Bound<'_, PyModule>) -> PyResult<()> { + midi::refresh_ports() +} +#[pyfunction] +#[pyo3(pass_module)] +fn midi_play_notes(module: &Bound<'_, PyModule>, note: u8, duration: u64) -> PyResult<()> { + midi::play_notes(note, duration) +} diff --git a/crates/processing_pyo3/src/midi.rs b/crates/processing_pyo3/src/midi.rs new file mode 100644 index 0000000..2f88b50 --- /dev/null +++ b/crates/processing_pyo3/src/midi.rs @@ -0,0 +1,15 @@ +use processing::prelude::*; +use pyo3::{exceptions::PyRuntimeError, prelude::*}; + +pub fn connect(port: usize) -> PyResult<()> { + midi_connect(port).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) +} +pub fn disconnect() -> PyResult<()> { + midi_disconnect().map_err(|e| PyRuntimeError::new_err(format!("{e}"))) +} +pub fn refresh_ports() -> PyResult<()> { + midi_refresh_ports().map_err(|e| PyRuntimeError::new_err(format!("{e}"))) +} +pub fn play_notes(note: u8, duration: u64) -> PyResult<()> { + midi_play_notes(note, duration).map_err(|e| PyRuntimeError::new_err(format!("{e}"))) +} diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index dbf80f6..ef1f101 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -1280,6 +1280,14 @@ pub fn midi_connect(port: usize) -> error::Result<()> { }) } +#[cfg(not(target_arch = "wasm32"))] +pub fn midi_disconnect() -> error::Result<()> { + app_mut(|app| { + let world = app.world_mut(); + world.run_system_cached(midi::disconnect).unwrap() + }) +} + #[cfg(not(target_arch = "wasm32"))] pub fn midi_play_notes(note: u8, duration: u64) -> error::Result<()> { app_mut(|app| { diff --git a/crates/processing_render/src/midi.rs b/crates/processing_render/src/midi.rs index 4491cee..ce66df4 100644 --- a/crates/processing_render/src/midi.rs +++ b/crates/processing_render/src/midi.rs @@ -10,7 +10,7 @@ impl Plugin for MidiPlugin { // TODO: Update `bevy_midi` to treat connections as entities // in order to support hot-plugging app.insert_resource(MidiOutputSettings { - port_name: "output", + port_name: "libprocessing output", }); app.add_plugins(MidiOutputPlugin); From 6761aeaaadfdbeeb01d8a409350fb23b0ba35479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 14 Mar 2026 14:58:52 -0400 Subject: [PATCH 6/9] Reorganized code after rebase --- Cargo.lock | 2 ++ crates/processing_midi/Cargo.toml | 2 +- crates/processing_midi/src/lib.rs | 40 +++++++++++++++++++------ crates/processing_render/Cargo.toml | 1 + crates/processing_render/src/lib.rs | 15 ++++++---- crates/processing_render/src/midi.rs | 45 ---------------------------- 6 files changed, 45 insertions(+), 60 deletions(-) delete mode 100644 crates/processing_render/src/midi.rs diff --git a/Cargo.lock b/Cargo.lock index 7e9130a..d84f1ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5365,6 +5365,7 @@ version = "0.1.0" dependencies = [ "bevy", "bevy_midi", + "processing_core", ] [[package]] @@ -5393,6 +5394,7 @@ dependencies = [ "objc2 0.6.4", "objc2-app-kit 0.3.2", "processing_core", + "processing_midi", "raw-window-handle", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/crates/processing_midi/Cargo.toml b/crates/processing_midi/Cargo.toml index 7c087a5..9d85d6b 100644 --- a/crates/processing_midi/Cargo.toml +++ b/crates/processing_midi/Cargo.toml @@ -5,8 +5,8 @@ edition = "2024" [dependencies] bevy = { workspace = true } +processing_core = { workspace = true } bevy_midi = { git = "https://github.com/BlackPhlox/bevy_midi", branch = "latest" } - [lints] workspace = true diff --git a/crates/processing_midi/src/lib.rs b/crates/processing_midi/src/lib.rs index 505f235..185ece9 100644 --- a/crates/processing_midi/src/lib.rs +++ b/crates/processing_midi/src/lib.rs @@ -1,23 +1,45 @@ use bevy::prelude::*; use bevy_midi::prelude::*; +use processing_core::error::Result; + pub struct MidiPlugin; impl Plugin for MidiPlugin { fn build(&self, app: &mut App) { + // TODO: Update `bevy_midi` to treat connections as entities + // in order to support hot-plugging app.insert_resource(MidiOutputSettings { - port_name: "output", - }) - .add_plugins(MidiOutputPlugin); + port_name: "libprocessing output", + }); + + app.add_plugins(MidiOutputPlugin); + } +} + +pub fn connect(In(port): In, output: Res) -> Result<()> { + if let Some((_, port)) = output.ports().get(port) { + output.connect(port.clone()); } + Ok(()) } -pub fn connect(_port: usize) { - // we need to work with the ECS - // do we pass a MidiCommand to Bevy? +pub fn disconnect(output: Res) -> Result<()> { + output.disconnect(); + Ok(()) } -pub fn disconnect() {} -pub fn refresh_ports() {} +pub fn refresh_ports(output: Res) -> Result<()> { + output.refresh_ports(); + Ok(()) +} + +pub fn play_notes(In((note, duration)): In<(u8, u64)>, output: Res) -> Result<()> { + output.send([0b1001_0000, note, 127].into()); // Note on, channel 1, max velocity + + std::thread::sleep(std::time::Duration::from_millis(duration)); -pub fn play_notes() {} + output.send([0b1000_0000, note, 127].into()); // Note on, channel 1, max velocity + + Ok(()) +} diff --git a/crates/processing_render/Cargo.toml b/crates/processing_render/Cargo.toml index 9f10c24..e7a3abd 100644 --- a/crates/processing_render/Cargo.toml +++ b/crates/processing_render/Cargo.toml @@ -21,6 +21,7 @@ raw-window-handle = "0.6" half = "2.7" crossbeam-channel = "0.5" processing_core = { workspace = true } +processing_midi = { workspace = true } [build-dependencies] wesl = { workspace = true, features = ["package"] } diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index ef1f101..ea35f6c 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -4,7 +4,6 @@ mod graphics; pub mod image; pub mod light; pub mod material; -pub mod midi; pub mod render; pub mod sketch; pub(crate) mod surface; @@ -1268,7 +1267,9 @@ pub fn gltf_light(gltf_entity: Entity, index: usize) -> error::Result { pub fn midi_refresh_ports() -> error::Result<()> { app_mut(|app| { let world = app.world_mut(); - world.run_system_cached(midi::refresh_ports).unwrap() + world + .run_system_cached(processing_midi::refresh_ports) + .unwrap() }) } @@ -1276,7 +1277,9 @@ pub fn midi_refresh_ports() -> error::Result<()> { pub fn midi_connect(port: usize) -> error::Result<()> { app_mut(|app| { let world = app.world_mut(); - world.run_system_cached_with(midi::connect, port).unwrap() + world + .run_system_cached_with(processing_midi::connect, port) + .unwrap() }) } @@ -1284,7 +1287,9 @@ pub fn midi_connect(port: usize) -> error::Result<()> { pub fn midi_disconnect() -> error::Result<()> { app_mut(|app| { let world = app.world_mut(); - world.run_system_cached(midi::disconnect).unwrap() + world + .run_system_cached(processing_midi::disconnect) + .unwrap() }) } @@ -1293,7 +1298,7 @@ pub fn midi_play_notes(note: u8, duration: u64) -> error::Result<()> { app_mut(|app| { let world = app.world_mut(); world - .run_system_cached_with(midi::play_notes, (note, duration)) + .run_system_cached_with(processing_midi::play_notes, (note, duration)) .unwrap() }) } diff --git a/crates/processing_render/src/midi.rs b/crates/processing_render/src/midi.rs deleted file mode 100644 index ce66df4..0000000 --- a/crates/processing_render/src/midi.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::error::Result; -use bevy::prelude::*; - -use bevy_midi::prelude::*; - -pub struct MidiPlugin; - -impl Plugin for MidiPlugin { - fn build(&self, app: &mut App) { - // TODO: Update `bevy_midi` to treat connections as entities - // in order to support hot-plugging - app.insert_resource(MidiOutputSettings { - port_name: "libprocessing output", - }); - - app.add_plugins(MidiOutputPlugin); - } -} - -pub fn connect(In(port): In, output: Res) -> Result<()> { - if let Some((_, port)) = output.ports().get(port) { - output.connect(port.clone()); - } - Ok(()) -} - -pub fn disconnect(output: Res) -> Result<()> { - output.disconnect(); - Ok(()) -} - -pub fn refresh_ports(output: Res) -> Result<()> { - output.refresh_ports(); - Ok(()) -} - -pub fn play_notes(In((note, duration)): In<(u8, u64)>, output: Res) -> Result<()> { - output.send([0b1001_0000, note, 127].into()); // Note on, channel 1, max velocity - - std::thread::sleep(std::time::Duration::from_millis(duration)); - - output.send([0b1000_0000, note, 127].into()); // Note on, channel 1, max velocity - - Ok(()) -} From cb2b77c92e6e509305ffc0a599f6d4377994fd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 14 Mar 2026 18:02:41 -0400 Subject: [PATCH 7/9] no need to pass modules for python midi functions --- crates/processing_pyo3/src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/processing_pyo3/src/lib.rs b/crates/processing_pyo3/src/lib.rs index 7234853..e4c1292 100644 --- a/crates/processing_pyo3/src/lib.rs +++ b/crates/processing_pyo3/src/lib.rs @@ -597,22 +597,18 @@ fn create_webcam( } #[pyfunction] -#[pyo3(pass_module)] -fn midi_connect(module: &Bound<'_, PyModule>, port: usize) -> PyResult<()> { +fn midi_connect(port: usize) -> PyResult<()> { midi::connect(port) } #[pyfunction] -#[pyo3(pass_module)] -fn midi_disconnect(module: &Bound<'_, PyModule>) -> PyResult<()> { +fn midi_disconnect() -> PyResult<()> { midi::disconnect() } #[pyfunction] -#[pyo3(pass_module)] -fn midi_refresh_ports(module: &Bound<'_, PyModule>) -> PyResult<()> { +fn midi_refresh_ports() -> PyResult<()> { midi::refresh_ports() } #[pyfunction] -#[pyo3(pass_module)] -fn midi_play_notes(module: &Bound<'_, PyModule>, note: u8, duration: u64) -> PyResult<()> { +fn midi_play_notes(note: u8, duration: u64) -> PyResult<()> { midi::play_notes(note, duration) } From adf8ae6b607642aafec247b6abe5b71d25604e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 14 Mar 2026 18:18:24 -0400 Subject: [PATCH 8/9] clippy --- crates/processing_render/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index ea35f6c..7d62393 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -46,14 +46,13 @@ impl Plugin for ProcessingRenderPlugin { let has_sketch_file = config .get(ConfigKey::SketchFileName) .is_some_and(|f| !f.is_empty()); - if has_sketch_file { - if let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) { + if has_sketch_file + && let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) { app.register_asset_source( "sketch_directory", AssetSourceBuilder::platform_default(sketch_path, None), ); } - } if has_sketch_file { app.add_plugins(sketch::LivecodePlugin); From f0e671e0a3ea9ebd50a9e221b6ecc5e50aa3557d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moon=20Dav=C3=A9?= Date: Sat, 14 Mar 2026 18:20:40 -0400 Subject: [PATCH 9/9] fmt --- crates/processing_render/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index 7d62393..0c44d0b 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -46,13 +46,12 @@ impl Plugin for ProcessingRenderPlugin { let has_sketch_file = config .get(ConfigKey::SketchFileName) .is_some_and(|f| !f.is_empty()); - if has_sketch_file - && let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) { - app.register_asset_source( - "sketch_directory", - AssetSourceBuilder::platform_default(sketch_path, None), - ); - } + if has_sketch_file && let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) { + app.register_asset_source( + "sketch_directory", + AssetSourceBuilder::platform_default(sketch_path, None), + ); + } if has_sketch_file { app.add_plugins(sketch::LivecodePlugin);