1 #pragma once
2 
3 #include "preferences/usersettings.h"
4 
5 #define VAMP_CONFIG_KEY "[Vamp]"
6 
7 // VAMP_CONFIG_KEY Preferences. WARNING: Do not fix the "analyser" spelling here
8 // since user config files contain these.
9 #define VAMP_ANALYZER_BEAT_LIBRARY "AnalyserBeatLibrary"
10 #define VAMP_ANALYZER_BEAT_PLUGIN_ID "AnalyserBeatPluginID"
11 
12 #define BPM_CONFIG_KEY "[BPM]"
13 
14 // BPM_CONFIG_KEY Preferences
15 #define BPM_DETECTION_ENABLED "BPMDetectionEnabled"
16 #define BPM_FIXED_TEMPO_ASSUMPTION "BeatDetectionFixedTempoAssumption"
17 #define BPM_REANALYZE_WHEN_SETTINGS_CHANGE "ReanalyzeWhenSettingsChange"
18 #define BPM_REANALYZE_IMPORTED "ReanalyzeImported"
19 #define BPM_FAST_ANALYSIS_ENABLED "FastAnalysisEnabled"
20 
21 class BeatDetectionSettings {
22   public:
BeatDetectionSettings(UserSettingsPointer pConfig)23     BeatDetectionSettings(UserSettingsPointer pConfig) : m_pConfig(pConfig) {}
24 
25     DEFINE_PREFERENCE_HELPERS(BpmDetectionEnabled, bool,
26                               BPM_CONFIG_KEY, BPM_DETECTION_ENABLED, true);
27 
28     DEFINE_PREFERENCE_HELPERS(FixedTempoAssumption, bool,
29                               BPM_CONFIG_KEY, BPM_FIXED_TEMPO_ASSUMPTION, true);
30 
31     DEFINE_PREFERENCE_HELPERS(ReanalyzeWhenSettingsChange, bool,
32                               BPM_CONFIG_KEY, BPM_REANALYZE_WHEN_SETTINGS_CHANGE, false);
33 
34     DEFINE_PREFERENCE_HELPERS(ReanalyzeImported, bool, BPM_CONFIG_KEY, BPM_REANALYZE_WHEN_SETTINGS_CHANGE, false);
35 
36     DEFINE_PREFERENCE_HELPERS(FastAnalysis, bool,
37                               BPM_CONFIG_KEY, BPM_FAST_ANALYSIS_ENABLED, false);
38 
getBeatPluginId()39     QString getBeatPluginId() const {
40         return m_pConfig->getValue<QString>(ConfigKey(
41                 VAMP_CONFIG_KEY, VAMP_ANALYZER_BEAT_PLUGIN_ID));
42     }
setBeatPluginId(const QString & plugin_id)43     void setBeatPluginId(const QString& plugin_id) {
44         m_pConfig->setValue(
45                 ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_BEAT_PLUGIN_ID),
46                 plugin_id);
47     }
48 
49   private:
50     UserSettingsPointer m_pConfig;
51 };
52