File tree Expand file tree Collapse file tree 3 files changed +59
-8
lines changed Expand file tree Collapse file tree 3 files changed +59
-8
lines changed Original file line number Diff line number Diff line change 11use projectm_rs:: core:: { projectm, projectm_handle} ;
22use sdl2:: video:: GLProfile ;
33
4+ pub mod audio;
45pub mod config;
56pub mod main_loop;
67pub mod playlist;
@@ -12,6 +13,7 @@ pub struct App {
1213 sdl_context : sdl2:: Sdl ,
1314 gl_context : sdl2:: video:: GLContext ,
1415 window : sdl2:: video:: Window ,
16+ config : config:: Config ,
1517}
1618
1719pub fn default_config ( ) -> config:: Config {
@@ -53,26 +55,33 @@ impl App {
5355
5456 // initialize projectM
5557 let pm = projectm:: create ( ) ;
58+
5659 // and a preset playlist
5760 let playlist = projectm_rs:: playlist:: Playlist :: create ( pm) ;
5861
5962 // get/set window size
6063 let ( width, height) = window. drawable_size ( ) ; // highDPI aware
6164 projectm:: set_window_size ( pm, width. try_into ( ) . unwrap ( ) , height. try_into ( ) . unwrap ( ) ) ;
6265
63- let mut this = Self {
66+ Self {
6467 pm,
6568 playlist,
6669 sdl_context,
6770 gl_context,
6871 window,
69- } ;
72+ config : if let Some ( config) = config {
73+ config
74+ } else {
75+ default_config ( )
76+ } ,
77+ }
78+ }
7079
80+ pub fn init ( & mut self ) {
7181 // read config
72- if let Some ( config) = config {
73- this. load_config ( config) ;
74- }
82+ self . load_config ( & self . config ) ;
7583
76- this
84+ // initialize audio
85+ let audio = audio:: Audio :: new ( & self ) ;
7786 }
7887}
Original file line number Diff line number Diff line change 1+ use crate :: app:: App ;
2+ use sdl2:: audio:: { AudioCallback , AudioDevice , AudioSpecDesired } ;
3+
4+ pub struct Audio {
5+ app : & App ,
6+ audio_subsystem : sdl2:: AudioSubsystem ,
7+ audio_device_index : u8 ,
8+ // device_list: Vec<sdl2::audio::AudioDevice>,
9+ }
10+
11+ impl Audio {
12+ pub fn new ( app : & App ) -> Self {
13+ let audio_subsystem = app. sdl_context . audio ( ) . unwrap ( ) ;
14+
15+ Self {
16+ app,
17+ audio_subsystem,
18+ audio_device_index : 0 ,
19+ }
20+ }
21+
22+ // pub fn get_device_list(mut self) -> Vec<sdl2::audio::AudioDevice> {
23+ // let audio_subsystem = sdl_context.audio().unwrap();
24+ // let device_list = audio_subsystem
25+ // .capture_devices()
26+ // .expect("could not get audio device list");
27+ // for (i, device) in device_list.enumerate() {
28+ // println!("{}: {}", i, device.name());
29+ // }
30+ // }
31+
32+ pub fn begin_audio_capture ( mut self ) {
33+ let frame_rate = self . app . config . frame_rate . unwrap ( ) ;
34+ let desired_spec = AudioSpecDesired {
35+ freq : Some ( 44100 ) ,
36+ channels : None ,
37+ samples : Some ( 512 ) , // should be 1 frame
38+ } ;
39+ }
40+ }
Original file line number Diff line number Diff line change 11use crate :: app:: App ;
22
33pub struct Config {
4+ pub frame_rate : Option < u32 > ,
45 pub preset_path : Option < String > ,
56}
67
@@ -10,14 +11,15 @@ impl Default for Config {
1011 Self {
1112 // load from home dir or w/e
1213 preset_path : Some ( String :: from ( "/usr/local/share/projectM/presets" ) ) ,
14+ frame_rate : Some ( 60 ) ,
1315 }
1416 }
1517}
1618
1719impl App {
18- pub fn load_config ( & mut self , config : Config ) {
20+ pub fn load_config ( & mut self , config : & Config ) {
1921 // load presets if provided
20- if let Some ( preset_path) = config. preset_path {
22+ if let Some ( preset_path) = & config. preset_path {
2123 self . add_preset_path ( & preset_path) ;
2224 }
2325 }
You can’t perform that action at this time.
0 commit comments