Skip to content

Commit

Permalink
Add visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Sep 5, 2024
1 parent 2597a8f commit b0b8d59
Show file tree
Hide file tree
Showing 31 changed files with 2,282 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 @@ -162,6 +162,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 @@ -197,6 +205,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 @@ -461,6 +474,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
35 changes: 35 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,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 @@ -1114,6 +1135,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_directories(strawberry_lib PRIVATE ${ALSA_LIBRARY_DIRS})
Expand Down Expand Up @@ -1215,6 +1244,12 @@ 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_directories(strawberry_lib PRIVATE ${LIBPROJECTM_LIBRARY_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 @@ -254,3 +266,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 Q_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 @@ -212,6 +212,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 @@ -595,6 +600,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 @@ -861,6 +872,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 @@ -3291,3 +3303,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

}
6 changes: 6 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,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
public Q_SLOTS:
void CommandlineOptionsReceived(const QByteArray &string_options);
void Raise();
void ShowVisualizations();

private:

Expand Down Expand Up @@ -355,6 +357,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 b0b8d59

Please sign in to comment.