MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / parse_ogg

Function parse_ogg

native/shared/src/audio.rs:348–363  ·  view source on GitHub ↗

Parse an OGG Vorbis file into SoundData.

(data: &[u8])

Source from the content-addressed store, hash-verified

346
347/// Parse an OGG Vorbis file into SoundData.
348pub fn parse_ogg(data: &[u8]) -> Option<SoundData> {
349 let cursor = std::io::Cursor::new(data);
350 let mut reader = lewton::inside_ogg::OggStreamReader::new(cursor).ok()?;
351 let sample_rate = reader.ident_hdr.audio_sample_rate;
352 let channels = reader.ident_hdr.audio_channels as u16;
353 let mut samples = Vec::new();
354
355 while let Ok(Some(packet)) = reader.read_dec_packet_itl() {
356 for &sample in &packet {
357 samples.push(sample as f32 / 32768.0);
358 }
359 }
360
361 if samples.is_empty() { return None; }
362 Some(SoundData { samples, sample_rate, channels })
363}

Callers 15

bloom_load_soundFunction · 0.85
bloom_load_musicFunction · 0.85
bloom_stage_soundFunction · 0.85
bloom_load_soundFunction · 0.85
bloom_load_musicFunction · 0.85
bloom_stage_soundFunction · 0.85
bloom_load_soundFunction · 0.85
bloom_load_musicFunction · 0.85
bloom_stage_soundFunction · 0.85
bloom_load_soundFunction · 0.85
bloom_load_musicFunction · 0.85
bloom_stage_soundFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected