From e1fcb3744e58bea35f5d12ed6792361da41f99ce Mon Sep 17 00:00:00 2001 From: jiminycrick Date: Mon, 9 Nov 2020 16:19:21 -0800 Subject: [PATCH] Comment out audio device picker --- assets/voxygen/audio/sfx.ron | 6 + .../audio/sfx/footsteps/wood_step_1.wav | 3 + .../audio/sfx/footsteps/wood_step_2.wav | 3 + .../audio/sfx/footsteps/wood_step_3.wav | 3 + .../audio/sfx/footsteps/wood_step_4.wav | 3 + voxygen/src/audio/mod.rs | 132 +++++++----------- voxygen/src/audio/sfx/mod.rs | 11 +- voxygen/src/hud/mod.rs | 8 +- voxygen/src/hud/settings_window.rs | 48 ++++--- voxygen/src/main.rs | 17 +-- voxygen/src/session.rs | 12 +- 11 files changed, 120 insertions(+), 126 deletions(-) create mode 100644 assets/voxygen/audio/sfx/footsteps/wood_step_1.wav create mode 100644 assets/voxygen/audio/sfx/footsteps/wood_step_2.wav create mode 100644 assets/voxygen/audio/sfx/footsteps/wood_step_3.wav create mode 100644 assets/voxygen/audio/sfx/footsteps/wood_step_4.wav diff --git a/assets/voxygen/audio/sfx.ron b/assets/voxygen/audio/sfx.ron index d933131be6..9b7701454e 100644 --- a/assets/voxygen/audio/sfx.ron +++ b/assets/voxygen/audio/sfx.ron @@ -412,6 +412,12 @@ ], threshold: 0.3, ), + Inventory(CollectedItem("ShinyGem")): ( + files: [ + "voxygen.audio.sfx.weapon.staff_out", + ], + threshold: 0.3, + ), Inventory(CollectFailed): ( files: [ "voxygen.audio.sfx.inventory.add_failed", diff --git a/assets/voxygen/audio/sfx/footsteps/wood_step_1.wav b/assets/voxygen/audio/sfx/footsteps/wood_step_1.wav new file mode 100644 index 0000000000..dd93ea5476 --- /dev/null +++ b/assets/voxygen/audio/sfx/footsteps/wood_step_1.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7519bbdea2c5e2713ec884cf08a7c4b03d1bef30eb264091ae8c22623449a259 +size 31090 diff --git a/assets/voxygen/audio/sfx/footsteps/wood_step_2.wav b/assets/voxygen/audio/sfx/footsteps/wood_step_2.wav new file mode 100644 index 0000000000..d918f7fd9f --- /dev/null +++ b/assets/voxygen/audio/sfx/footsteps/wood_step_2.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4a3a3025be119a89064e0f48adde1f2494d9df217040626b514b047254f3742 +size 27654 diff --git a/assets/voxygen/audio/sfx/footsteps/wood_step_3.wav b/assets/voxygen/audio/sfx/footsteps/wood_step_3.wav new file mode 100644 index 0000000000..b288c2bf48 --- /dev/null +++ b/assets/voxygen/audio/sfx/footsteps/wood_step_3.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57fb2f3a6219020b9f4834eb255720b86ca49976a53867f49b74f863982c11e9 +size 25582 diff --git a/assets/voxygen/audio/sfx/footsteps/wood_step_4.wav b/assets/voxygen/audio/sfx/footsteps/wood_step_4.wav new file mode 100644 index 0000000000..afaf29fe54 --- /dev/null +++ b/assets/voxygen/audio/sfx/footsteps/wood_step_4.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50a3ab5b659a5a4d054eaf82b3e1af45cf07b54f051627c91424166d7e3cc6f3 +size 32258 diff --git a/voxygen/src/audio/mod.rs b/voxygen/src/audio/mod.rs index 194f2819d5..0d9d9d0e71 100644 --- a/voxygen/src/audio/mod.rs +++ b/voxygen/src/audio/mod.rs @@ -14,8 +14,8 @@ use std::time::Duration; use tracing::warn; use common::assets; -use cpal::traits::{DeviceTrait, HostTrait}; -use rodio::{source::Source, Decoder, Device, OutputStream, OutputStreamHandle, StreamError}; +//use cpal::traits::{DeviceTrait, HostTrait}; +use rodio::{source::Source, Decoder, OutputStream, OutputStreamHandle, StreamError}; use vek::*; #[derive(Default, Clone)] @@ -32,9 +32,9 @@ pub struct Listener { /// Voxygen's [`GlobalState`](../struct.GlobalState.html#structfield.audio) to /// provide access to devices and playback control in-game pub struct AudioFrontend { - pub device: String, - pub device_list: Vec, - pub audio_device: Option, + //pub device: String, + //pub device_list: Vec, + //pub audio_device: Option, pub stream: Option, audio_stream: Option, sound_cache: SoundCache, @@ -49,25 +49,17 @@ pub struct AudioFrontend { impl AudioFrontend { /// Construct with given device - pub fn new(dev: String, max_sfx_channels: usize) -> Self { - let audio_device = get_device_raw(&dev); + pub fn new(/* dev: String, */ max_sfx_channels: usize) -> Self { + //let audio_device = get_device_raw(&dev); - let device = match get_default_device() { - Some(d) => d, - None => "".to_string(), - }; + //let device = match get_default_device() { + // Some(d) => d, + // None => "".to_string(), + //}; - //let (stream, audio_stream) = match get_default_stream() { - let (stream, audio_stream) = if get_device_raw(&dev).is_some() { - match get_stream(&get_device_raw(&dev).unwrap()) { - Ok(s) => (Some(s.0), Some(s.1)), - Err(_) => (None, None), - } - } else { - match get_default_stream() { - Ok(s) => (Some(s.0), Some(s.1)), - Err(_) => (None, None), - } + let (stream, audio_stream) = match get_default_stream() { + Ok(s) => (Some(s.0), Some(s.1)), + Err(_) => (None, None), }; let mut sfx_channels = Vec::with_capacity(max_sfx_channels); @@ -78,9 +70,9 @@ impl AudioFrontend { }; Self { - device, - device_list: list_devices(), - audio_device, + //device, + //device_list: list_devices(), + //audio_device, stream, audio_stream, sound_cache: SoundCache::default(), @@ -96,9 +88,9 @@ impl AudioFrontend { /// Construct in `no-audio` mode for debugging pub fn no_audio() -> Self { Self { - device: "".to_string(), - device_list: Vec::new(), - audio_device: None, + //device: "".to_string(), + //device_list: Vec::new(), + //audio_device: None, stream: None, audio_stream: None, sound_cache: SoundCache::default(), @@ -352,81 +344,55 @@ impl AudioFrontend { } } - // TODO: figure out how badly this will break things when it is called - pub fn set_device(&mut self, name: String) { - self.device = name.clone(); - self.audio_device = get_device_raw(&name); - } + //// TODO: figure out how badly this will break things when it is called + //pub fn set_device(&mut self, name: String) { + // self.device = name.clone(); + // self.audio_device = get_device_raw(&name); + //} } ///// Returns the default audio device. ///// Does not return rodio Device struct in case our audio backend changes. //pub fn get_default_device() -> Option { -// match rodio::default_output_device() { +// match cpal::default_host().default_output_device() { // Some(x) => Some(x.name().ok()?), // None => None, // } //} -pub fn get_default_device() -> Option { - match cpal::default_host().default_output_device() { - Some(x) => Some(x.name().ok()?), - None => None, - } -} /// Returns the default stream pub fn get_default_stream() -> Result<(OutputStream, OutputStreamHandle), StreamError> { rodio::OutputStream::try_default() } -/// Returns a stream on the specified device -pub fn get_stream( - device: &rodio::Device, -) -> Result<(OutputStream, OutputStreamHandle), StreamError> { - rodio::OutputStream::try_from_device(device) -} - -///// Returns a vec of the audio devices available. -///// Does not return rodio Device struct in case our audio backend changes. -//pub fn list_devices() -> Vec { -// list_devices_raw() -// .iter() -// .map(|x| x.name().unwrap()) -// .collect() +///// Returns a stream on the specified device +//pub fn get_stream( +// device: &rodio::Device, +//) -> Result<(OutputStream, OutputStreamHandle), StreamError> { +// rodio::OutputStream::try_from_device(device) //} - -///// Returns vec of devices -//fn list_devices_raw() -> Vec { -// match rodio::output_devices() { -// Ok(devices) => { -// // Filter out any devices that the name isn't available for -// devices.filter(|d| d.name().is_ok()).collect() -// }, +// +//fn list_devices_raw() -> Vec { +// match cpal::default_host().devices() { +// Ok(devices) => devices.filter(|d| d.name().is_ok()).collect(), // Err(_) => { // warn!("Failed to enumerate audio output devices, audio will not be // available"); Vec::new() // }, // } //} -fn list_devices_raw() -> Vec { - match cpal::default_host().devices() { - Ok(devices) => devices.filter(|d| d.name().is_ok()).collect(), - Err(_) => { - warn!("Failed to enumerate audio output devices, audio will not be available"); - Vec::new() - }, - } -} - -fn list_devices() -> Vec { - list_devices_raw() - .iter() - .map(|x| x.name().unwrap()) - .collect() -} // -fn get_device_raw(device: &str) -> Option { - list_devices_raw() - .into_iter() - .find(|d| d.name().unwrap() == device) -} +///// Returns a vec of the audio devices available. +///// Does not return rodio Device struct in case our audio backend changes. +//fn list_devices() -> Vec { +// list_devices_raw() +// .iter() +// .map(|x| x.name().unwrap()) +// .collect() +//} +// +//fn get_device_raw(device: &str) -> Option { +// list_devices_raw() +// .into_iter() +// .find(|d| d.name().unwrap() == device) +//} diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index 4e76fa0978..5f9e004719 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -174,6 +174,7 @@ pub enum SfxEvent { pub enum SfxInventoryEvent { Collected, CollectedTool(ToolKind), + CollectedItem(String), CollectFailed, Consumed(String), Debug, @@ -187,12 +188,18 @@ impl From<&InventoryUpdateEvent> for SfxEvent { fn from(value: &InventoryUpdateEvent) -> Self { match value { InventoryUpdateEvent::Collected(item) => { - // Handle sound effects for types of collected items, falling back to the - // default Collected event + // Handle sound effects for types of collected items, falling + // back to the default Collected event match &item.kind() { ItemKind::Tool(tool) => { SfxEvent::Inventory(SfxInventoryEvent::CollectedTool(tool.kind.clone())) }, + ItemKind::Ingredient { kind } => match &kind[..] { + "ShinyGem" => { + SfxEvent::Inventory(SfxInventoryEvent::CollectedItem(kind.clone())) + }, + _ => SfxEvent::Inventory(SfxInventoryEvent::Collected), + }, _ => SfxEvent::Inventory(SfxInventoryEvent::Collected), } }, diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 1ccf95d029..6377d57d8a 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -319,7 +319,7 @@ pub enum Event { AdjustFigureLoDRenderDistance(u32), AdjustMusicVolume(f32), AdjustSfxVolume(f32), - ChangeAudioDevice(String), + //ChangeAudioDevice(String), ChangeMaxFPS(u32), ChangeFOV(u16), ChangeGamma(f32), @@ -2131,9 +2131,9 @@ impl Hud { settings_window::Event::MaximumFPS(max_fps) => { events.push(Event::ChangeMaxFPS(max_fps)); }, - settings_window::Event::ChangeAudioDevice(name) => { - events.push(Event::ChangeAudioDevice(name)); - }, + //settings_window::Event::ChangeAudioDevice(name) => { + // events.push(Event::ChangeAudioDevice(name)); + //}, settings_window::Event::CrosshairType(crosshair_type) => { events.push(Event::CrosshairType(crosshair_type)); }, diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 29ea570eda..506b0f1aa8 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -291,7 +291,7 @@ pub enum Event { ChangeRenderMode(Box), AdjustMusicVolume(f32), AdjustSfxVolume(f32), - ChangeAudioDevice(String), + //ChangeAudioDevice(String), MaximumFPS(u32), CrosshairTransp(f32), CrosshairType(CrosshairType), @@ -2693,30 +2693,32 @@ impl<'a> Widget for SettingsWindow<'a> { events.push(Event::AdjustSfxVolume(new_val)); } - // Audio Device Selector -------------------------------------------- - let device = &self.global_state.audio.device; - let device_list = &self.global_state.audio.device_list; - Text::new(&self.localized_strings.get("hud.settings.audio_device")) - .down_from(state.ids.sfx_volume_slider, 10.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.audio_device_text, ui); + // Audio Device Selector + // -------------------------------------------- + // let device = &self.global_state.audio.device; + //let device_list = &self.global_state.audio.device_list; + //Text::new(&self.localized_strings.get("hud.settings.audio_device" + // )) .down_from(state.ids.sfx_volume_slider, 10.0) + // .font_size(self.fonts.cyri.scale(14)) + // .font_id(self.fonts.cyri.conrod_id) + // .color(TEXT_COLOR) + // .set(state.ids.audio_device_text, ui); - // Get which device is currently selected - let selected = device_list.iter().position(|x| x.contains(device)); + //// Get which device is currently selected + //let selected = device_list.iter().position(|x| + // x.contains(device)); - if let Some(clicked) = DropDownList::new(&device_list, selected) - .w_h(400.0, 22.0) - .color(MENU_BG) - .label_color(TEXT_COLOR) - .label_font_id(self.fonts.opensans.conrod_id) - .down_from(state.ids.audio_device_text, 10.0) - .set(state.ids.audio_device_list, ui) - { - let new_val = device_list[clicked].clone(); - events.push(Event::ChangeAudioDevice(new_val)); - } + //if let Some(clicked) = DropDownList::new(&device_list, selected) + // .w_h(400.0, 22.0) + // .color(MENU_BG) + // .label_color(TEXT_COLOR) + // .label_font_id(self.fonts.opensans.conrod_id) + // .down_from(state.ids.audio_device_text, 10.0) + // .set(state.ids.audio_device_list, ui) + //{ + // let new_val = device_list[clicked].clone(); + // events.push(Event::ChangeAudioDevice(new_val)); + //} } // 5) Languages Tab ----------------------------------- diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 8fe5867110..5bb028a9f1 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -9,7 +9,7 @@ use veloren_voxygen::{ logging, profile::Profile, run, - settings::{AudioOutput, Settings}, + settings::Settings, window::Window, GlobalState, }; @@ -142,13 +142,14 @@ fn main() { anim::init(); // Setup audio - let mut audio = match settings.audio.output { - AudioOutput::Off => None, - AudioOutput::Automatic => audio::get_default_device(), - AudioOutput::Device(ref dev) => Some(dev.clone()), - } - .map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels)) - .unwrap_or_else(AudioFrontend::no_audio); + //let mut audio = match settings.audio.output { + // AudioOutput::Off => None, + // AudioOutput::Automatic => audio::get_default_device(), + // AudioOutput::Device(ref dev) => Some(dev.clone()), + //} + //.map(|dev| AudioFrontend::new(dev, settings.audio.max_sfx_channels)) + //.unwrap_or_else(AudioFrontend::no_audio); + let mut audio = AudioFrontend::new(settings.audio.max_sfx_channels); audio.set_music_volume(settings.audio.music_volume); audio.set_sfx_volume(settings.audio.sfx_volume); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 2c15a6984b..260f057086 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -7,7 +7,7 @@ use crate::{ menu::char_selection::CharSelectionState, render::Renderer, scene::{camera, CameraMode, Scene, SceneData}, - settings::{AudioOutput, ControlSettings, Settings}, + settings::{ControlSettings, Settings}, window::{AnalogGameInput, Event, GameInput}, Direction, Error, GlobalState, PlayState, PlayStateResult, }; @@ -901,12 +901,12 @@ impl PlayState for SessionState { global_state.settings.audio.sfx_volume = sfx_volume; global_state.settings.save_to_file_warn(); }, - HudEvent::ChangeAudioDevice(name) => { - global_state.audio.set_device(name.clone()); + //HudEvent::ChangeAudioDevice(name) => { + // global_state.audio.set_device(name.clone()); - global_state.settings.audio.output = AudioOutput::Device(name); - global_state.settings.save_to_file_warn(); - }, + // global_state.settings.audio.output = AudioOutput::Device(name); + // global_state.settings.save_to_file_warn(); + //}, HudEvent::ChangeMaxFPS(fps) => { global_state.settings.graphics.max_fps = fps; global_state.settings.save_to_file_warn();