Skip to content

Commit

Permalink
fixes #174, update with bevy v0.12, not using bevy_kira_audio, use de…
Browse files Browse the repository at this point in the history
…codable for streaming
  • Loading branch information
yjpark committed Jan 6, 2024
1 parent 71dc9d1 commit f73736e
Show file tree
Hide file tree
Showing 40 changed files with 892 additions and 668 deletions.
1,004 changes: 522 additions & 482 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ opt-level = 's'
opt-level = 1

[patch.crates-io]
# bevy_kira_audio = { git = "https://github.com/yjpark/bevy_kira_audio", branch = "stream-kira-0.5" }

[workspace.dependencies]
notation_core = { path = "model/notation_core", version = "0.6.0" }
Expand All @@ -48,8 +47,8 @@ notation_tab = { path = "dsl/notation_tab", version = "0.6.0" }
notation_audio = { path = "bevy/notation_audio", version = "0.6.0" }
notation_midi = { path = "bevy/notation_midi", version = "0.6.0" }

# edger_bevy_app = { path = "../../edger-dev/crates/bevy/app" }
edger_bevy_app = { git = "https://github.com/edger-dev/crates", branch = "main" }
edger_bevy_app = { path = "../../edger-dev/crates/bevy/app" }
# edger_bevy_app = { git = "https://github.com/edger-dev/crates", branch = "main" }

fehler = "1.0"
serde = { version = "1.0", features = ["derive", "alloc"] }
Expand All @@ -68,14 +67,13 @@ rfd = "0.11"
unic-langid = { version = "0.9", features = [ "macros" ] }
clap = { version = "4.0", features = [ "derive" ] }

bevy = { version = "0.11", default-features = false }
bevy_prototype_lyon = "0.9"
bevy_easings = "0.11"
bevy_asset_loader = { version = "0.17", features = [ "standard_dynamic_assets" ]}
bevy = { version = "0.12.1", default-features = false }
bevy_prototype_lyon = "0.10.0"
bevy_easings = "0.12.2"
bevy_asset_loader = { version = "0.19.1", features = [ "standard_dynamic_assets" ]}

bevy_egui = { version = "0.21" }

bevy_kira_audio = { version = "0.11", git = "https://github.com/yjpark/bevy_kira_audio", branch = "stream-kira-0.5_bevy-0.11" }
bevy_egui = { version = "0.24.0" }
egui_plot = { version = "0.24.0" }

# [target.'cfg(target_arch = "wasm32")'.workspace.dependencies]
wasm-bindgen = "0.2.87"
Expand Down
1 change: 1 addition & 0 deletions apps/notation_kb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ notation_viewer = { path = "../notation_viewer" }

bevy = { workspace = true }
bevy_asset_loader = { workspace = true }
egui_plot = { workspace = true }

10 changes: 5 additions & 5 deletions apps/notation_kb/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ impl NotationKnowledgeBaseAssets {
}

impl ExtraAssets for NotationKnowledgeBaseAssets {
fn get_assets(&self) -> Vec<HandleUntyped> {
fn get_assets(&self) -> Vec<UntypedHandle> {
vec![
self.kb_welcome.clone_untyped(),
self.kb_sound.clone_untyped(),
self.kb_scale.clone_untyped(),
self.kb_guitar.clone_untyped(),
self.kb_welcome.clone().untyped(),
self.kb_sound.clone().untyped(),
self.kb_scale.clone().untyped(),
self.kb_guitar.clone().untyped(),
]
}
fn setup_extra_keys(settings: &NotationSettings, asset_keys: &mut DynamicAssets) {
Expand Down
24 changes: 21 additions & 3 deletions apps/notation_kb/src/index_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ impl KbPanel for IndexPanel {
fn get_title(&self) -> &str {
"Index (F1, H)"
}

fn get_current_page_id(&self) -> KbPageId {
self.current_page_id.clone()
}

fn set_current_page_id(&mut self, page_id: KbPageId) {
self.current_page_id = page_id;
}

fn get_page_tabs(&self) -> Vec<(KbPageId, &'static str)> {
vec![
(Self::WELCOME, "Welcome"),
Expand All @@ -83,6 +86,7 @@ impl KbPanel for IndexPanel {
(Self::GUITAR, "Guitar"),
]
}

fn get_page_mut(&mut self, page_id: KbPageId) -> &mut dyn KbPage {
match page_id {
Self::SOUND => &mut self.sound as &mut dyn KbPage,
Expand Down Expand Up @@ -111,6 +115,7 @@ impl IndexPanel {
}
}
}

pub fn hack_settings(
state: Res<NotationState>,
mut theme: ResMut<NotationTheme>,
Expand Down Expand Up @@ -144,6 +149,7 @@ impl IndexPanel {
}
}
}

pub fn index_ui(
mut egui_ctx: EguiContexts,
texts: Res<Assets<MarkDownAsset>>,
Expand All @@ -166,6 +172,7 @@ impl IndexPanel {
}
(&mut index).content_ui(&mut egui_ctx, &texts, &assets, &state, &theme, &mut link_evts);
}

fn content_ui(
&mut self,
egui_ctx: &mut EguiContexts,
Expand All @@ -190,16 +197,18 @@ impl IndexPanel {
});
}
}

pub fn handle_link_evts(
mut midi_state: ResMut<MidiState>,
mut play_control_evts: EventWriter<PlayControlEvent>,
mut index: ResMut<IndexPanel>,
mut evts: EventReader<EasyLinkEvent>,
) {
for evt in evts.iter() {
for evt in evts.read() {
(&mut index).handle_link_evt(&mut midi_state, &mut play_control_evts, evt);
}
}

fn handle_link_evt(
&mut self,
midi_state: &mut MidiState,
Expand Down Expand Up @@ -227,6 +236,7 @@ impl IndexPanel {
_ => (),
}
}

fn _index_audio(
&mut self,
stream: &mut StereoStream,
Expand All @@ -238,12 +248,19 @@ impl IndexPanel {
_ => {},
}
}

pub fn index_audio(
mut index: ResMut<IndexPanel>,
mut stream: ResMut<StereoStream>,
stream_handle_query: Query<&Handle<StereoStream>>,
mut assets: ResMut<Assets<StereoStream>>,
) {
(&mut index)._index_audio(&mut stream);
for stream_handle in stream_handle_query.iter() {
if let Some(stream) = assets.get_mut(stream_handle) {
(&mut index)._index_audio(stream);
}
}
}

pub fn make_tab(&self, _tab_path: String) -> ProtoTab {
match self.current_page_id {
Self::SCALE => {
Expand All @@ -252,6 +269,7 @@ impl IndexPanel {
_ => Self::make_default_tab(),
}
}

pub fn make_default_tab() -> ProtoTab {
ProtoTab::new_empty()
}
Expand Down
4 changes: 2 additions & 2 deletions apps/notation_kb/src/kb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl NotationKnowledgeBase {
index: Res<IndexPanel>,
) {
settings.add_ready_section = false;
NotationApp::load_tab(&mut commands, &time, &mut window_query, &mut state, &mut theme, &settings, &mut evts, &entities, &viewer_query, |tab_path| {
NotationApp::load_tab(&mut commands, &time, &mut window_query, &mut state, &mut theme, &settings, &mut evts, &entities, &viewer_query, |_commands: &mut Commands, tab_path| {
Some(TabAsset::from(index.make_tab(tab_path)))
})
}
Expand All @@ -60,7 +60,7 @@ impl NotationKnowledgeBase {
mut window_resized_evts: EventReader<WindowResizedEvent>,
) {
let mut need_reload = false;
for evt in window_resized_evts.iter() {
for evt in window_resized_evts.read() {
if state.window_width > state.window_height {
if evt.last_width <= evt.last_height {
need_reload = true;
Expand Down
4 changes: 2 additions & 2 deletions apps/notation_kb/src/theory/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::f64::consts::{PI, FRAC_PI_2};

use tab_viewer::edger_bevy_app::bevy_prelude::*;
use tab_viewer::edger_bevy_app::egui::{self, *};
use tab_viewer::edger_bevy_app::egui::plot::*;
use egui_plot::*;
use tab_viewer::prelude::{AudioConsts, StereoStream};

use tab_viewer::kb::markdown_page::MarkDownPage;
Expand Down Expand Up @@ -315,7 +315,7 @@ impl SoundPage {
let step = AudioConsts::FRAME_STEP;
let mut t = 0.0;
loop {
if stream.buffer.remaining() < 2 {
if stream.remaining() < 2 {
break;
}
let mut total = 0.0;
Expand Down
6 changes: 3 additions & 3 deletions apps/notation_viewer/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ impl NotationViewerAssets {
}

impl ExtraAssets for NotationViewerAssets {
fn get_assets(&self) -> Vec<HandleUntyped> {
fn get_assets(&self) -> Vec<UntypedHandle> {
vec![
self.kb_welcome.clone_untyped(),
self.kb_usage.clone_untyped(),
self.kb_welcome.clone().untyped(),
self.kb_usage.clone().untyped(),
]
}
fn setup_extra_keys(settings: &NotationSettings, asset_keys: &mut DynamicAssets) {
Expand Down
2 changes: 1 addition & 1 deletion apps/notation_viewer/src/help_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl HelpPanel {
mut index: ResMut<HelpPanel>,
mut evts: EventReader<EasyLinkEvent>,
) {
for evt in evts.iter() {
for evt in evts.read() {
(&mut index).handle_link_evt(evt);
}
}
Expand Down
8 changes: 4 additions & 4 deletions apps/notation_viewer/src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl NotationViewer {
asset_server: Res<AssetServer>,
assets: Res<Assets<TabAsset>>,
) {
NotationApp::load_tab(&mut commands, &time, &mut window_query, &mut state, &mut theme, &settings, &mut evts, &entities, &viewer_query, |tab_path| {
NotationApp::load_tab_from_assets(&asset_server, &assets, tab_path)
NotationApp::load_tab(&mut commands, &time, &mut window_query, &mut state, &mut theme, &settings, &mut evts, &entities, &viewer_query, |commands: &mut Commands, tab_path| {
NotationApp::load_tab_from_assets(commands, &asset_server, &assets, tab_path)
})
}
pub fn handle_keyboard_inputs(
Expand Down Expand Up @@ -182,15 +182,15 @@ impl NotationViewer {
} else if mouse_input.just_pressed(MouseButton::Right) {
} else if mouse_input.just_released(MouseButton::Right) {
} else if mouse_input.pressed(MouseButton::Right) {
for event in mouse_motion_events.iter() {
for event in mouse_motion_events.read() {
//println!("handle_inputs() -> MouseDraggedEvent({:?})", event.delta);
mouse_dragged.send(MouseDraggedEvent {
cursor_position,
delta: event.delta,
});
}
} else {
for event in mouse_wheel_input.iter() {
for event in mouse_wheel_input.read() {
let mut delta = match event.unit {
MouseScrollUnit::Line => Vec2::new(
event.x * settings.panning_line_size,
Expand Down
8 changes: 6 additions & 2 deletions bevy/notation_audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ repository = { workspace = true }
[lib]

[features]
default = [
"bevy/bevy_audio",
"bevy/bevy_asset",
]

[dependencies]
bevy = { workspace = true }
bevy_kira_audio = { workspace = true }

ringbuf = "0.2.8"
ringbuffer = "0.15.0"
ringbuf = "0.4.0-rc.2"
Loading

0 comments on commit f73736e

Please sign in to comment.