settings: make characters used in visualizer customizable
This commit is contained in:
@@ -375,6 +375,7 @@ void NcmpcppConfig::SetDefaults()
|
||||
new_header_second_line = "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
|
||||
browser_playlist_prefix << clRed << "(playlist)" << clEnd << ' ';
|
||||
progressbar = U("=>\0");
|
||||
visualizer_chars = U("◆│");
|
||||
pattern = "%n - %t";
|
||||
selected_item_prefix << clMagenta;
|
||||
selected_item_suffix << clEnd;
|
||||
@@ -907,6 +908,16 @@ void NcmpcppConfig::Read()
|
||||
// if two characters were specified, add third one as null
|
||||
progressbar.resize(3);
|
||||
}
|
||||
else if (name == "visualizer_look")
|
||||
{
|
||||
std::basic_string<my_char_t> vc = TO_WSTRING(v);
|
||||
if (vc.length() != 2)
|
||||
{
|
||||
std::cerr << "Warning: length of visualizer_look should be 2, but it's " << vc.length() << ", discarding.\n";
|
||||
}
|
||||
else
|
||||
visualizer_chars = vc;
|
||||
}
|
||||
else if (name == "default_tag_editor_pattern")
|
||||
{
|
||||
if (!v.empty())
|
||||
|
||||
@@ -174,6 +174,7 @@ struct NcmpcppConfig
|
||||
std::string new_header_second_line;
|
||||
std::string lastfm_preferred_language;
|
||||
std::basic_string<my_char_t> progressbar;
|
||||
std::basic_string<my_char_t> visualizer_chars;
|
||||
|
||||
std::string pattern;
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
||||
{
|
||||
const int samples_per_col = samples/w->GetWidth();
|
||||
const int half_height = height/2;
|
||||
*w << fmtAltCharset;
|
||||
double prev_point_pos = 0;
|
||||
const size_t win_width = w->GetWidth();
|
||||
for (size_t i = 0; i < win_width; ++i)
|
||||
@@ -173,7 +172,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
||||
point_pos /= samples_per_col;
|
||||
point_pos /= std::numeric_limits<int16_t>::max();
|
||||
point_pos *= half_height;
|
||||
*w << XY(i, y_offset+half_height+point_pos) << '`';
|
||||
*w << XY(i, y_offset+half_height+point_pos) << Config.visualizer_chars[0];
|
||||
if (i && abs(prev_point_pos-point_pos) > 2)
|
||||
{
|
||||
// if gap is too big. intermediate values are needed
|
||||
@@ -181,11 +180,10 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
||||
const int breakpoint = std::max(prev_point_pos, point_pos);
|
||||
const int half = (prev_point_pos+point_pos)/2;
|
||||
for (int k = std::min(prev_point_pos, point_pos)+1; k < breakpoint; k += 2)
|
||||
*w << XY(i-(k < half), y_offset+half_height+k) << '`';
|
||||
*w << XY(i-(k < half), y_offset+half_height+k) << Config.visualizer_chars[0];
|
||||
}
|
||||
prev_point_pos = point_pos;
|
||||
}
|
||||
*w << fmtAltCharsetEnd;
|
||||
}
|
||||
|
||||
#ifdef HAVE_FFTW3_H
|
||||
@@ -213,7 +211,10 @@ void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_o
|
||||
for (int j = 0; j < freqs_per_col; ++j)
|
||||
bar_height += itsFreqsMagnitude[i*freqs_per_col+j];
|
||||
bar_height = std::min(bar_height/freqs_per_col, height);
|
||||
mvwvline(w->Raw(), y_offset > 0 ? y_offset : height-bar_height, i, 0, bar_height);
|
||||
const size_t start_y = y_offset > 0 ? y_offset : height-bar_height;
|
||||
const size_t stop_y = std::min(bar_height+start_y, w->GetHeight());
|
||||
for (size_t j = start_y; j < stop_y; ++j)
|
||||
*w << XY(i, j) << Config.visualizer_chars[1];
|
||||
}
|
||||
}
|
||||
#endif // HAVE_FFTW3_H
|
||||
|
||||
Reference in New Issue
Block a user