mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Lower volume of river sfx
This commit is contained in:
parent
0f3eb6cb3f
commit
9a8c288580
@ -76,7 +76,7 @@
|
||||
)),
|
||||
Individual((
|
||||
title: "A Hero's Sorrow",
|
||||
path: "voxygen.audio.soundtrack.overworld.a_heroes_sorrow",
|
||||
path: "voxygen.audio.soundtrack.overworld.a_heros_sorrow",
|
||||
length: 251.0,
|
||||
timing: None,
|
||||
weather: Some(Rain),
|
||||
|
@ -253,12 +253,12 @@ impl SfxChannel {
|
||||
|
||||
/// Same as SfxChannel::play but with the source passed through
|
||||
/// a low pass filter at 300 Hz
|
||||
pub fn play_with_low_pass_filter<S>(&mut self, source: S)
|
||||
pub fn play_with_low_pass_filter<S>(&mut self, source: S, freq: u32)
|
||||
where
|
||||
S: Sized + Send + 'static,
|
||||
S: Source<Item = f32>,
|
||||
{
|
||||
let source = source.low_pass(300);
|
||||
let source = source.low_pass(freq);
|
||||
self.sink.append(source);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ impl AudioFrontend {
|
||||
channel.set_pos(position);
|
||||
channel.update(&listener);
|
||||
if underwater {
|
||||
channel.play_with_low_pass_filter(sound.convert_samples());
|
||||
channel.play_with_low_pass_filter(sound.convert_samples(), 300);
|
||||
} else {
|
||||
channel.play(sound);
|
||||
}
|
||||
@ -290,6 +290,43 @@ impl AudioFrontend {
|
||||
}
|
||||
}
|
||||
|
||||
/// Play a sfx file given its position, SfxEvent, and volume with a low-pass
|
||||
/// filter at the given frequency
|
||||
pub fn emit_filtered_sfx(
|
||||
&mut self,
|
||||
trigger_item: Option<(&SfxEvent, &SfxTriggerItem)>,
|
||||
position: Vec3<f32>,
|
||||
volume: Option<f32>,
|
||||
freq: Option<u32>,
|
||||
underwater: bool,
|
||||
) {
|
||||
if let Some(sfx_file) = Self::get_sfx_file(trigger_item) {
|
||||
// Play sound in empty channel at given position
|
||||
if self.audio_stream.is_some() && volume.map_or(true, |v| v > MIN_HEARABLE_VOLUME) {
|
||||
let sound = load_ogg(sfx_file).amplify(volume.unwrap_or(1.0));
|
||||
|
||||
let listener = self.listener.clone();
|
||||
if let Some(channel) = self.get_sfx_channel() {
|
||||
channel.set_pos(position);
|
||||
channel.update(&listener);
|
||||
if !underwater {
|
||||
channel.play_with_low_pass_filter(
|
||||
sound.convert_samples(),
|
||||
freq.unwrap_or(20000),
|
||||
)
|
||||
} else {
|
||||
channel.play_with_low_pass_filter(sound.convert_samples(), 300)
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug!(
|
||||
"Missing sfx trigger config for sfx event at position: {:?}",
|
||||
position
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Plays a sfx using a non-spatial sink at the given volume; doesn't need a
|
||||
/// position
|
||||
/// Passing no volume will default to 1.0
|
||||
|
@ -101,14 +101,14 @@ impl EventMapper for BlockEventMapper {
|
||||
blocks: |boi| &boi.slow_river,
|
||||
range: 1,
|
||||
sfx: SfxEvent::RunningWaterSlow,
|
||||
volume: 1.5,
|
||||
volume: 1.2,
|
||||
cond: |_| true,
|
||||
},
|
||||
BlockSounds {
|
||||
blocks: |boi| &boi.fast_river,
|
||||
range: 1,
|
||||
sfx: SfxEvent::RunningWaterFast,
|
||||
volume: 2.5,
|
||||
volume: 1.5,
|
||||
cond: |_| true,
|
||||
},
|
||||
//BlockSounds {
|
||||
@ -238,12 +238,22 @@ impl EventMapper for BlockEventMapper {
|
||||
.unwrap_or(false);
|
||||
|
||||
let sfx_trigger_item = triggers.get_key_value(&sounds.sfx);
|
||||
audio.emit_sfx(
|
||||
sfx_trigger_item,
|
||||
block_pos,
|
||||
Some(sounds.volume),
|
||||
underwater,
|
||||
);
|
||||
if sounds.sfx == SfxEvent::RunningWaterFast {
|
||||
audio.emit_filtered_sfx(
|
||||
sfx_trigger_item,
|
||||
block_pos,
|
||||
Some(sounds.volume),
|
||||
Some(8000),
|
||||
underwater,
|
||||
);
|
||||
} else {
|
||||
audio.emit_sfx(
|
||||
sfx_trigger_item,
|
||||
block_pos,
|
||||
Some(sounds.volume),
|
||||
underwater,
|
||||
);
|
||||
}
|
||||
}
|
||||
internal_state.time = Instant::now();
|
||||
internal_state.event = sounds.sfx.clone();
|
||||
|
@ -2448,7 +2448,7 @@ impl Hud {
|
||||
|
||||
// Current song info
|
||||
Text::new(&format!(
|
||||
"Currently playing: {} [{}]",
|
||||
"Now playing: {} [{}]",
|
||||
debug_info.current_track, debug_info.current_artist,
|
||||
))
|
||||
.color(TEXT_COLOR)
|
||||
|
Loading…
Reference in New Issue
Block a user