File tree 3 files changed +59
-8
lines changed
3 files changed +59
-8
lines changed Original file line number Diff line number Diff line change 1
1
use projectm_rs:: core:: { projectm, projectm_handle} ;
2
2
use sdl2:: video:: GLProfile ;
3
3
4
+ pub mod audio;
4
5
pub mod config;
5
6
pub mod main_loop;
6
7
pub mod playlist;
@@ -12,6 +13,7 @@ pub struct App {
12
13
sdl_context : sdl2:: Sdl ,
13
14
gl_context : sdl2:: video:: GLContext ,
14
15
window : sdl2:: video:: Window ,
16
+ config : config:: Config ,
15
17
}
16
18
17
19
pub fn default_config ( ) -> config:: Config {
@@ -53,26 +55,33 @@ impl App {
53
55
54
56
// initialize projectM
55
57
let pm = projectm:: create ( ) ;
58
+
56
59
// and a preset playlist
57
60
let playlist = projectm_rs:: playlist:: Playlist :: create ( pm) ;
58
61
59
62
// get/set window size
60
63
let ( width, height) = window. drawable_size ( ) ; // highDPI aware
61
64
projectm:: set_window_size ( pm, width. try_into ( ) . unwrap ( ) , height. try_into ( ) . unwrap ( ) ) ;
62
65
63
- let mut this = Self {
66
+ Self {
64
67
pm,
65
68
playlist,
66
69
sdl_context,
67
70
gl_context,
68
71
window,
69
- } ;
72
+ config : if let Some ( config) = config {
73
+ config
74
+ } else {
75
+ default_config ( )
76
+ } ,
77
+ }
78
+ }
70
79
80
+ pub fn init ( & mut self ) {
71
81
// read config
72
- if let Some ( config) = config {
73
- this. load_config ( config) ;
74
- }
82
+ self . load_config ( & self . config ) ;
75
83
76
- this
84
+ // initialize audio
85
+ let audio = audio:: Audio :: new ( & self ) ;
77
86
}
78
87
}
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 1
1
use crate :: app:: App ;
2
2
3
3
pub struct Config {
4
+ pub frame_rate : Option < u32 > ,
4
5
pub preset_path : Option < String > ,
5
6
}
6
7
@@ -10,14 +11,15 @@ impl Default for Config {
10
11
Self {
11
12
// load from home dir or w/e
12
13
preset_path : Some ( String :: from ( "/usr/local/share/projectM/presets" ) ) ,
14
+ frame_rate : Some ( 60 ) ,
13
15
}
14
16
}
15
17
}
16
18
17
19
impl App {
18
- pub fn load_config ( & mut self , config : Config ) {
20
+ pub fn load_config ( & mut self , config : & Config ) {
19
21
// load presets if provided
20
- if let Some ( preset_path) = config. preset_path {
22
+ if let Some ( preset_path) = & config. preset_path {
21
23
self . add_preset_path ( & preset_path) ;
22
24
}
23
25
}
You can’t perform that action at this time.
0 commit comments