diff options
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(); |