Skip to content

Commit

Permalink
Add visualisations
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski committed Jun 21, 2024
1 parent a7a42ea commit 5a4c00a
Show file tree
Hide file tree
Showing 24 changed files with 2,099 additions and 6 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
libchromaprint-devel
fftw3-devel
libebur128-devel
projectM-devel
desktop-file-utils
update-desktop-files
appstream-glib
Expand All @@ -86,6 +87,7 @@ jobs:
libQt5Network-devel
libQt5Sql-devel
libQt5DBus-devel
libQt5OpenGL-devel
libQt5Test-devel
libqt5-qtbase-common-devel
libQt5Sql5-sqlite
Expand All @@ -106,6 +108,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 @@ -312,6 +315,7 @@ jobs:
lib64Qt6DBus-devel
lib64Qt6Gui-devel
lib64Qt6Widgets-devel
lib64Qt6OpenGL-devel
lib64Qt6Test-devel
qt6-cmake
qt6-qtbase-tools
Expand Down Expand Up @@ -409,6 +413,7 @@ jobs:
lib64fftw-devel
lib64dbus-devel
lib64appstream-devel
lib64projectm-devel
lib64qt6core-devel
lib64qt6gui-devel
lib64qt6widgets-devel
Expand All @@ -418,6 +423,7 @@ jobs:
lib64qt6dbus-devel
lib64qt6help-devel
lib64qt6test-devel
lib64qt6opengl-devel
protobuf-compiler
desktop-file-utils
appstream-util
Expand Down Expand Up @@ -508,11 +514,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 @@ -595,11 +602,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 @@ -681,6 +689,7 @@ jobs:
libcdio-dev
libmtp-dev
libgpod-dev
libprojectm-dev
gstreamer1.0-alsa
gstreamer1.0-pulseaudio
protobuf-compiler
Expand All @@ -693,7 +702,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)
if(projectM4_FOUND)
set(LIBPROJECTM_FOUND ON)
set(HAVE_PROJECTM4 ON)
set(LIBPROJECTM_LIBRARIES libprojectM::projectM projectM-4-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 @@ -443,6 +456,20 @@ optional_component(EBUR128 ON "EBU R 128 loudness normalization"
DEPENDS "gstreamer" HAVE_GSTREAMER
)

if(QT_VERSION_MAJOR EQUAL 5)
optional_component(VISUALISATIONS ON "Visualisations"
DEPENDS "libprojectm" LIBPROJECTM_FOUND
DEPENDS "QtOpenGL" Qt${QT_VERSION_MAJOR}OpenGL_FOUND
DEPENDS "gstreamer" HAVE_GSTREAMER
)
else()
optional_component(VISUALISATIONS ON "Visualisations"
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
36 changes: 36 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,25 @@ optional_source(HAVE_EBUR128
SOURCES engine/ebur128analysis.cpp
)

# Visualisations
optional_source(HAVE_VISUALISATIONS
SOURCES
visualisations/projectmpresetmodel.cpp
visualisations/projectmvisualisation.cpp
visualisations/visualisationcontainer.cpp
visualisations/visualisationoverlay.cpp
visualisations/visualisationselector.cpp
HEADERS
visualisations/projectmpresetmodel.h
visualisations/projectmvisualisation.h
visualisations/visualisationcontainer.h
visualisations/visualisationoverlay.h
visualisations/visualisationselector.h
UI
visualisations/visualisationoverlay.ui
visualisations/visualisationselector.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 @@ -1087,6 +1106,10 @@ if(HAVE_QTSPARKLE)
link_directories(${QTSPARKLE_LIBRARY_DIRS})
endif()

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

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

if(HAVE_VISUALISATIONS)
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 @@ -1229,6 +1260,11 @@ if(HAVE_LIBMTP)
target_link_libraries(strawberry_lib PRIVATE ${LIBMTP_LIBRARIES})
endif()

if(HAVE_VISUALISATIONS)
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 @@ -71,7 +71,8 @@ AnalyzerContainer::AnalyzerContainer(QWidget *parent)
double_click_timer_(new QTimer(this)),
ignore_next_click_(false),
current_analyzer_(nullptr),
engine_(nullptr) {
engine_(nullptr),
action_visualisation_(nullptr) {

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

}

void AnalyzerContainer::mouseDoubleClickEvent(QMouseEvent *e) {

Q_UNUSED(e);

double_click_timer_->stop();
ignore_next_click_ = true;

if (action_visualisation_) action_visualisation_->trigger();

}

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

}

void AnalyzerContainer::SetVisualisationsAction(QAction *visualisation) {

action_visualisation_ = visualisation;
context_menu_->addAction(action_visualisation_);

}
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 SetVisualisationsAction(QAction *visualisation);

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_visualisation_;
};

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 @@ -58,4 +58,7 @@

#cmakedefine HAVE_EBUR128

#cmakedefine HAVE_VISUALISATIONS
#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_VISUALISATIONS
# include "visualisations/visualisationcontainer.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_VISUALISATIONS
QObject::connect(ui_->action_visualisations, &QAction::triggered, this, &MainWindow::ShowVisualisations);
#else
ui_->action_visualisations->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->SetVisualisationsAction(ui_->action_visualisations);

// 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::ShowVisualisations() {

#ifdef HAVE_VISUALISATIONS

if (!visualisation_) {
visualisation_.reset(new VisualisationContainer);

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

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

visualisation_->show();

#endif // HAVE_VISUALISATIONS

}
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 VisualisationContainer;

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 ShowVisualisations();

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_VISUALISATIONS
ScopedPtr<VisualisationContainer> visualisation_;
#endif

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

0 comments on commit 5a4c00a

Please sign in to comment.