Music additions

This commit is contained in:
DaforLynx 2021-12-22 11:20:34 +00:00 committed by Joshua Barretto
parent 824a978cdb
commit e44478736e
15 changed files with 135 additions and 45 deletions

View File

@ -1,6 +1,6 @@
( (
combat_nearby_radius: 40.0, combat_nearby_radius: 25.0,
combat_health_factor: 75.0, combat_health_factor: 50.0,
combat_nearby_high_thresh: 4, combat_nearby_high_thresh: 4,
combat_nearby_low_thresh: 4, combat_nearby_low_thresh: 4,
fade_timings: { fade_timings: {
@ -8,8 +8,8 @@
(TitleMusic, Exploration): (4.0, 4.0), (TitleMusic, Exploration): (4.0, 4.0),
(TitleMusic, Combat): (4.0, 4.0), (TitleMusic, Combat): (4.0, 4.0),
(Exploration, TitleMusic): (2.0, 2.0), (Exploration, TitleMusic): (2.0, 2.0),
(Exploration, Combat): (2.0, 2.0), (Exploration, Combat): (0.5, 0.5),
(Combat, Exploration): (3.0, 6.0), (Combat, Exploration): (2.0, 6.0),
(Combat, TitleMusic): (2.0, 2.0), (Combat, TitleMusic): (2.0, 2.0),
}, },
interrupt_delay: 5.0, interrupt_delay: 5.0,

View File

@ -2,11 +2,55 @@
// Times: Some(Day), Some(Night), None [both] // Times: Some(Day), Some(Night), None [both]
// Biomes: Grassland, Forest, Desert, Snowland, Lake, Mountain, Ocean, Jungle // Biomes: Grassland, Forest, Desert, Snowland, Lake, Mountain, Ocean, Jungle
// planned biomes: Savannah, Swamp // planned biomes: Savannah, Swamp
// Sites: Cave, Dungeon, Void [none] // Number after biome indicates weighting
// Music states: Explore, Combat // Sites: Some(Settlement), Some(Cave), Some(Dungeon), Some(Void) [none]
// Music states: Activity(Explore), Activity(Combat)
// Combat music is looped. Needs three files: start, loop, and end. Start also contains one run of the loop.
( (
tracks: [ tracks: [
Individual((
title: "Raising Below Like Thunder",
path: "voxygen.audio.soundtrack.town.raising_below_like_thunder",
length: 120.0,
timing: Some(Night),
biomes: [
(Desert, 1)
],
site: Some(Void),
music_state: Activity(Explore),
artist: "Rarnage",
)),
Individual((
title: "A Tale Worth Telling",
path: "voxygen.audio.soundtrack.town.a_tale_worth_telling",
length: 279.0,
timing: Some(Night),
biomes: [],
site: Some(Settlement),
music_state: Activity(Explore),
artist: "Oolnokk; mixed by cereal7",
)),
Individual((
title: "Bustle and Bloom",
path: "voxygen.audio.soundtrack.town.bustle_and_bloom",
length: 155.0,
timing: Some(Day),
biomes: [],
site: Some(Settlement),
music_state: Activity(Explore),
artist: "DaforLynx",
)),
Individual((
title: "Starlit Pathways",
path: "voxygen.audio.soundtrack.town.starlit_pathways",
length: 132.0,
timing: Some(Night),
biomes: [],
site: Some(Settlement),
music_state: Activity(Explore),
artist: "DaforLynx",
)),
Individual(( Individual((
title: "Rest Assured", title: "Rest Assured",
path: "voxygen.audio.soundtrack.town.rest_assured", path: "voxygen.audio.soundtrack.town.rest_assured",
@ -17,16 +61,6 @@
music_state: Activity(Explore), music_state: Activity(Explore),
artist: "badbbad", artist: "badbbad",
)), )),
Individual((
title: "Onwards!",
path: "voxygen.audio.soundtrack.town.onwards",
length: 151.0,
timing: Some(Night),
biomes: [],
site: Some(Settlement),
music_state: Activity(Explore),
artist: "lorenzo_rozzi",
)),
Individual(( Individual((
title: "I'm Home", title: "I'm Home",
path: "voxygen.audio.soundtrack.town.im_home", path: "voxygen.audio.soundtrack.town.im_home",
@ -167,7 +201,6 @@
timing: Some(Day), timing: Some(Day),
biomes: [ biomes: [
(Desert, 1), (Desert, 1),
(Mountain, 1),
], ],
site: Some(Void), site: Some(Void),
music_state: Activity(Explore), music_state: Activity(Explore),
@ -255,7 +288,6 @@
timing: Some(Night), timing: Some(Night),
biomes: [ biomes: [
(Forest, 1), (Forest, 1),
(Mountain, 1),
], ],
site: Some(Void), site: Some(Void),
music_state: Activity(Explore), music_state: Activity(Explore),
@ -340,7 +372,6 @@
timing: Some(Night), timing: Some(Night),
biomes: [ biomes: [
(Grassland, 1), (Grassland, 1),
(Desert, 1),
], ],
site: Some(Void), site: Some(Void),
music_state: Activity(Explore), music_state: Activity(Explore),
@ -388,7 +419,7 @@
length: 244.0, length: 244.0,
timing: None, timing: None,
biomes: [], biomes: [],
site: Some(Dungeon), site: Some(Cave),
music_state: Activity(Explore), music_state: Activity(Explore),
artist: "badbbad", artist: "badbbad",
)), )),
@ -404,6 +435,9 @@
music_state: Activity(Explore), music_state: Activity(Explore),
artist: "badbbad", artist: "badbbad",
)), )),
// Combat Music
Segmented( Segmented(
title: "Barred Paths", title: "Barred Paths",
author: "DaforLynx", author: "DaforLynx",
@ -411,9 +445,21 @@
biomes: [], biomes: [],
site: Some(Dungeon), site: Some(Dungeon),
segments: [ segments: [
("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-end", 6.0, Transition(Combat(High), Explore), None),
("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-loop", 54.0, Activity(Combat(High)), None),
("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-start", 56.0, Transition(Explore, Combat(High)), Some(Combat(High))), ("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-start", 56.0, Transition(Explore, Combat(High)), Some(Combat(High))),
("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-loop", 54.0, Activity(Combat(High)), None),
("voxygen.audio.soundtrack.combat.barred_paths.barred_paths-end", 6.0, Transition(Combat(High), Explore), None),
],
),
Segmented(
title: "Reversal",
author: "DaforLynx",
timing: None,
biomes: [],
site: Some(Dungeon),
segments: [
("voxygen.audio.soundtrack.combat.reversal.reversal-start", 60.0, Transition(Explore, Combat(High)), Some(Combat(High))),
("voxygen.audio.soundtrack.combat.reversal.reversal-loop", 60.0, Activity(Combat(High)), None),
("voxygen.audio.soundtrack.combat.reversal.reversal-end", 4.0, Transition(Combat(High), Explore), None),
], ],
), ),
] ]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/audio/soundtrack/town/bustle_and_bloom.ogg (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/audio/soundtrack/town/starlit_pathways.ogg (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -279,6 +279,8 @@ impl MusicMgr {
MusicState::Transition(_, next) => MusicState::Activity(next), MusicState::Transition(_, next) => MusicState::Activity(next),
}; };
// TODO: Instead of a constant tick, make this a timer that starts only when
// combat might end, providing a proper "buffer".
let interrupt = matches!(music_state, MusicState::Transition(_, _)) let interrupt = matches!(music_state, MusicState::Transition(_, _))
&& self.last_interrupt.elapsed().as_secs_f32() > mtm.interrupt_delay; && self.last_interrupt.elapsed().as_secs_f32() > mtm.interrupt_delay;
@ -309,10 +311,17 @@ impl MusicMgr {
) -> Result<MusicState, ()> { ) -> Result<MusicState, ()> {
let mut rng = thread_rng(); let mut rng = thread_rng();
// Adds a bit of randomness between plays // Adds a bit of randomness between plays, depending on whether the player is in
// a town, or exploring.
// TODO: make this something that is decided when a song ends, instead of when
// it begins
let silence_between_tracks_seconds: f32 = let silence_between_tracks_seconds: f32 =
if matches!(music_state, MusicState::Activity(MusicActivity::Explore)) { if matches!(music_state, MusicState::Activity(MusicActivity::Explore))
&& matches!(client.current_site(), SitesKind::Settlement)
{
rng.gen_range(90.0..180.0) rng.gen_range(90.0..180.0)
} else if matches!(music_state, MusicState::Activity(MusicActivity::Explore)) {
rng.gen_range(60.0..120.0)
} else { } else {
0.0 0.0
}; };
@ -349,8 +358,24 @@ impl MusicMgr {
if maybe_tracks.is_empty() { if maybe_tracks.is_empty() {
return Err(()); return Err(());
} }
// Second, prevent playing the last track if possible (though don't return Err // Second, prevent playing the last track (when not in combat, because then it
// here, since the combat music is intended to loop) // needs to loop)
if music_state == &MusicState::Activity(MusicActivity::Combat(CombatIntensity::High))
|| music_state
== &MusicState::Transition(
MusicActivity::Combat(CombatIntensity::High),
MusicActivity::Explore,
)
{
let filtered_tracks: Vec<_> = maybe_tracks
.iter()
.filter(|track| track.title.eq(&self.last_track))
.copied()
.collect();
if !filtered_tracks.is_empty() {
maybe_tracks = filtered_tracks;
}
} else {
let filtered_tracks: Vec<_> = maybe_tracks let filtered_tracks: Vec<_> = maybe_tracks
.iter() .iter()
.filter(|track| !track.title.eq(&self.last_track)) .filter(|track| !track.title.eq(&self.last_track))
@ -359,6 +384,7 @@ impl MusicMgr {
if !filtered_tracks.is_empty() { if !filtered_tracks.is_empty() {
maybe_tracks = filtered_tracks; maybe_tracks = filtered_tracks;
} }
}
// Randomly selects a track from the remaining tracks weighted based // Randomly selects a track from the remaining tracks weighted based
// on the biome // on the biome
@ -378,7 +404,7 @@ impl MusicMgr {
); );
if let Ok(track) = new_maybe_track { if let Ok(track) = new_maybe_track {
//println!("Now playing {:?}", track.title); // println!("Now playing {:?}", track.title);
self.last_track = String::from(&track.title); self.last_track = String::from(&track.title);
self.began_playing = Instant::now(); self.began_playing = Instant::now();
self.next_track_change = track.length + silence_between_tracks_seconds; self.next_track_change = track.length + silence_between_tracks_seconds;