@@ -5,10 +5,22 @@ pub type FrameRate = u32;
5
5
6
6
/// Configuration for the application
7
7
/// TODO: use config crate to support loading from env/CLI/file.
8
+ /// Parameters are defined here: https://github.com/projectM-visualizer/projectm/blob/master/src/api/include/projectM-4/parameters.h
8
9
pub struct Config {
10
+ /// Frame rate to render at. Defaults to 60.
9
11
pub frame_rate : Option < FrameRate > ,
12
+
13
+ /// Path to the preset directory. Defaults to /usr/local/share/projectM/presets
10
14
pub preset_path : Option < String > ,
15
+
16
+ /// Path to the texture directory. Defaults to /usr/local/share/projectM/textures
11
17
pub texture_path : Option < String > ,
18
+
19
+ /// How sensitive the beat detection is. 1.0 is default.
20
+ pub beat_sensitivity : Option < f32 > ,
21
+
22
+ /// How long to play a preset before switching to a new one (seconds).
23
+ pub preset_duration : Option < f64 > ,
12
24
}
13
25
14
26
impl Default for Config {
@@ -19,6 +31,8 @@ impl Default for Config {
19
31
preset_path : Some ( "/usr/local/share/projectM/presets" . to_owned ( ) ) ,
20
32
texture_path : Some ( "/usr/local/share/projectM/textures" . to_owned ( ) ) ,
21
33
frame_rate : Some ( 60 ) ,
34
+ beat_sensitivity : Some ( 1.0 ) ,
35
+ preset_duration : Some ( 10.0 ) ,
22
36
}
23
37
}
24
38
}
@@ -41,6 +55,16 @@ impl App {
41
55
paths. push ( texture_path. into ( ) ) ;
42
56
Projectm :: set_texture_search_paths ( self . pm , & paths, 1 ) ;
43
57
}
58
+
59
+ // set beat sensitivity if provided
60
+ if let Some ( beat_sensitivity) = config. beat_sensitivity {
61
+ Projectm :: set_beat_sensitivity ( self . pm , beat_sensitivity) ;
62
+ }
63
+
64
+ // set preset duration if provided
65
+ if let Some ( preset_duration) = config. preset_duration {
66
+ Projectm :: set_preset_duration ( self . pm , preset_duration) ;
67
+ }
44
68
}
45
69
46
70
pub fn get_frame_rate ( & self ) -> FrameRate {
0 commit comments