Skip to content

Commit

Permalink
Add visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Jul 9, 2024
1 parent 8327751 commit 2677346
Show file tree
Hide file tree
Showing 30 changed files with 2,220 additions and 10 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
libchromaprint-devel
fftw3-devel
libebur128-devel
projectM-devel
desktop-file-utils
update-desktop-files
appstream-glib
Expand All @@ -85,6 +86,7 @@ jobs:
libQt5Network-devel
libQt5Sql-devel
libQt5DBus-devel
libQt5OpenGL-devel
libQt5Test-devel
libqt5-qtbase-common-devel
libQt5Sql5-sqlite
Expand All @@ -105,6 +107,7 @@ jobs:
qt6-base-common-devel
qt6-sql-sqlite
qt6-linguist-devel
qt6-opengl-devel
- name: Install tagparser
if: matrix.opensuse_version == 'tumbleweed'
run: zypper -n --gpg-auto-import-keys in tagparser-devel
Expand Down Expand Up @@ -219,6 +222,7 @@ jobs:
libchromaprint-devel
libebur128-devel
fftw-devel
libprojectM-devel
desktop-file-utils
libappstream-glib
hicolor-icon-theme
Expand Down Expand Up @@ -310,6 +314,7 @@ jobs:
lib64Qt6DBus-devel
lib64Qt6Gui-devel
lib64Qt6Widgets-devel
lib64Qt6OpenGL-devel
lib64Qt6Test-devel
qt6-cmake
qt6-qtbase-tools
Expand Down Expand Up @@ -406,6 +411,7 @@ jobs:
lib64fftw-devel
lib64dbus-devel
lib64appstream-devel
lib64projectm-devel
lib64qt6core-devel
lib64qt6gui-devel
lib64qt6widgets-devel
Expand All @@ -415,6 +421,7 @@ jobs:
lib64qt6dbus-devel
lib64qt6help-devel
lib64qt6test-devel
lib64qt6opengl-devel
protobuf-compiler
desktop-file-utils
appstream-util
Expand Down Expand Up @@ -505,11 +512,12 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libprojectm-dev
- name: Install Qt 5
if: matrix.debian_version == 'bullseye'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev libqt5opengl5-dev
- name: Install Qt 6
if: matrix.debian_version != 'bullseye'
env:
Expand Down Expand Up @@ -592,11 +600,12 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libprojectm-dev
- name: Install Qt 5
if: matrix.ubuntu_version == 'focal'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev libqt5opengl5-dev
- name: Install Qt 6
if: matrix.ubuntu_version != 'focal'
env:
Expand Down Expand Up @@ -678,6 +687,7 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libprojectm-dev
gstreamer1.0-alsa
gstreamer1.0-pulseaudio
protobuf-compiler
Expand All @@ -690,7 +700,7 @@ jobs:
if: matrix.ubuntu_version == 'focal'
env:
DEBIAN_FRONTEND: noninteractive
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev
run: apt install -y qtbase5-dev qtbase5-dev-tools qttools5-dev qttools5-dev-tools libqt5x11extras5-dev libqt5opengl5-dev
- name: Install Qt 6
if: matrix.ubuntu_version != 'focal'
env:
Expand Down
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ pkg_check_modules(LIBMTP libmtp>=1.0)
pkg_check_modules(GDK_PIXBUF gdk-pixbuf-2.0)
find_package(Gettext)
find_package(FFTW3)
find_package(projectM4 COMPONENTS Playlist)
if(projectM4_FOUND)
set(LIBPROJECTM_FOUND ON)
set(HAVE_PROJECTM4 ON)
set(LIBPROJECTM_LIBRARIES libprojectM::projectM libprojectM::playlist)
else()
pkg_check_modules(LIBPROJECTM libprojectM)
endif()
find_package(GTest)
find_library(GMOCK_LIBRARY gmock)

Expand Down Expand Up @@ -185,6 +193,11 @@ endif()
if(X11_FOUND AND QT_VERSION_MAJOR EQUAL 5)
list(APPEND QT_COMPONENTS X11Extras)
endif()
if(QT_VERSION_MAJOR EQUAL 5)
list(APPEND QT_OPTIONAL_COMPONENTS OpenGL)
else()
list(APPEND QT_OPTIONAL_COMPONENTS OpenGLWidgets)
endif()

find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED OPTIONAL_COMPONENTS ${QT_OPTIONAL_COMPONENTS})

Expand Down Expand Up @@ -449,6 +462,20 @@ optional_component(EBUR128 ON "EBU R 128 loudness normalization"
DEPENDS "gstreamer" HAVE_GSTREAMER
)

if(QT_VERSION_MAJOR EQUAL 5)
optional_component(VISUALIZATIONS ON "Visualizations"
DEPENDS "libprojectm" LIBPROJECTM_FOUND
DEPENDS "QtOpenGL" Qt${QT_VERSION_MAJOR}OpenGL_FOUND
DEPENDS "gstreamer" HAVE_GSTREAMER
)
else()
optional_component(VISUALIZATIONS ON "Visualizations"
DEPENDS "libprojectm" LIBPROJECTM_FOUND
DEPENDS "QtOpenGLWidgets" Qt${QT_VERSION_MAJOR}OpenGLWidgets_FOUND
DEPENDS "gstreamer" HAVE_GSTREAMER
)
endif()

if(APPLE OR WIN32)
set(USE_BUNDLE_DEFAULT ON)
else()
Expand Down
2 changes: 1 addition & 1 deletion debian/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(LSB_RELEASE_EXEC AND DPKG_BUILDPACKAGE)
if(DEB_CODENAME AND DEB_DATE)

if(QT_VERSION_MAJOR EQUAL 5)
set(DEBIAN_BUILD_DEPENDS_QT_PACKAGES qtbase5-dev,qtbase5-dev-tools,qttools5-dev,qttools5-dev-tools,libqt5x11extras5-dev)
set(DEBIAN_BUILD_DEPENDS_QT_PACKAGES qtbase5-dev,qtbase5-dev-tools,qttools5-dev,qttools5-dev-tools,libqt5x11extras5-dev,libqt5opengl5-dev)
set(DEBIAN_DEPENDS_QT_PACKAGES libqt5sql5-sqlite)
endif()
if(QT_VERSION_MAJOR EQUAL 6)
Expand Down
3 changes: 2 additions & 1 deletion debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Build-Depends: debhelper (>= 11),
libmtp-dev,
libchromaprint-dev,
libfftw3-dev,
libebur128-dev
libebur128-dev,
libprojectm-dev
Standards-Version: 4.6.1

Package: strawberry
Expand Down
1 change: 1 addition & 0 deletions dist/unix/strawberry.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ BuildRequires: pkgconfig(taglib)
BuildRequires: pkgconfig(fftw3)
BuildRequires: pkgconfig(icu-uc)
BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(libprojectM)
BuildRequires: cmake(Qt@QT_VERSION_MAJOR@Core)
BuildRequires: cmake(Qt@QT_VERSION_MAJOR@Concurrent)
BuildRequires: cmake(Qt@QT_VERSION_MAJOR@Network)
Expand Down
38 changes: 38 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,27 @@ optional_source(HAVE_EBUR128
SOURCES engine/ebur128analysis.cpp
)

# Visualizations
optional_source(HAVE_VISUALIZATIONS
SOURCES
visualizations/projectmpresetmodel.cpp
visualizations/projectmvisualization.cpp
visualizations/visualizationcontainer.cpp
visualizations/visualizationoverlay.cpp
visualizations/visualizationselector.cpp
visualizations/visualizationopenglwidget.cpp
HEADERS
visualizations/projectmpresetmodel.h
visualizations/projectmvisualization.h
visualizations/visualizationcontainer.h
visualizations/visualizationoverlay.h
visualizations/visualizationselector.h
visualizations/visualizationopenglwidget.h
UI
visualizations/visualizationoverlay.ui
visualizations/visualizationselector.ui
)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)

Expand Down Expand Up @@ -1089,6 +1110,10 @@ if(HAVE_QTSPARKLE)
link_directories(${QTSPARKLE_LIBRARY_DIRS})
endif()

if(HAVE_VISUALIZATIONS)
link_directories(${LIBPROJECTM_LIBRARY_DIRS})
endif()

add_library(strawberry_lib STATIC
${SOURCES}
${MOC}
Expand Down Expand Up @@ -1149,6 +1174,14 @@ if(HAVE_X11_GLOBALSHORTCUTS AND HAVE_X11EXTRAS)
target_link_libraries(strawberry_lib PUBLIC Qt${QT_VERSION_MAJOR}::X11Extras)
endif()

if(HAVE_VISUALIZATIONS)
if(QT_VERSION_MAJOR EQUAL 5)
target_link_libraries(strawberry_lib PUBLIC Qt${QT_VERSION_MAJOR}::OpenGL)
else()
target_link_libraries(strawberry_lib PUBLIC Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
endif()
endif()

if(HAVE_ALSA)
target_include_directories(strawberry_lib SYSTEM PRIVATE ${ALSA_INCLUDE_DIRS})
target_link_libraries(strawberry_lib PRIVATE ${ALSA_LIBRARIES})
Expand Down Expand Up @@ -1231,6 +1264,11 @@ if(HAVE_LIBMTP)
target_link_libraries(strawberry_lib PRIVATE ${LIBMTP_LIBRARIES})
endif()

if(HAVE_VISUALIZATIONS)
target_include_directories(strawberry_lib SYSTEM PRIVATE ${LIBPROJECTM_INCLUDE_DIRS})
target_link_libraries(strawberry_lib PRIVATE ${LIBPROJECTM_LIBRARIES})
endif()

if(APPLE)
target_link_libraries(strawberry_lib PRIVATE
"-framework AppKit"
Expand Down
21 changes: 20 additions & 1 deletion src/analyzer/analyzercontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
double_click_timer_(new QTimer(this)),
ignore_next_click_(false),
current_analyzer_(nullptr),
engine_(nullptr) {
engine_(nullptr),
action_visualization_(nullptr) {

QHBoxLayout *layout = new QHBoxLayout(this);
setLayout(layout);
Expand Down Expand Up @@ -125,6 +126,17 @@ void AnalyzerContainer::mouseReleaseEvent(QMouseEvent *e) {

}

void AnalyzerContainer::mouseDoubleClickEvent(QMouseEvent *e) {

Q_UNUSED(e);

double_click_timer_->stop();
ignore_next_click_ = true;

if (action_visualization_) action_visualization_->trigger();

}

void AnalyzerContainer::ShowPopupMenu() {
context_menu_->popup(last_click_pos_);
}
Expand Down Expand Up @@ -247,3 +259,10 @@ void AnalyzerContainer::AddFramerate(const QString &name, const int framerate) {
QObject::connect(action, &QAction::triggered, this, [this, framerate]() { ChangeFramerate(framerate); } );

}

void AnalyzerContainer::SetVisualizationsAction(QAction *visualization) {

action_visualization_ = visualization;
context_menu_->addAction(action_visualization_);

}
4 changes: 4 additions & 0 deletions src/analyzer/analyzercontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AnalyzerContainer : public QWidget {
explicit AnalyzerContainer(QWidget *parent);

void SetEngine(SharedPtr<EngineBase> engine);
void SetVisualizationsAction(QAction *visualization);

static const char *kSettingsGroup;
static const char *kSettingsFramerate;
Expand All @@ -55,6 +56,7 @@ class AnalyzerContainer : public QWidget {

protected:
void mouseReleaseEvent(QMouseEvent *e) override;
void mouseDoubleClickEvent(QMouseEvent *e) override;
void wheelEvent(QWheelEvent *e) override;

private slots:
Expand Down Expand Up @@ -89,6 +91,8 @@ class AnalyzerContainer : public QWidget {

AnalyzerBase *current_analyzer_;
SharedPtr<EngineBase> engine_;

QAction *action_visualization_;
};

template<typename T>
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@

#cmakedefine HAVE_EBUR128

#cmakedefine HAVE_VISUALIZATIONS
#cmakedefine HAVE_PROJECTM4

#endif // CONFIG_H_IN
33 changes: 33 additions & 0 deletions src/core/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@

#include "organize/organizeerrordialog.h"

#ifdef HAVE_VISUALIZATIONS
# include "visualizations/visualizationcontainer.h"
# include "engine/gstengine.h"
#endif

#ifdef Q_OS_WIN
# include "windows7thumbbar.h"
#endif
Expand Down Expand Up @@ -594,6 +599,12 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
stop_menu->addAction(ui_->action_stop_after_this_track);
ui_->stop_button->setMenu(stop_menu);

#ifdef HAVE_VISUALIZATIONS
QObject::connect(ui_->action_visualizations, &QAction::triggered, this, &MainWindow::ShowVisualizations);
#else
ui_->action_visualizations->setEnabled(false);
#endif

// Player connections
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, &*app_->player(), &Player::SetVolumeFromSlider);

Expand Down Expand Up @@ -859,6 +870,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS

// Analyzer
QObject::connect(ui_->analyzer, &AnalyzerContainer::WheelEvent, this, &MainWindow::VolumeWheelEvent);
ui_->analyzer->SetVisualizationsAction(ui_->action_visualizations);

// Statusbar widgets
ui_->playlist_summary->setMinimumWidth(QFontMetrics(font()).horizontalAdvance(QStringLiteral("WW selected of WW tracks - [ WW:WW ]")));
Expand Down Expand Up @@ -3330,3 +3342,24 @@ void MainWindow::FocusSearchField() {
}

}

void MainWindow::ShowVisualizations() {

#ifdef HAVE_VISUALIZATIONS

if (!visualization_) {
visualization_.reset(new VisualizationContainer);

visualization_->SetActions(ui_->action_previous_track, ui_->action_play_pause, ui_->action_stop, ui_->action_next_track);
connect(&*app_->player(), &Player::Stopped, &*visualization_, &VisualizationContainer::Stopped);
connect(&*app_->player(), &Player::ForceShowOSD, &*visualization_, &VisualizationContainer::SongMetadataChanged);
connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*visualization_, &VisualizationContainer::SongMetadataChanged);

visualization_->SetEngine(qobject_cast<GstEngine*>(&*app_->player()->engine()));
}

visualization_->show();

#endif // HAVE_VISUALIZATIONS

}
7 changes: 7 additions & 0 deletions src/core/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Windows7ThumbBar;
class AddStreamDialog;
class LastFMImportDialog;
class RadioViewContainer;
class VisualizationContainer;

class MainWindow : public QMainWindow, public PlatformInterface {
Q_OBJECT
Expand Down Expand Up @@ -274,6 +275,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {

void DeleteFilesFinished(const SongList &songs_with_errors);

void ShowVisualizations();

public slots:
void CommandlineOptionsReceived(const QByteArray &string_options);
void Raise();
Expand Down Expand Up @@ -358,6 +361,10 @@ class MainWindow : public QMainWindow, public PlatformInterface {

LastFMImportDialog *lastfm_import_dialog_;

#ifdef HAVE_VISUALIZATIONS
ScopedPtr<VisualizationContainer> visualization_;
#endif

QAction *collection_show_all_;
QAction *collection_show_duplicates_;
QAction *collection_show_untagged_;
Expand Down
Loading

0 comments on commit 2677346

Please sign in to comment.