summaryrefslogtreecommitdiff
path: root/src/screens
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-13 23:32:13 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-13 23:58:24 +0100
commit9b49acba56ccc9839814ef7b223dba0ff8a74258 (patch)
tree33d38140057a77b1001b4ffb5c7dd15b1c7367fd /src/screens
parent261b23266de6d65fb8cbf2f02f85086134dcecf3 (diff)
Clear samples of the visualizer when playback is stopped
Diffstat (limited to 'src/screens')
-rw-r--r--src/screens/visualizer.cpp15
-rw-r--r--src/screens/visualizer.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/screens/visualizer.cpp b/src/screens/visualizer.cpp
index 1a146398..2470a4bf 100644
--- a/src/screens/visualizer.cpp
+++ b/src/screens/visualizer.cpp
@@ -90,10 +90,8 @@ Visualizer::Visualizer()
# endif // HAVE_FFTW3_H
if (Config.visualizer_in_stereo)
m_read_samples *= 2;
- m_sample_buffer.resize(m_read_samples);
- m_temp_sample_buffer.resize(m_read_samples);
- memset(m_sample_buffer.data(), 0, m_sample_buffer.size()*sizeof(int16_t));
- memset(m_temp_sample_buffer.data(), 0, m_sample_buffer.size()*sizeof(int16_t));
+ m_sample_buffer.resize(m_read_samples, 0);
+ m_temp_sample_buffer.resize(m_read_samples, 0);
# ifdef HAVE_FFTW3_H
m_fftw_results = DFT_TOTAL_SIZE/2+1;
@@ -110,12 +108,11 @@ Visualizer::Visualizer()
void Visualizer::switchTo()
{
SwitchTo::execute(this);
- w.clear();
+ Clear();
SetFD();
// negative infinity to toggle output in update() at least once
m_timer = boost::posix_time::neg_infin;
drawHeader();
- memset(m_sample_buffer.data(), 0, m_sample_buffer.size()*sizeof(int16_t));
# ifdef HAVE_FFTW3_H
GenLogspace();
m_bar_heights.reserve(w.getWidth());
@@ -639,6 +636,12 @@ void Visualizer::GenLogspace()
/**********************************************************************/
+void Visualizer::Clear()
+{
+ w.clear();
+ std::fill(m_sample_buffer.begin(), m_sample_buffer.end(), 0);
+}
+
void Visualizer::ToggleVisualizationType()
{
switch (Config.visualizer_type)
diff --git a/src/screens/visualizer.h b/src/screens/visualizer.h
index 7fb7aa56..2c658719 100644
--- a/src/screens/visualizer.h
+++ b/src/screens/visualizer.h
@@ -54,7 +54,7 @@ struct Visualizer: Screen<NC::Window>, Tabbable
virtual bool isLockable() override { return true; }
virtual bool isMergable() override { return true; }
- // private members
+ void Clear();
void ToggleVisualizationType();
void SetFD();
void ResetFD();