Merge branch 'DaforLynx/new-music-nov' into 'master'

Music additions

See merge request veloren/veloren!3023
This commit is contained in:
Joshua Barretto 2021-12-22 11:20:34 +00:00
commit 119c802695
15 changed files with 135 additions and 45 deletions

View File

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

View File

@ -2,11 +2,55 @@
// Times: Some(Day), Some(Night), None [both]
// Biomes: Grassland, Forest, Desert, Snowland, Lake, Mountain, Ocean, Jungle
// planned biomes: Savannah, Swamp
// Sites: Cave, Dungeon, Void [none]
// Music states: Explore, Combat
// Number after biome indicates weighting
// 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: [
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((
title: "Rest Assured",
path: "voxygen.audio.soundtrack.town.rest_assured",
@ -17,16 +61,6 @@
music_state: Activity(Explore),
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((
title: "I'm Home",
path: "voxygen.audio.soundtrack.town.im_home",
@ -167,7 +201,6 @@
timing: Some(Day),
biomes: [
(Desert, 1),
(Mountain, 1),
],
site: Some(Void),
music_state: Activity(Explore),
@ -255,7 +288,6 @@
timing: Some(Night),
biomes: [
(Forest, 1),
(Mountain, 1),
],
site: Some(Void),
music_state: Activity(Explore),
@ -340,7 +372,6 @@
timing: Some(Night),
biomes: [
(Grassland, 1),
(Desert, 1),
],
site: Some(Void),
music_state: Activity(Explore),
@ -388,7 +419,7 @@
length: 244.0,
timing: None,
biomes: [],
site: Some(Dungeon),
site: Some(Cave),
music_state: Activity(Explore),
artist: "badbbad",
)),
@ -404,6 +435,9 @@
music_state: Activity(Explore),
artist: "badbbad",
)),
// Combat Music
Segmented(
title: "Barred Paths",
author: "DaforLynx",
@ -411,9 +445,21 @@
biomes: [],
site: Some(Dungeon),
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-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),
};
// 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(_, _))
&& self.last_interrupt.elapsed().as_secs_f32() > mtm.interrupt_delay;
@ -309,10 +311,17 @@ impl MusicMgr {
) -> Result<MusicState, ()> {
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 =
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)
} else if matches!(music_state, MusicState::Activity(MusicActivity::Explore)) {
rng.gen_range(60.0..120.0)
} else {
0.0
};
@ -349,15 +358,32 @@ impl MusicMgr {
if maybe_tracks.is_empty() {
return Err(());
}
// Second, prevent playing the last track if possible (though don't return Err
// here, since the combat music is intended to loop)
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;
// Second, prevent playing the last track (when not in combat, because then it
// 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
.iter()
.filter(|track| !track.title.eq(&self.last_track))
.copied()
.collect();
if !filtered_tracks.is_empty() {
maybe_tracks = filtered_tracks;
}
}
// Randomly selects a track from the remaining tracks weighted based
@ -378,7 +404,7 @@ impl MusicMgr {
);
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.began_playing = Instant::now();
self.next_track_change = track.length + silence_between_tracks_seconds;