add JupiterRecording.ogg, toggle BGM with TAB

This commit is contained in:
yuni 2024-05-23 03:56:13 +02:00
parent 8d4ad64330
commit 2a6e14aa90
3 changed files with 49 additions and 21 deletions

View file

@ -41,7 +41,11 @@
- https://pixabay.com/sound-effects/whoosh-blow-flutter-shortwav-14678/ - https://pixabay.com/sound-effects/whoosh-blow-flutter-shortwav-14678/
- https://pixabay.com/sound-effects/dslr-camera-sounds-26117/ - https://pixabay.com/sound-effects/dslr-camera-sounds-26117/
- https://pixabay.com/sound-effects/beep-6-96243 - https://pixabay.com/sound-effects/beep-6-96243
- Music: [Cinematic Cello](https://pixabay.com/music/build-up-scenes-cinematic-cello-115667) by [Aleksey Chistilin](https://pixabay.com/users/lexin_music-28841948/), [Pixabay Content License](https://pixabay.com/service/license-summary) - Music:
- JupiterRecording.ogg is an [actual Jupiter recording by NASA](https://archive.org/download/voyager-1-and-2-1990-jupiter-nasa-voyager-space-sounds-electronic), public domain.
- Processed by cutting out min 1:47-3:47 and applying a 10s linear crossfade at the end. Exported as ogg with quality=3, see [.kdenlive file](src/audio/JupiterRecording.kdenlive).
- The source file has been taken down, and generally, I can't find information on how exactly this was produced. Hoping it's not a hoax.
- [Cinematic Cello](https://pixabay.com/music/build-up-scenes-cinematic-cello-115667) by [Aleksey Chistilin](https://pixabay.com/users/lexin_music-28841948/), [Pixabay Content License](https://pixabay.com/service/license-summary)
- Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database) - Star chart based on the [HYG Stellar database](https://github.com/astronexus/HYG-Database)
- Font Yupiter-Regular.ttf is placed under the SIL OPEN FONT LICENSE Version 1.1 and is based on: - Font Yupiter-Regular.ttf is placed under the SIL OPEN FONT LICENSE Version 1.1 and is based on:
- Noto Sans Symbols 2, Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols) - Noto Sans Symbols 2, Copyright 2022 The Noto Project Authors (https://github.com/notofonts/symbols)

Binary file not shown.

View file

@ -21,12 +21,19 @@ impl Plugin for AudioPlugin {
app.add_systems(Startup, setup); app.add_systems(Startup, setup);
app.add_systems( app.add_systems(
Update, Update,
respawn_sinks.run_if(on_event::<RespawnSinksEvent>()), (
play_zoom_sfx,
respawn_sinks.run_if(on_event::<RespawnSinksEvent>()),
pause_all.run_if(on_event::<PauseAllSfxEvent>()),
),
);
app.add_systems(
PostUpdate,
(
play_sfx,
toggle_music.run_if(on_event::<ToggleMusicEvent>()),
),
); );
app.add_systems(Update, play_zoom_sfx);
app.add_systems(Update, pause_all.run_if(on_event::<PauseAllSfxEvent>()));
app.add_systems(PostUpdate, play_sfx);
app.add_systems(PostUpdate, update_music);
app.add_event::<PlaySfxEvent>(); app.add_event::<PlaySfxEvent>();
app.add_event::<PauseAllSfxEvent>(); app.add_event::<PauseAllSfxEvent>();
app.add_event::<ToggleMusicEvent>(); app.add_event::<ToggleMusicEvent>();
@ -44,6 +51,11 @@ const PATHS: &[(SfxType, Sfx, &str)] = &[
Sfx::BGM, Sfx::BGM,
"music/Aleksey Chistilin - Cinematic Cello.ogg", "music/Aleksey Chistilin - Cinematic Cello.ogg",
), ),
(
SfxType::BGMNoAR,
Sfx::BGMActualJupiterRecording,
"music/JupiterRecording.ogg",
),
( (
SfxType::LoopSfx, SfxType::LoopSfx,
Sfx::ElectricMotor, Sfx::ElectricMotor,
@ -81,6 +93,7 @@ const PATHS: &[(SfxType, Sfx, &str)] = &[
pub enum Sfx { pub enum Sfx {
Achieve, Achieve,
BGM, BGM,
BGMActualJupiterRecording,
Click, Click,
Connect, Connect,
Crash, Crash,
@ -115,6 +128,7 @@ pub fn str2sfx(sfx_label: &str) -> Sfx {
pub enum SfxType { pub enum SfxType {
BGM, BGM,
BGMNoAR,
LoopSfx, LoopSfx,
OneOff, OneOff,
} }
@ -163,7 +177,20 @@ pub fn respawn_sinks(
source, source,
settings: PlaybackSettings { settings: PlaybackSettings {
mode: PlaybackMode::Loop, mode: PlaybackMode::Loop,
paused: settings.mute_music, paused: settings.mute_music || !settings.hud_active,
..default()
},
},
));
}
SfxType::BGMNoAR => {
commands.spawn((
*sfx,
AudioBundle {
source,
settings: PlaybackSettings {
mode: PlaybackMode::Loop,
paused: settings.mute_music || settings.hud_active,
..default() ..default()
}, },
}, },
@ -207,22 +234,19 @@ pub fn play_sfx(
} }
} }
pub fn update_music( pub fn toggle_music(q_audiosinks: Query<(&AudioSink, &Sfx)>, settings: Res<var::Settings>) {
mut events: EventReader<ToggleMusicEvent>, for (bgm_sink, sfx) in &q_audiosinks {
q_audiosinks: Query<(&AudioSink, &Sfx)>, let play = match *sfx {
settings: Res<var::Settings>, Sfx::BGM => settings.hud_active,
) { Sfx::BGMActualJupiterRecording => !settings.hud_active,
if !events.is_empty() { _ => {
events.clear();
for (bgm_sink, sfx) in &q_audiosinks {
if *sfx != Sfx::BGM {
continue; continue;
} }
if settings.mute_music { };
bgm_sink.pause(); if settings.mute_music || !play {
} else { bgm_sink.pause();
bgm_sink.play(); } else {
} bgm_sink.play();
} }
} }
} }