make sound wave the default visualization and fftw optional dependency
This commit is contained in:
25
configure.in
25
configure.in
@@ -14,6 +14,7 @@ AC_ARG_ENABLE(visualizer, AS_HELP_STRING([--enable-visualizer], [Enable music vi
|
||||
AC_ARG_ENABLE(clock, AS_HELP_STRING([--enable-clock], [Enable clock screen @<:@default=no@:>@]), [clock=$enableval], [clock=no])
|
||||
AC_ARG_ENABLE(unicode, AS_HELP_STRING([--enable-unicode], [Enable utf8 support @<:@default=yes@:>@]), [unicode=$enableval], [unicode=yes])
|
||||
AC_ARG_WITH(curl, AS_HELP_STRING([--with-curl], [Enable fetching lyrics from the Internet @<:@default=auto@:>@]), [curl=$withval], [curl=auto])
|
||||
AC_ARG_WITH(fftw, AS_HELP_STRING([--with-fftw], [Enable fftw support (required for frequency spectrum vizualization) @<:@default=auto@:>@]), [fftw=$withval], [fftw=auto])
|
||||
AC_ARG_WITH(iconv, AS_HELP_STRING([--with-iconv], [Enable iconv support (Note: if you use utf-8 system wide, you can disable this) @<:@default=auto@:>@]), [iconv=$withval], [iconv=auto])
|
||||
AC_ARG_WITH(pdcurses, AS_HELP_STRING([--with-pdcurses[=LIBNAME]], [Link against pdcurses instead of ncurses @<:@default=XCurses@:>@]), [pdcurses=$withval], [pdcurses=no])
|
||||
AC_ARG_WITH(threads, AS_HELP_STRING([--with-threads], [Enable threading support using posix threads @<:@default=auto@:>@]), [threads=$withval], [threads=auto])
|
||||
@@ -93,12 +94,24 @@ dnl ======================
|
||||
dnl = checking for fftw3 =
|
||||
dnl ======================
|
||||
if test "$visualizer" = "yes" ; then
|
||||
PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], , AC_MSG_ERROR([fftw3 library is required!]))
|
||||
AC_SUBST(fftw3_LIBS)
|
||||
AC_SUBST(fftw3_CFLAGS)
|
||||
CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
|
||||
LDFLAGS="$LDFLAGS $fftw3_LIBS"
|
||||
AC_CHECK_HEADERS([fftw3.h], , AC_MSG_ERROR([missing fftw3.h header]))
|
||||
if test "$fftw" != "no" ; then
|
||||
PKG_CHECK_MODULES([fftw3], [fftw3 >= 3], [
|
||||
AC_SUBST(fftw3_LIBS)
|
||||
AC_SUBST(fftw3_CFLAGS)
|
||||
CPPFLAGS="$CPPFLAGS $fftw3_CFLAGS"
|
||||
AC_CHECK_HEADERS([fftw3.h],
|
||||
LDFLAGS="$LDFLAGS $fftw3_LIBS"
|
||||
,
|
||||
if test "$fftw" = "yes" ; then
|
||||
AC_MSG_ERROR([missing fftw3.h header])
|
||||
fi
|
||||
)
|
||||
],
|
||||
if test "$fftw" = "yes" ; then
|
||||
AC_MSG_ERROR([fftw3 library is required!])
|
||||
fi
|
||||
)
|
||||
fi
|
||||
AC_DEFINE([ENABLE_VISUALIZER], [1], [enables music visualizer screen])
|
||||
fi
|
||||
|
||||
|
||||
@@ -34,7 +34,12 @@
|
||||
#
|
||||
#visualizer_fifo_path = ""
|
||||
#
|
||||
#visualizer_type = "spectrum" (spectrum/wave)
|
||||
##
|
||||
## Note: To enable spectrum frequency visualization
|
||||
## you need to compile ncmpcpp with fftw3 support.
|
||||
##
|
||||
#
|
||||
#visualizer_type = "wave" (spectrum/wave)
|
||||
#
|
||||
##### system encoding #####
|
||||
##
|
||||
|
||||
@@ -70,7 +70,7 @@ Default number of seconds to crossfade, if enabled by ncmpcpp.
|
||||
Path to mpd fifo output. This is needed to make music visualizer work (note that output sound format of this fifo has to be 44100:16:1)
|
||||
.TP
|
||||
.B visualizer_type = spectrum/wave
|
||||
Defines default visualizer type.
|
||||
Defines default visualizer type (spectrum is available only if ncmpcpp was compiled with fftw support).
|
||||
.TP
|
||||
.B system_encoding = ENCODING
|
||||
If you use encoding other than utf8, set it in order to handle utf8 encoded strings properly.
|
||||
|
||||
@@ -298,10 +298,10 @@ void Help::GetKeybindings()
|
||||
# endif // ENABLE_OUTPUTS
|
||||
|
||||
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
# if defined(ENABLE_VISUALIZER) && defined(HAVE_FFTW3_H)
|
||||
*w << "\n\n " << fmtBold << "Keys - Music visualizer\n -----------------------------------------\n" << fmtBoldEnd;
|
||||
*w << DisplayKeys(Key.Space) << "Toggle visualization type\n";
|
||||
# endif // ENABLE_VISUALIZER
|
||||
# endif // ENABLE_VISUALIZER && HAVE_FFTW3_H
|
||||
|
||||
|
||||
*w << "\n\n " << fmtBold << "Mouse - Global\n -----------------------------------------\n" << fmtBoldEnd;
|
||||
|
||||
@@ -306,7 +306,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.ask_before_clearing_main_playlist = false;
|
||||
conf.mouse_support = true;
|
||||
conf.new_design = false;
|
||||
conf.visualizer_use_wave = false;
|
||||
conf.visualizer_use_wave = true;
|
||||
conf.set_window_title = true;
|
||||
conf.mpd_port = 6600;
|
||||
conf.mpd_connection_timeout = 15;
|
||||
|
||||
@@ -37,7 +37,9 @@ using Global::MainHeight;
|
||||
Visualizer *myVisualizer = new Visualizer;
|
||||
|
||||
const unsigned Visualizer::Samples = 2048;
|
||||
#ifdef HAVE_FFTW3_H
|
||||
const unsigned Visualizer::FFTResults = Samples/2+1;
|
||||
#endif // HAVE_FFTW3_H
|
||||
|
||||
void Visualizer::Init()
|
||||
{
|
||||
@@ -45,10 +47,12 @@ void Visualizer::Init()
|
||||
w->SetTimeout(Config.visualizer_fifo_path.empty() ? ncmpcpp_window_timeout : 40 /* this gives us 25 fps */);
|
||||
|
||||
ResetFD();
|
||||
# ifdef HAVE_FFTW3_H
|
||||
itsFreqsMagnitude = new unsigned[FFTResults];
|
||||
itsInput = static_cast<double *>(fftw_malloc(sizeof(double)*Samples));
|
||||
itsOutput = static_cast<fftw_complex *>(fftw_malloc(sizeof(fftw_complex)*FFTResults));
|
||||
itsPlan = fftw_plan_dft_r2c_1d(Samples, itsInput, itsOutput, FFTW_ESTIMATE);
|
||||
# endif // HAVE_FFTW3_H
|
||||
|
||||
isInitialized = 1;
|
||||
}
|
||||
@@ -103,14 +107,20 @@ void Visualizer::Update()
|
||||
return;
|
||||
|
||||
w->Clear(0);
|
||||
# ifdef HAVE_FFTW3_H
|
||||
Config.visualizer_use_wave ? DrawSoundWave(buf, data) : DrawFrequencySpectrum(buf, data);
|
||||
# else
|
||||
DrawSoundWave(buf, data);
|
||||
# endif // HAVE_FFTW3_H
|
||||
w->Refresh();
|
||||
}
|
||||
|
||||
void Visualizer::SpacePressed()
|
||||
{
|
||||
# ifdef HAVE_FFTW3_H
|
||||
Config.visualizer_use_wave = !Config.visualizer_use_wave;
|
||||
ShowMessage("Visualization type: %s", Config.visualizer_use_wave ? "Sound wave" : "Frequency spectrum");
|
||||
# endif // HAVE_FFTW3_H
|
||||
}
|
||||
|
||||
void Visualizer::DrawSoundWave(int16_t *buf, ssize_t data)
|
||||
@@ -142,6 +152,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t data)
|
||||
*w << fmtAltCharsetEnd;
|
||||
}
|
||||
|
||||
#ifdef HAVE_FFTW3_H
|
||||
void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t data)
|
||||
{
|
||||
// zero old values
|
||||
@@ -165,6 +176,7 @@ void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t data)
|
||||
mvwvline(w->Raw(), MainHeight-bar_height, i, 0, bar_height);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_FFTW3_H
|
||||
|
||||
void Visualizer::SetFD()
|
||||
{
|
||||
|
||||
@@ -59,16 +59,23 @@ class Visualizer : public Screen<Window>
|
||||
|
||||
private:
|
||||
void DrawSoundWave(int16_t *, ssize_t);
|
||||
# ifdef HAVE_FFTW3_H
|
||||
void DrawFrequencySpectrum(int16_t *, ssize_t);
|
||||
# endif // HAVE_FFTW3_H
|
||||
|
||||
int itsFifo;
|
||||
# ifdef HAVE_FFTW3_H
|
||||
unsigned *itsFreqsMagnitude;
|
||||
double *itsInput;
|
||||
fftw_complex *itsOutput;
|
||||
fftw_plan itsPlan;
|
||||
# endif // HAVE_FFTW3_H
|
||||
|
||||
static const unsigned Samples;
|
||||
# ifdef HAVE_FFTW3_H
|
||||
static const unsigned FFTResults;
|
||||
# endif // HAVE_FFTW3_H
|
||||
|
||||
};
|
||||
|
||||
extern Visualizer *myVisualizer;
|
||||
|
||||
Reference in New Issue
Block a user