visualizer: scale automatically if multiplier is 1
This commit is contained in:
1
NEWS
1
NEWS
@@ -29,6 +29,7 @@ ncmpcpp-0.7 (????-??-??)
|
|||||||
* Support for selecting found items was added (bound to Ctrl-_ by default).
|
* Support for selecting found items was added (bound to Ctrl-_ by default).
|
||||||
* Tracks in media library are now properly sorted for track numbers greater than 99.
|
* Tracks in media library are now properly sorted for track numbers greater than 99.
|
||||||
* Value of 'visualizer_sync_interval' is now restricted to be greater than 9.
|
* Value of 'visualizer_sync_interval' is now restricted to be greater than 9.
|
||||||
|
* Output of the visualizer now scales automatically as long as 'visualizer_sample_multiplier' is set to 1.
|
||||||
|
|
||||||
ncmpcpp-0.6.5 (2015-07-05)
|
ncmpcpp-0.6.5 (2015-07-05)
|
||||||
|
|
||||||
|
|||||||
@@ -526,6 +526,9 @@ void Status::Changes::songID(int song_id)
|
|||||||
playing_song_scroll_begin = 0;
|
playing_song_scroll_begin = 0;
|
||||||
first_line_scroll_begin = 0;
|
first_line_scroll_begin = 0;
|
||||||
second_line_scroll_begin = 0;
|
second_line_scroll_begin = 0;
|
||||||
|
# ifdef ENABLE_VISUALIZER
|
||||||
|
myVisualizer->ResetAutoScaleMultiplier();
|
||||||
|
# endif // ENABLE_VISUALIZER
|
||||||
if (m_player_state != MPD::psStop)
|
if (m_player_state != MPD::psStop)
|
||||||
{
|
{
|
||||||
auto &pl = myPlaylist->main();
|
auto &pl = myPlaylist->main();
|
||||||
|
|||||||
@@ -148,8 +148,23 @@ void Visualizer::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ssize_t samples_read = data/sizeof(int16_t);
|
const ssize_t samples_read = data/sizeof(int16_t);
|
||||||
std::for_each(buf, buf+samples_read, [](int16_t &sample) {
|
if (Config.visualizer_sample_multiplier == 1.0)
|
||||||
int32_t tmp = sample * Config.visualizer_sample_multiplier;
|
{
|
||||||
|
m_auto_scale_multiplier += 1.0/fps;
|
||||||
|
std::for_each(buf, buf+samples_read, [this](int16_t &sample) {
|
||||||
|
double scale = std::numeric_limits<int16_t>::min();
|
||||||
|
scale /= sample;
|
||||||
|
scale = fabs(scale);
|
||||||
|
if (scale < m_auto_scale_multiplier)
|
||||||
|
m_auto_scale_multiplier = scale;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
std::for_each(buf, buf+samples_read, [this](int16_t &sample) {
|
||||||
|
int32_t tmp = sample;
|
||||||
|
if (Config.visualizer_sample_multiplier != 1.0)
|
||||||
|
tmp *= Config.visualizer_sample_multiplier;
|
||||||
|
else if (m_auto_scale_multiplier <= 50.0) // limit the auto scale
|
||||||
|
tmp *= m_auto_scale_multiplier;
|
||||||
if (tmp < std::numeric_limits<int16_t>::min())
|
if (tmp < std::numeric_limits<int16_t>::min())
|
||||||
sample = std::numeric_limits<int16_t>::min();
|
sample = std::numeric_limits<int16_t>::min();
|
||||||
else if (tmp > std::numeric_limits<int16_t>::max())
|
else if (tmp > std::numeric_limits<int16_t>::max())
|
||||||
@@ -474,6 +489,11 @@ void Visualizer::FindOutputID()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Visualizer::ResetAutoScaleMultiplier()
|
||||||
|
{
|
||||||
|
m_auto_scale_multiplier = std::numeric_limits<double>::infinity();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ENABLE_VISUALIZER
|
#endif // ENABLE_VISUALIZER
|
||||||
|
|
||||||
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */
|
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ struct Visualizer: Screen<NC::Window>, Tabbable
|
|||||||
void SetFD();
|
void SetFD();
|
||||||
void ResetFD();
|
void ResetFD();
|
||||||
void FindOutputID();
|
void FindOutputID();
|
||||||
|
void ResetAutoScaleMultiplier();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
||||||
@@ -78,6 +79,7 @@ private:
|
|||||||
|
|
||||||
int m_fifo;
|
int m_fifo;
|
||||||
size_t m_samples;
|
size_t m_samples;
|
||||||
|
double m_auto_scale_multiplier;
|
||||||
# ifdef HAVE_FFTW3_H
|
# ifdef HAVE_FFTW3_H
|
||||||
size_t m_fftw_results;
|
size_t m_fftw_results;
|
||||||
double *m_fftw_input;
|
double *m_fftw_input;
|
||||||
|
|||||||
Reference in New Issue
Block a user