oml_audio/audio/
audio_stub.rs

1
2use crate::FileLoader;
3use crate::Music;
4use crate::SoundBank;
5//use crate::SoundPool;
6
7use std::time::Instant;	// temporary, we get higher precision by calculating from the audio callbacks
8
9#[derive(Debug)]
10pub struct AudioStub {
11	last_now:		Instant,
12	capture_buffer: Vec< f32 >,
13}
14
15impl AudioStub {
16	pub fn new() -> Self {
17		Self {
18	        last_now:		Instant::now(),
19	        capture_buffer:	Vec::new(),
20		}
21	}
22
23	pub fn update( &mut self ) -> f64 {
24        let timestep = self.last_now.elapsed().as_secs_f64();
25        self.last_now = Instant::now();
26
27		timestep
28	}
29
30	pub fn load_music( &mut self, fileloader: &mut impl FileLoader, filename: &str ) -> bool {
31//		self.music.load( fileloader, filename )
32		true
33	}
34
35	pub fn play_music( &mut self ) {
36//		self.music.play();
37	}
38	pub fn pause_music( &mut self ) {
39//		self.music.pause();
40	}
41
42	pub fn load_sound_bank( &mut self, fileloader: &mut impl FileLoader, filename: &str ) {
43//		self.sound_bank.load( fileloader, filename )
44	}
45
46	pub fn play_sound( &mut self, name: &str ) {
47//		self.sound_bank.play( name );
48	}
49
50	pub fn capture( &mut self, size: usize ) {
51	}
52
53	pub fn capture_buffer_slice( &self ) -> &[f32] {
54		self.capture_buffer.as_slice()
55	}
56
57}