Skip to content

Commit 58856fb

Browse files
committed
more configs
1 parent 624ec61 commit 58856fb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/app/config.rs

+24
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@ pub type FrameRate = u32;
55

66
/// Configuration for the application
77
/// 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
89
pub struct Config {
10+
/// Frame rate to render at. Defaults to 60.
911
pub frame_rate: Option<FrameRate>,
12+
13+
/// Path to the preset directory. Defaults to /usr/local/share/projectM/presets
1014
pub preset_path: Option<String>,
15+
16+
/// Path to the texture directory. Defaults to /usr/local/share/projectM/textures
1117
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>,
1224
}
1325

1426
impl Default for Config {
@@ -19,6 +31,8 @@ impl Default for Config {
1931
preset_path: Some("/usr/local/share/projectM/presets".to_owned()),
2032
texture_path: Some("/usr/local/share/projectM/textures".to_owned()),
2133
frame_rate: Some(60),
34+
beat_sensitivity: Some(1.0),
35+
preset_duration: Some(10.0),
2236
}
2337
}
2438
}
@@ -41,6 +55,16 @@ impl App {
4155
paths.push(texture_path.into());
4256
Projectm::set_texture_search_paths(self.pm, &paths, 1);
4357
}
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+
}
4468
}
4569

4670
pub fn get_frame_rate(&self) -> FrameRate {

0 commit comments

Comments
 (0)