From c814fbe4cb5a42ccbb76f3d5fda359d21a5e723f Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Mon, 20 Dec 2021 11:23:36 -0700 Subject: [PATCH] change sounds away from mario, replace their use sites (#974) --- appmgr/src/bin/embassy-init.rs | 4 +- appmgr/src/bin/embassyd.rs | 2 +- appmgr/src/shutdown.rs | 4 +- appmgr/src/sound.rs | 89 +++++++++++++++++++++------------- appmgr/src/update/mod.rs | 23 ++++++++- 5 files changed, 82 insertions(+), 40 deletions(-) diff --git a/appmgr/src/bin/embassy-init.rs b/appmgr/src/bin/embassy-init.rs index 096c5f39f..0a2fc7c75 100644 --- a/appmgr/src/bin/embassy-init.rs +++ b/appmgr/src/bin/embassy-init.rs @@ -10,7 +10,7 @@ use embassy::middleware::encrypt::encrypt; #[cfg(feature = "avahi")] use embassy::net::mdns::MdnsController; use embassy::shutdown::Shutdown; -use embassy::sound::MARIO_COIN; +use embassy::sound::CHIME; use embassy::util::logger::EmbassyLogger; use embassy::util::Invoke; use embassy::{Error, ResultExt}; @@ -51,7 +51,7 @@ async fn setup_or_init(cfg_path: Option<&str>) -> Result<(), Error> { async move { ctx.product_key().await } }; let encrypt = encrypt(keysource); - MARIO_COIN.play().await?; + CHIME.play().await?; rpc_server!({ command: embassy::setup_api, context: ctx.clone(), diff --git a/appmgr/src/bin/embassyd.rs b/appmgr/src/bin/embassyd.rs index c6ceb0799..fee26359f 100644 --- a/appmgr/src/bin/embassyd.rs +++ b/appmgr/src/bin/embassyd.rs @@ -219,7 +219,7 @@ async fn inner_main(cfg_path: Option<&str>) -> Result, Error> { rpc_ctx.shutdown.subscribe(), ); - embassy::sound::MARIO_COIN.play().await?; + embassy::sound::CHARGE.play().await?; futures::try_join!( server diff --git a/appmgr/src/shutdown.rs b/appmgr/src/shutdown.rs index 3ac9ae29e..8d3529fc5 100644 --- a/appmgr/src/shutdown.rs +++ b/appmgr/src/shutdown.rs @@ -6,7 +6,7 @@ use rpc_toolkit::command; use crate::context::RpcContext; use crate::disk::main::export; -use crate::sound::MARIO_DEATH; +use crate::sound::SHUTDOWN; use crate::util::{display_none, Invoke}; use crate::Error; @@ -53,7 +53,7 @@ impl Shutdown { tracing::debug!("{:?}", e); } } - if let Err(e) = MARIO_DEATH.play().await { + if let Err(e) = SHUTDOWN.play().await { tracing::error!("Error Playing Shutdown Song: {}", e); tracing::debug!("{:?}", e); } diff --git a/appmgr/src/sound.rs b/appmgr/src/sound.rs index 4b3e73674..27eebde44 100644 --- a/appmgr/src/sound.rs +++ b/appmgr/src/sound.rs @@ -336,44 +336,65 @@ macro_rules! song { pub const BEP: Song<[(Option, TimeSlice); 1]> = song!(150, [note(A, 4, Sixteenth);]); -pub const MARIO_DEATH: Song<[(Option, TimeSlice); 12]> = song!(400, [ - note(B, 4, Quarter); - note(F, 5, Quarter); - rest(Quarter); - note(F, 5, Quarter); - note(F, 5, Triplet(&Half)); - note(E, 5, Triplet(&Half)); - note(D, 5, Triplet(&Half)); - note(C, 5, Quarter); - note(E, 4, Quarter); - rest(Quarter); - note(E, 4, Quarter); - note(C, 4, Half); -]); - -pub const MARIO_POWER_UP: Song<[(Option, TimeSlice); 15]> = song!(400, [ - note(G,4,Triplet(&Eighth)); - note(B,4,Triplet(&Eighth)); - note(D,5,Triplet(&Eighth)); - note(G,5,Triplet(&Eighth)); - note(B,5,Triplet(&Eighth)); - note(Ab,4,Triplet(&Eighth)); - note(C,5,Triplet(&Eighth)); - note(Eb,5,Triplet(&Eighth)); - note(Ab,5,Triplet(&Eighth)); - note(C,5,Triplet(&Eighth)); - note(Bb,4,Triplet(&Eighth)); - note(D,5,Triplet(&Eighth)); - note(F,5,Triplet(&Eighth)); - note(Bb,5,Triplet(&Eighth)); - note(D,6,Triplet(&Eighth)); -]); - -pub const MARIO_COIN: Song<[(Option, TimeSlice); 2]> = song!(400, [ +pub const CHIME: Song<[(Option, TimeSlice); 2]> = song!(400, [ note(B, 5, Eighth); note(E, 6, Tie(&Dot(&Quarter), &Half)); ]); +pub const CHARGE: Song<[(Option, TimeSlice); 7]> = song!(120, [ + note(G, 3, Triplet(&Eighth)); + note(C, 4, Triplet(&Eighth)); + note(E, 4, Triplet(&Eighth)); + note(G, 4, Triplet(&Eighth)); + rest(Triplet(&Eighth)); + note(E, 4, Triplet(&Eighth)); + note(G, 4, Whole); +]); + +pub const SHUTDOWN: Song<[(Option, TimeSlice); 12]> = song!(120, [ + note(C, 5, Eighth); + rest(Eighth); + note(G, 4, Triplet(&Eighth)); + note(Gb, 4, Triplet(&Eighth)); + note(G, 4, Triplet(&Eighth)); + note(Ab, 4, Quarter); + note(G, 4, Eighth); + rest(Eighth); + rest(Quarter); + note(B, 4, Eighth); + rest(Eighth); + note(C, 5, Eighth); +]); + +pub const UPDATE_FAILED_1: Song<[(Option, TimeSlice); 5]> = song!(120, [ + note(C, 4, Triplet(&Sixteenth)); + note(Eb, 4, Triplet(&Sixteenth)); + note(Gb, 4, Triplet(&Sixteenth)); + note(A, 4, Quarter); + rest(Eighth); +]); +pub const UPDATE_FAILED_2: Song<[(Option, TimeSlice); 5]> = song!(110, [ + note(B, 3, Triplet(&Sixteenth)); + note(D, 4, Triplet(&Sixteenth)); + note(F, 4, Triplet(&Sixteenth)); + note(Ab, 4, Quarter); + rest(Eighth); +]); +pub const UPDATE_FAILED_3: Song<[(Option, TimeSlice); 5]> = song!(100, [ + note(Bb, 3, Triplet(&Sixteenth)); + note(Db, 4, Triplet(&Sixteenth)); + note(E, 4, Triplet(&Sixteenth)); + note(G, 4, Quarter); + rest(Eighth); +]); +pub const UPDATE_FAILED_4: Song<[(Option, TimeSlice); 5]> = song!(90, [ + note(A, 3, Triplet(&Sixteenth)); + note(C, 4, Triplet(&Sixteenth)); + note(Eb, 4, Triplet(&Sixteenth)); + note(Gb, 4, Tie(&Dot(&Quarter), &Quarter)); + rest(Quarter); +]); + pub const BEETHOVEN: Song<[(Option, TimeSlice); 9]> = song!(216, [ note(G, 4, Eighth); note(G, 4, Eighth); diff --git a/appmgr/src/update/mod.rs b/appmgr/src/update/mod.rs index 4f3118a68..33dc0c4ec 100644 --- a/appmgr/src/update/mod.rs +++ b/appmgr/src/update/mod.rs @@ -30,6 +30,7 @@ use crate::disk::mount::filesystem::FileSystem; use crate::disk::mount::guard::TmpMountGuard; use crate::disk::BOOT_RW_PATH; use crate::notifications::NotificationLevel; +use crate::sound::{BEP, UPDATE_FAILED_1, UPDATE_FAILED_2, UPDATE_FAILED_3, UPDATE_FAILED_4}; use crate::update::latest_information::LatestInformation; use crate::util::Invoke; use crate::version::{Current, VersionT}; @@ -194,6 +195,9 @@ async fn maybe_do_update(ctx: RpcContext) -> Result>, Error Ok(()) => { info.status = ServerStatus::Updated; info.save(&mut db).await.expect("could not save status"); + BEP.play().await.expect("could not bep"); + BEP.play().await.expect("could not bep"); + BEP.play().await.expect("could not bep"); } Err(e) => { info.status = ServerStatus::Running; @@ -209,7 +213,24 @@ async fn maybe_do_update(ctx: RpcContext) -> Result>, Error None, ) .await - .expect("") + .expect(""); + // TODO: refactor sound lib to make compound tempos easier to deal with + UPDATE_FAILED_1 + .play() + .await + .expect("could not play song: update failed 1"); + UPDATE_FAILED_2 + .play() + .await + .expect("could not play song: update failed 2"); + UPDATE_FAILED_3 + .play() + .await + .expect("could not play song: update failed 3"); + UPDATE_FAILED_4 + .play() + .await + .expect("could not play song: update failed 4"); } } });