1 /*
2  * VisConstants.h
3  *
4  * Created on: Jul 30, 2015
5  *     Author: dpayne
6  */
7 
8 #ifndef _VIS_CONSTANTS_H
9 #define _VIS_CONSTANTS_H
10 
11 #include <cstdlib>
12 #include <string>
13 #include <vector>
14 
15 #include "Domain/VisTypes.h"
16 #include "Writer/NcursesWriter.h"
17 
18 namespace VisConstants
19 {
20 
21 // max extended color values, assumes extended colors fit in signed shorts
22 static const int16_t k_max_extended_color = 2 << 13; // 16384
23 static const int16_t k_default_max_color = 256;
24 static const std::string k_disabled_gradient_color_config{"gradient=false"};
25 static const std::string k_enabled_gradient_color_config{"gradient=true"};
26 
27 // Various constants
28 static const std::string k_default_locale{"en_US.UTF8"};
29 static const wchar_t k_space_wchar{L' '};
30 static const wchar_t k_full_block_wchar{L'\u2588'};
31 static const wchar_t k_hash_wchar{L'#'};
32 
33 static const double k_pi = 3.14159265358979323846;
34 
35 static const std::string k_true{"true"};
36 static const std::string k_false{"false"};
37 static const std::string k_mpd_audio_source_name{"mpd"};
38 static const std::string k_osx_audio_source_name{"osx"};
39 static const std::string k_pulse_audio_source_name{"pulse"};
40 static const std::string k_default_visualizer_pulse_audio_source;
41 static const std::string k_spectrum_circle_visualizer_name{"spectrum_circle"};
42 static const std::string k_ellipse_visualizer_name{"ellipse"};
43 static const std::string k_lorenz_visualizer_name{"lorenz"};
44 static const int64_t k_default_visualizer_rotation_interval =
45     0L; // 0 means disabled
46 // Defaults
47 static const double k_default_scaling_multiplier = 1.0;
48 
49 static const uint32_t k_default_fps = 20;
50 
51 const static std::string k_default_audio_source{k_pulse_audio_source_name};
52 const static std::string k_default_mpd_fifo_path{"/tmp/mpd.fifo"};
53 const static std::string k_default_visualizers{"spectrum,ellipse,lorenz"};
54 
55 // visualizer names
56 static const std::string k_spectrum_visualizer_name{"spectrum"};
57 
58 // frequency defaults
59 static const uint32_t k_default_sampling_frequency = 44100;
60 static const uint32_t k_default_low_cutoff_frequency = 30;
61 static const uint32_t k_default_high_cutoff_frequency = 22050;
62 
63 // config path defaults
64 // XDG_CONFIG_HOME is usually "~/.config"
65 static const char *k_xdg_config_home{std::getenv("XDG_CONFIG_HOME")};
66 
67 // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
68 // use ${XDG_CONFIG_HOME}/vis/ as the default config directory
69 static const std::string k_default_config_path_root{
70     (k_xdg_config_home != nullptr
71          ? std::string{k_xdg_config_home}
72          : std::string{std::getenv("HOME")} + "/.config") +
73     "/vis/"};
74 static const std::string k_default_config_path =
75     k_default_config_path_root + "config";
76 static const std::string k_colors_directory{k_default_config_path_root +
77                                             "colors/"};
78 static const std::string k_default_log_path{k_default_config_path_root +
79                                             "vis.log"};
80 static const std::string k_default_colors_path{"colors"};
81 
82 // Default characters for visualizers
83 static const wchar_t k_default_spectrum_character{k_space_wchar};
84 static const wchar_t k_default_lorenz_character{k_full_block_wchar};
85 static const wchar_t k_default_ellipse_character{k_full_block_wchar};
86 static const wchar_t k_default_lorenz_character_osx{k_hash_wchar};
87 static const wchar_t k_default_ellipse_character_osx{k_hash_wchar};
88 
89 // ellipse defaults
90 static const uint32_t k_default_ellipse_radius{2};
91 
92 // monstercat smoothing defaults
93 static const double k_default_monstercat_smoothing_factor{1.5};
94 static const uint32_t k_default_monstercat_bar_width = 1;
95 static const uint32_t k_default_monstercat_bar_spacing = 0;
96 
97 // sgs smoothing defaults
98 static const uint32_t k_default_sgs_smoothing_points{
99     3}; // this should be an odd number
100 static const uint32_t k_default_sgs_smoothing_passes{2};
101 
102 // spectrum defaults
103 static const uint32_t k_default_spectrum_bar_width = 2;
104 static const uint32_t k_default_spectrum_bar_spacing = 1;
105 static const vis::SmoothingMode k_default_spectrum_smoothing_mode =
106     vis::SmoothingMode::Sgs;
107 static const vis::FalloffMode k_default_spectrum_falloff_mode =
108     vis::FalloffMode::Fill;
109 static const double k_default_spectrum_falloff_weight = 0.95;
110 static const double k_default_spectrum_top_margin = 0.0;
111 static const double k_default_spectrum_bottom_margin = 0.0;
112 static const double k_default_spectrum_right_margin = 0.0;
113 static const double k_default_spectrum_left_margin = 0.0;
114 
115 static const bool k_default_spectrum_reversed = false;
116 
117 // input timeouts
118 static const int64_t k_default_mpd_fifo_timeout = 1l;
119 static const int32_t k_default_user_input_timeout_milliseconds = 500;
120 static const uint64_t k_silent_sleep_milliseconds = 100ul;
121 
122 // 16 bit colorscheme
123 static const std::vector<vis::ColorDefinition> k_default_16_colors = {
124     vis::ColorDefinition{4, -1, -1, -1},  vis::ColorDefinition{12, -1, -1, -1},
125     vis::ColorDefinition{6, -1, -1, -1},  vis::ColorDefinition{14, -1, -1, -1},
126     vis::ColorDefinition{2, -1, -1, -1},  vis::ColorDefinition{10, -1, -1, -1},
127     vis::ColorDefinition{11, -1, -1, -1}, vis::ColorDefinition{3, -1, -1, -1},
128     vis::ColorDefinition{5, -1, -1, -1},  vis::ColorDefinition{1, -1, -1, -1},
129     vis::ColorDefinition{13, -1, -1, -1}, vis::ColorDefinition{9, -1, -1, -1},
130     vis::ColorDefinition{7, -1, -1, -1},  vis::ColorDefinition{15, -1, -1, -1},
131     vis::ColorDefinition{0, -1, -1, -1},
132 };
133 
134 // 8 bit colorscheme
135 static const std::vector<vis::ColorDefinition> k_default_8_colors = {
136     vis::ColorDefinition{4, -1, -1, -1}, vis::ColorDefinition{6, -1, -1, -1},
137     vis::ColorDefinition{2, -1, -1, -1}, vis::ColorDefinition{3, -1, -1, -1},
138     vis::ColorDefinition{5, -1, -1, -1}, vis::ColorDefinition{1, -1, -1, -1},
139     vis::ColorDefinition{7, -1, -1, -1}, vis::ColorDefinition{0, -1, -1, -1}};
140 } // namespace VisConstants
141 
142 #endif
143