diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2020-03-04 09:11:08 -0600 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2020-03-04 09:11:08 -0600 |
commit | f57de5cd6075c071fe89bb7af898072b0a8daab6 (patch) | |
tree | a7bf31e5c791e5f0c4122f661b72a621ec3eff2b /src/audio.rs | |
parent | 7ef7e745c9be4d07dbfcc4e536709924c7c982d4 (diff) |
compiles a semi optimized version always, sets up volume to be very low
Diffstat (limited to 'src/audio.rs')
-rw-r--r-- | src/audio.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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::<Stereo<i16>, _>(&samples, sample_rate) .unwrap(); |