diff --git a/Cargo.lock b/Cargo.lock index 9895d626..a8b6b055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "fonts" -version = "0.1.1" +version = "0.1.2" dependencies = [ "embedded-graphics", ] @@ -1630,12 +1630,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hound" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1" - [[package]] name = "http" version = "0.2.8" @@ -2146,7 +2140,7 @@ dependencies = [ [[package]] name = "matrix-drawing" -version = "0.1.1" +version = "0.1.2" dependencies = [ "arrayref", "arrayvec 0.7.2", @@ -3037,7 +3031,7 @@ dependencies = [ [[package]] name = "refbox" -version = "0.1.1" +version = "0.1.2" dependencies = [ "array-concat", "arrayref", @@ -3059,7 +3053,6 @@ dependencies = [ "more-asserts", "paste", "reqwest", - "rodio", "rppal", "serde", "serde_derive", @@ -3138,16 +3131,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "rodio" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb10b653d5ec0e9411a2e7d46e2c7f4046fd87d35b9955bd73ba4108d69072b5" -dependencies = [ - "cpal", - "hound", -] - [[package]] name = "rppal" version = "0.14.0" @@ -3597,7 +3580,6 @@ checksum = "17033fe05e4f7f10a6ad602c272bafd2520b2e5cdd9feb61494d9cdce08e002f" dependencies = [ "lazy_static", "symphonia-bundle-flac", - "symphonia-bundle-mp3", "symphonia-codec-pcm", "symphonia-codec-vorbis", "symphonia-core", @@ -3619,19 +3601,6 @@ dependencies = [ "symphonia-utils-xiph", ] -[[package]] -name = "symphonia-bundle-mp3" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db5d3d53535ae2b7d0e39e82f683cac5398a6c8baca25ff1183e107d13959d3e" -dependencies = [ - "bitflags", - "lazy_static", - "log", - "symphonia-core", - "symphonia-metadata", -] - [[package]] name = "symphonia-codec-pcm" version = "0.5.1" @@ -4028,7 +3997,7 @@ dependencies = [ [[package]] name = "uwh-common" -version = "0.1.1" +version = "0.1.2" dependencies = [ "arrayref", "arrayvec 0.7.2", diff --git a/fonts/Cargo.toml b/fonts/Cargo.toml index a45265f4..be8fa78a 100644 --- a/fonts/Cargo.toml +++ b/fonts/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fonts" -version = "0.1.1" +version = "0.1.2" authors = ["Atlantis Sports "] edition = "2021" diff --git a/matrix-drawing/Cargo.toml b/matrix-drawing/Cargo.toml index 2bc758a3..dee29b2e 100644 --- a/matrix-drawing/Cargo.toml +++ b/matrix-drawing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "matrix-drawing" -version = "0.1.1" +version = "0.1.2" authors = ["Atlantis Sports "] edition = "2021" @@ -12,8 +12,8 @@ std = ["arrayvec/std", "serde/std", "uwh-common/std"] arrayref = "0.3.6" arrayvec = { version = "0.7.2", default-features = false } embedded-graphics = "0.7.1" -fonts = { version = "0.1.1", path = "../fonts" } +fonts = { version = "0.1.2", path = "../fonts" } more-asserts = "0.2" serde = { version = "1.0", default-features = false } serde_derive = "1.0" -uwh-common = { version = "0.1.1", path = "../uwh-common", default-features = false } +uwh-common = { version = "0.1.2", path = "../uwh-common", default-features = false } diff --git a/overlay/Cargo.lock b/overlay/Cargo.lock index bbee4225..0b37d51f 100644 --- a/overlay/Cargo.lock +++ b/overlay/Cargo.lock @@ -436,7 +436,7 @@ dependencies = [ [[package]] name = "fonts" -version = "0.1.1" +version = "0.1.2" dependencies = [ "embedded-graphics", ] diff --git a/refbox/Cargo.toml b/refbox/Cargo.toml index f18d33de..d737d73b 100644 --- a/refbox/Cargo.toml +++ b/refbox/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "refbox" -version = "0.1.1" +version = "0.1.2" description = "UI for Atlantis Sports's Underwater Hockey Refbox" authors = ["Atlantis Sports "] edition = "2021" @@ -28,7 +28,6 @@ macro-attr-2018 = "2" more-asserts = "0.2" paste = "1.0.7" reqwest = { version = "0.11", features = ["json"] } -rodio = { version = "0.16", default-features = false, features = ["wav"] } serde = "1.0" serde_derive = "1.0" serde_json = "1.0" @@ -38,9 +37,9 @@ time = { version = "0.3", features = ["local-offset", "macros", "serde", "serde- tokio = { version = "1.18", features = ["io-util", "macros", "net", "sync", "time"] } tokio-serial = "5.4" toml = "0.5" -uwh-common = { version = "0.1.1", path = "../uwh-common"} -matrix-drawing = { version = "0.1.1", path = "../matrix-drawing"} -web-audio-api = "0.26" +uwh-common = { version = "0.1.2", path = "../uwh-common"} +matrix-drawing = { version = "0.1.2", path = "../matrix-drawing"} +web-audio-api = { version = "0.26", default-features = false, features = ["cpal"] } [target.'cfg(target_os = "linux")'.dependencies] futures-lite = "1" diff --git a/refbox/resources/sounds/ref-warn-1.aup3 b/refbox/resources/sounds/ref-alert-1.aup3 similarity index 100% rename from refbox/resources/sounds/ref-warn-1.aup3 rename to refbox/resources/sounds/ref-alert-1.aup3 diff --git a/refbox/resources/sounds/ref-warn-1.raw b/refbox/resources/sounds/ref-alert-1.raw similarity index 100% rename from refbox/resources/sounds/ref-warn-1.raw rename to refbox/resources/sounds/ref-alert-1.raw diff --git a/refbox/resources/sounds/ref-warn-2.aup3 b/refbox/resources/sounds/ref-alert-2.aup3 similarity index 100% rename from refbox/resources/sounds/ref-warn-2.aup3 rename to refbox/resources/sounds/ref-alert-2.aup3 diff --git a/refbox/resources/sounds/ref-warn-2.raw b/refbox/resources/sounds/ref-alert-2.raw similarity index 100% rename from refbox/resources/sounds/ref-warn-2.raw rename to refbox/resources/sounds/ref-alert-2.raw diff --git a/refbox/src/app/message.rs b/refbox/src/app/message.rs index 9da884a5..e77cbd1b 100644 --- a/refbox/src/app/message.rs +++ b/refbox/src/app/message.rs @@ -164,14 +164,14 @@ pub enum BoolGameParameter { WhiteOnRight, UsingUwhScores, SoundEnabled, - RefWarnEnabled, + RefAlertEnabled, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum CyclingParameter { BuzzerSound, RemoteBuzzerSound(usize), - WarningVolume, + AlertVolume, AboveWaterVol, UnderWaterVol, } diff --git a/refbox/src/app/mod.rs b/refbox/src/app/mod.rs index 46b623ad..acc5bfee 100644 --- a/refbox/src/app/mod.rs +++ b/refbox/src/app/mod.rs @@ -127,7 +127,7 @@ impl RefBoxApp { } fn maybe_play_sound(&self, new_snapshot: &GameSnapshot) { - let (play_ref_warn, play_buzzer) = match new_snapshot.timeout { + let (play_ref_alert, play_buzzer) = match new_snapshot.timeout { TimeoutSnapshot::Black(time) | TimeoutSnapshot::White(time) => { match self.snapshot.timeout { TimeoutSnapshot::Black(old_time) | TimeoutSnapshot::White(old_time) => ( @@ -142,7 +142,7 @@ impl RefBoxApp { let prereqs = new_snapshot.current_period != GamePeriod::SuddenDeath && new_snapshot.secs_in_period != self.snapshot.secs_in_period; - let is_warn_period = match new_snapshot.current_period { + let is_alert_period = match new_snapshot.current_period { GamePeriod::BetweenGames | GamePeriod::HalfTime | GamePeriod::PreOvertime @@ -169,15 +169,15 @@ impl RefBoxApp { }; ( - prereqs && is_warn_period && new_snapshot.secs_in_period == 35, + prereqs && is_alert_period && new_snapshot.secs_in_period == 35, prereqs && is_buzz_period && new_snapshot.secs_in_period == 0, ) } }; - if play_ref_warn { - info!("Triggering ref warning"); - self.sound.trigger_ref_warn(); + if play_ref_alert { + info!("Triggering ref alert"); + self.sound.trigger_ref_alert(); } else if play_buzzer { info!("Triggering buzzer"); self.sound.trigger_buzzer(); @@ -1211,8 +1211,8 @@ impl Application for RefBoxApp { BoolGameParameter::WhiteOnRight => edited_settings.white_on_right ^= true, BoolGameParameter::UsingUwhScores => edited_settings.using_uwhscores ^= true, BoolGameParameter::SoundEnabled => edited_settings.sound.sound_enabled ^= true, - BoolGameParameter::RefWarnEnabled => { - edited_settings.sound.ref_warn_enabled ^= true + BoolGameParameter::RefAlertEnabled => { + edited_settings.sound.ref_alert_enabled ^= true } } } @@ -1221,7 +1221,7 @@ impl Application for RefBoxApp { match param { CyclingParameter::BuzzerSound => sound.buzzer_sound.cycle(), CyclingParameter::RemoteBuzzerSound(idx) => sound.remotes[idx].sound.cycle(), - CyclingParameter::WarningVolume => sound.ref_warn_vol.cycle(), + CyclingParameter::AlertVolume => sound.ref_alert_vol.cycle(), CyclingParameter::AboveWaterVol => sound.above_water_vol.cycle(), CyclingParameter::UnderWaterVol => sound.under_water_vol.cycle(), } diff --git a/refbox/src/app/view_builders/configuration.rs b/refbox/src/app/view_builders/configuration.rs index be1c3f45..00d56d90 100644 --- a/refbox/src/app/view_builders/configuration.rs +++ b/refbox/src/app/view_builders/configuration.rs @@ -480,10 +480,10 @@ fn make_sound_config_page<'a>( )) .push(make_value_button( "REF WARN\nVOLUME:", - sound.ref_warn_vol.to_string().to_uppercase(), + sound.ref_alert_vol.to_string().to_uppercase(), (false, true), - if sound.sound_enabled && sound.ref_warn_enabled { - Some(Message::CycleParameter(CyclingParameter::WarningVolume)) + if sound.sound_enabled && sound.ref_alert_enabled { + Some(Message::CycleParameter(CyclingParameter::AlertVolume)) } else { None }, @@ -502,12 +502,12 @@ fn make_sound_config_page<'a>( .spacing(SPACING) .height(Length::Fill) .push(make_value_button( - "REF WARN\nENABLED:", - bool_string(sound.ref_warn_enabled), + "REF ALERT\nENABLED:", + bool_string(sound.ref_alert_enabled), (false, true), if sound.sound_enabled { Some(Message::ToggleBoolParameter( - BoolGameParameter::RefWarnEnabled, + BoolGameParameter::RefAlertEnabled, )) } else { None diff --git a/refbox/src/app/view_builders/shared_elements.rs b/refbox/src/app/view_builders/shared_elements.rs index fe308c86..9dde8654 100644 --- a/refbox/src/app/view_builders/shared_elements.rs +++ b/refbox/src/app/view_builders/shared_elements.rs @@ -249,7 +249,7 @@ pub(super) fn make_game_time_button<'a>( } TimeoutSnapshot::Ref(_) | TimeoutSnapshot::PenaltyShot(_) => false, TimeoutSnapshot::None => { - let is_warn_period = match snapshot.current_period { + let is_alert_period = match snapshot.current_period { GamePeriod::BetweenGames | GamePeriod::HalfTime | GamePeriod::PreOvertime @@ -266,7 +266,7 @@ pub(super) fn make_game_time_button<'a>( && ((snapshot.secs_in_period <= 10 && (snapshot.secs_in_period % 2 == 0) && (snapshot.secs_in_period != 0)) - || (is_warn_period && snapshot.secs_in_period == 30)) + || (is_alert_period && snapshot.secs_in_period == 30)) } } }; diff --git a/refbox/src/sound_controller/mod.rs b/refbox/src/sound_controller/mod.rs index 5188d3e7..9e9d4d5d 100644 --- a/refbox/src/sound_controller/mod.rs +++ b/refbox/src/sound_controller/mod.rs @@ -62,10 +62,10 @@ pub struct SoundSettings { #[derivative(Default(value = "true"))] pub sound_enabled: bool, #[derivative(Default(value = "true"))] - pub ref_warn_enabled: bool, + pub ref_alert_enabled: bool, pub buzzer_sound: BuzzerSound, #[derivative(Default(value = "Volume::Medium"))] - pub ref_warn_vol: Volume, + pub ref_alert_vol: Volume, pub above_water_vol: Volume, pub under_water_vol: Volume, pub remotes: Vec, @@ -105,7 +105,7 @@ pub struct RemoteInfo { #[derive(Debug, Clone, PartialEq, Eq)] enum SoundMessage { TriggerBuzzer, - TriggerRefWarning, + TriggerRefAlert, #[cfg(target_os = "linux")] StartBuzzer(Option), #[cfg(target_os = "linux")] @@ -146,6 +146,7 @@ impl SoundController { let mut _stop_rx = stop_rx.clone(); let mut _settings_rx = settings_rx.clone(); + #[cfg_attr(not(target_os = "linux"), allow(clippy::redundant_clone))] let mut _settings = settings.clone(); let _context = context.clone(); @@ -169,10 +170,10 @@ impl SoundController { let sound = Sound::new(_context.clone(), volumes, library[_settings.buzzer_sound].clone(), true, true); last_sound = Some(sound); } - SoundMessage::TriggerRefWarning => { - info!("Playing ref warning once"); + SoundMessage::TriggerRefAlert => { + info!("Playing ref alert once"); let volumes = ChannelVolumes::new(&_settings, true); - let sound = Sound::new(_context.clone(), volumes, library.ref_warn().clone(), false, false); + let sound = Sound::new(_context.clone(), volumes, library.ref_alert().clone(), false, false); last_sound = Some(sound); } #[cfg(target_os = "linux")] @@ -444,8 +445,8 @@ impl SoundController { self.settings_tx.send(settings).unwrap() } - pub fn trigger_ref_warn(&self) { - self.msg_tx.send(SoundMessage::TriggerRefWarning).unwrap() + pub fn trigger_ref_alert(&self) { + self.msg_tx.send(SoundMessage::TriggerRefAlert).unwrap() } pub fn trigger_buzzer(&self) { @@ -492,16 +493,16 @@ struct ChannelVolumes { } impl ChannelVolumes { - fn new(settings: &SoundSettings, is_ref_warn: bool) -> Self { + fn new(settings: &SoundSettings, is_ref_alert: bool) -> Self { Self { - left: if settings.sound_enabled && settings.ref_warn_enabled && is_ref_warn { - settings.ref_warn_vol.as_f32() - } else if settings.sound_enabled && !is_ref_warn { + left: if settings.sound_enabled && settings.ref_alert_enabled && is_ref_alert { + settings.ref_alert_vol.as_f32() + } else if settings.sound_enabled && !is_ref_alert { settings.above_water_vol.as_f32() } else { 0.0 }, - right: if settings.sound_enabled && !is_ref_warn { + right: if settings.sound_enabled && !is_ref_alert { settings.under_water_vol.as_f32() } else { 0.0 diff --git a/refbox/src/sound_controller/sounds.rs b/refbox/src/sound_controller/sounds.rs index 0c881904..7984fd87 100644 --- a/refbox/src/sound_controller/sounds.rs +++ b/refbox/src/sound_controller/sounds.rs @@ -30,13 +30,13 @@ const fn process_array(input: &[u8; M]) -> [f32; // can't be run on sound samples more than about 0.8s long, so we need to work around it by // processing smaller samples then concatenating them. See https://github.com/rust-lang/rust/pull/103877 // for a resolution that will potentially land soon -const LEN1: usize = include_bytes!("../../resources/sounds/ref-warn-1.raw").len() / 4; -const PT1: [f32; LEN1] = process_array(include_bytes!("../../resources/sounds/ref-warn-1.raw")); -const LEN2: usize = include_bytes!("../../resources/sounds/ref-warn-2.raw").len() / 4; -const PT2: [f32; LEN2] = process_array(include_bytes!("../../resources/sounds/ref-warn-2.raw")); +const LEN1: usize = include_bytes!("../../resources/sounds/ref-alert-1.raw").len() / 4; +const PT1: [f32; LEN1] = process_array(include_bytes!("../../resources/sounds/ref-alert-1.raw")); +const LEN2: usize = include_bytes!("../../resources/sounds/ref-alert-2.raw").len() / 4; +const PT2: [f32; LEN2] = process_array(include_bytes!("../../resources/sounds/ref-alert-2.raw")); const CONCAT: [f32; concat_arrays_size!(PT1, PT2)] = concat_arrays!(PT1, PT2); -const REF_WARN_LEN: usize = concat_arrays_size!(CONCAT, PT1); -static REF_WARN: [f32; REF_WARN_LEN] = concat_arrays!(CONCAT, PT1); +const REF_ALERT_LEN: usize = concat_arrays_size!(CONCAT, PT1); +static REF_ALERT: [f32; REF_ALERT_LEN] = concat_arrays!(CONCAT, PT1); const BUZZ_LEN: usize = include_bytes!("../../resources/sounds/buzz.raw").len() / 4; static BUZZ: [f32; BUZZ_LEN] = process_array(include_bytes!("../../resources/sounds/buzz.raw")); @@ -86,7 +86,7 @@ pub(super) struct SoundLibrary { crazy: AudioBuffer, de_de_du: AudioBuffer, two_tone: AudioBuffer, - ref_warn: AudioBuffer, + ref_alert: AudioBuffer, } impl Index for SoundLibrary { @@ -120,8 +120,8 @@ impl SoundLibrary { let mut two_tone = context.create_buffer(1, TWO_TONE_LEN, SAMPLE_RATE); two_tone.copy_to_channel(&TWO_TONE, 0); - let mut ref_warn = context.create_buffer(1, REF_WARN_LEN, SAMPLE_RATE); - ref_warn.copy_to_channel(&REF_WARN, 0); + let mut ref_alert = context.create_buffer(1, REF_ALERT_LEN, SAMPLE_RATE); + ref_alert.copy_to_channel(&REF_ALERT, 0); Self { buzz, @@ -129,11 +129,11 @@ impl SoundLibrary { crazy, de_de_du, two_tone, - ref_warn, + ref_alert, } } - pub(super) fn ref_warn(&self) -> &AudioBuffer { - &self.ref_warn + pub(super) fn ref_alert(&self) -> &AudioBuffer { + &self.ref_alert } } diff --git a/uwh-common/Cargo.toml b/uwh-common/Cargo.toml index 500e3344..127a8487 100644 --- a/uwh-common/Cargo.toml +++ b/uwh-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uwh-common" -version = "0.1.1" +version = "0.1.2" authors = ["Atlantis Sports "] edition = "2021" @@ -14,7 +14,7 @@ arrayvec = { version = "0.7.2", default-features = false, features = ["serde"] } defmt = "0.3.1" derivative = { version = "2.2.0", features = ["use_core"] } displaydoc = { version = "0.2.3", default-features = false } -fonts = { version = "0.1.1", path = "../fonts" } +fonts = { version = "0.1.2", path = "../fonts" } log = "0.4.16" serde = { version = "1.0", default-features = false, features = ["derive"] } time = { version = "0.3", features = [