summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-14 14:19:19 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-14 14:19:19 +0100
commitb602b198cd7766c8293af25ef089664848d3b9f2 (patch)
tree61d76db0782782291dea3de90c10d2afd83a743a /src
parentb8983b93eca707cafe5630962f7035775ebbae31 (diff)
Make fps of the visualizer configurable and set it to 60 by default
Diffstat (limited to 'src')
-rw-r--r--src/screens/visualizer.cpp11
-rw-r--r--src/settings.cpp10
-rw-r--r--src/settings.h1
3 files changed, 14 insertions, 8 deletions
diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp
index ea28d0b2..b8ef20c3 100644
--- a/src/screens/visualizer.cpp
+++ b/src/screens/visualizer.cpp
@@ -52,7 +52,6 @@ Visualizer *myVisualizer;
namespace {
-const size_t fps = 30;
const uint32_t MIN_DFT_SIZE = 14;
// toColor: a scaling function for coloring. For numbers 0 to max this function
@@ -159,7 +158,7 @@ void Visualizer::update()
if (Config.visualizer_autoscale)
{
- m_auto_scale_multiplier += 1.0/fps;
+ m_auto_scale_multiplier += 1.0/Config.visualizer_fps;
for (auto &sample : m_sample_buffer)
{
double scale = std::numeric_limits<int16_t>::min();
@@ -206,7 +205,7 @@ void Visualizer::update()
int Visualizer::windowTimeout()
{
if (m_fifo >= 0 && Status::State::player() == MPD::psPlay)
- return 1000/fps;
+ return 1000/Config.visualizer_fps;
else
return Screen<WindowType>::windowTimeout();
}
@@ -599,12 +598,12 @@ void Visualizer::SetVisualizationType()
switch (Config.visualizer_type)
{
case VisualizerType::Wave:
- m_read_samples = std::max(44100 / fps, w.getWidth());
+ m_read_samples = std::max(44100 / Config.visualizer_fps, w.getWidth());
draw = &Visualizer::DrawSoundWave;
drawStereo = &Visualizer::DrawSoundWaveStereo;
break;
case VisualizerType::WaveFilled:
- m_read_samples = std::max(44100 / fps, w.getWidth());
+ m_read_samples = std::max(44100 / Config.visualizer_fps, w.getWidth());
draw = &Visualizer::DrawSoundWaveFill;
drawStereo = &Visualizer::DrawSoundWaveFillStereo;
break;
@@ -616,7 +615,7 @@ void Visualizer::SetVisualizationType()
break;
# endif // HAVE_FFTW3_H
case VisualizerType::Ellipse:
- m_read_samples = 44100 / fps;
+ m_read_samples = 44100 / Config.visualizer_fps;
draw = &Visualizer::DrawSoundEllipse;
drawStereo = &Visualizer::DrawSoundEllipseStereo;
break;
diff --git a/src/settings.cpp b/src/settings.cpp
index 177a38cb..30efb500 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -293,12 +293,18 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
boundsCheck<std::wstring::size_type>(result.size(), 2, 2);
return result;
});
+ p.add("visualizer_fps", &visualizer_fps,
+ "60", [](std::string v) {
+ uint32_t result = verbose_lexical_cast<uint32_t>(v);
+ boundsCheck<uint32_t>(result, 30, 144);
+ return result;
+ });
p.add("visualizer_autoscale", &visualizer_autoscale, "no", yes_no);
p.add("visualizer_spectrum_smooth_look", &visualizer_spectrum_smooth_look, "yes", yes_no);
p.add("visualizer_spectrum_dft_size", &visualizer_spectrum_dft_size,
"3", [](std::string v) {
- uint32_t result = verbose_lexical_cast<uint32_t>(v);
- boundsCheck<uint32_t>(result, 1, 5);
+ auto result = verbose_lexical_cast<size_t>(v);
+ boundsCheck<size_t>(result, 1, 5);
return result + 11;
});
p.add("visualizer_spectrum_gain", &visualizer_spectrum_gain,
diff --git a/src/settings.h b/src/settings.h
index c171a9b1..a3f923ce 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -82,6 +82,7 @@ struct Configuration
std::string lastfm_preferred_language;
std::wstring progressbar;
std::wstring visualizer_chars;
+ size_t visualizer_fps;
bool visualizer_autoscale;
bool visualizer_spectrum_smooth_look;
uint32_t visualizer_spectrum_dft_size;