diff --git a/doc/config b/doc/config index 0c24e7c9..01b2c014 100644 --- a/doc/config +++ b/doc/config @@ -89,6 +89,8 @@ # #visualizer_type = "wave" (spectrum/wave) # +#visualizer_look = "◆│" +# ##### system encoding ##### ## ## ncmpcpp should detect your charset encoding diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 9862ebbe..36630d63 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -99,6 +99,9 @@ Defines interval between syncing visualizer and audio outputs. .B visualizer_type = spectrum/wave Defines default visualizer type (spectrum is available only if ncmpcpp was compiled with fftw support). .TP +.B visualizer_look = STRING +Defines visualizer's look (string has to be exactly 2 characters long: first one is for wave whereas second for frequency spectrum). +.TP .B system_encoding = ENCODING If you use encoding other than utf8, set it in order to handle utf8 encoded strings properly. .TP diff --git a/src/settings.cpp b/src/settings.cpp index 3c59f108..ecb66934 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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 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()) diff --git a/src/settings.h b/src/settings.h index 6a84ead3..07f6fca9 100644 --- a/src/settings.h +++ b/src/settings.h @@ -174,6 +174,7 @@ struct NcmpcppConfig std::string new_header_second_line; std::string lastfm_preferred_language; std::basic_string progressbar; + std::basic_string visualizer_chars; std::string pattern; diff --git a/src/visualizer.cpp b/src/visualizer.cpp index e8903d11..6fa43a41 100644 --- a/src/visualizer.cpp +++ b/src/visualizer.cpp @@ -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::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