aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 0be1d094b4623f7df87f4c7dd87bff353c9c25e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use directories::{ProjectDirs, UserDirs};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct Config {
    pub music_roots: Vec<String>,
    pub audio_exts: Vec<String>,
    pub skip_window_secs: u64,
    pub learning_rate: f32,
    pub decay_rate: f32,
    pub min_score_thresh: f32,
    pub temperature: f32,
}

pub fn default_state_path() -> String {
    ProjectDirs::from("qualifier", "organisation", "mood")
        .and_then(|pd| {
            pd.config_dir()
                .join("mood.ron")
                .to_str()
                .map(|x| x.to_string())
        })
        .unwrap_or("~/.config/mood/mood.ron".to_string())
}

impl Default for Config {
    fn default() -> Config {
        Config {
            music_roots: vec![
                UserDirs::new()
                    .and_then(|u| {
                        u.audio_dir()
                            .and_then(|p| p.to_str().map(|x| x.to_string()))
                    })
                    .unwrap_or("~/Music".to_string()),
            ],
            audio_exts: [".mp3", ".flac", ".wav", ".m4a", ".ogg", ".vorbis"]
                .into_iter()
                .map(String::from)
                .collect(),
            skip_window_secs: 60,
            learning_rate: 0.1,
            decay_rate: 0.001,
            min_score_thresh: 1e-5,
            temperature: 0.6,
        }
    }
}