From f57de5cd6075c071fe89bb7af898072b0a8daab6 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 4 Mar 2020 09:11:08 -0600 Subject: compiles a semi optimized version always, sets up volume to be very low --- src/audio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/audio.rs') diff --git a/src/audio.rs b/src/audio.rs index bbc3a53..ac6bc12 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -2,6 +2,8 @@ use alto::{Alto, Stereo, StreamingSource}; use lewton::inside_ogg::OggStreamReader; use std::fs::File; +use crate::constants; + pub fn init() -> StreamingSource { let mut source = OggStreamReader::new(File::open("data/djbLUETOOTH.ogg").unwrap()).unwrap(); let alto = Alto::load_default().unwrap(); @@ -10,7 +12,11 @@ pub fn init() -> StreamingSource { let mut stream = audio_context.new_streaming_source().unwrap(); let sample_rate = source.ident_hdr.audio_sample_rate as i32; - while let Ok(Some(samples)) = source.read_dec_packet_itl() { + while let Ok(Some(mut samples)) = source.read_dec_packet_itl() { + samples = samples + .into_iter() + .map(|s| (s as f32 * constants::VOLUME) as i16) + .collect(); let audio_buffer = audio_context .new_buffer::, _>(&samples, sample_rate) .unwrap(); -- cgit v1.2.3