From 0abac8ab0381afff933926063737f5d488ba24fa Mon Sep 17 00:00:00 2001 From: swagween <109032389+swagween@users.noreply.github.com> Date: Mon, 23 Jun 2025 02:52:46 +0200 Subject: [PATCH 1/8] integrate libxmp --- deps/CMakeLists.txt | 9 ++++++++- deps/imgui-sfml/CMakeLists.txt | 14 -------------- 2 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 deps/imgui-sfml/CMakeLists.txt diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 1741223..f5533b6 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -17,6 +17,13 @@ FetchContent_Declare( GIT_TAG v2.0.1 ) +# libxmp +FetchContent_Declare( + libxmp + GIT_REPOSITORY https://github.com/libxmp/libxmp + GIT_TAG libxmp-4.6.3 +) + # djson FetchContent_Declare( djson @@ -24,7 +31,7 @@ FetchContent_Declare( GIT_TAG v2.1.1 ) -FetchContent_MakeAvailable(gvdi capo djson) +FetchContent_MakeAvailable(gvdi capo libxmp djson) add_library(jukebox-deps INTERFACE) add_library(jukebox::deps ALIAS jukebox-deps) diff --git a/deps/imgui-sfml/CMakeLists.txt b/deps/imgui-sfml/CMakeLists.txt deleted file mode 100644 index f7799e1..0000000 --- a/deps/imgui-sfml/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -message(STATUS "Fetching ImGui-SFML...") - -set(IMGUI_DIR ${IMGUI_SOURCE_DIR}) -set(IMGUI_SFML_FIND_SFML OFF) -set(IMGUI_SFML_IMGUI_DEMO ON) - -# ImGui-SFML -FetchContent_Declare( - imgui-sfml - GIT_REPOSITORY https://github.com/eliasdaler/imgui-sfml - GIT_TAG v3.0 -) - -FetchContent_MakeAvailable(imgui-sfml) From dd62746cee891fe1db97b5608b781d40f0b3a335 Mon Sep 17 00:00:00 2001 From: Karn Kaul Date: Sun, 22 Jun 2025 20:30:54 -0700 Subject: [PATCH 2/8] Fix attempt for weird CMake/ninja error --- .github/workflows/ci.yml | 2 -- deps/CMakeLists.txt | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcf4e47..bba05dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - name: init - run: choco install ninja - name: configure run: cmake -S . --preset=ninja-clang -B build - name: build debug diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index f5533b6..84e0ea6 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -8,6 +8,7 @@ set(BUILD_SHARED_LIBS OFF) FetchContent_Declare(gvdi GIT_REPOSITORY https://github.com/karnkaul/gvdi GIT_TAG v0.2.5 + GIT_SHALLOW TRUE ) # capo @@ -15,6 +16,7 @@ FetchContent_Declare( capo GIT_REPOSITORY https://github.com/capo-devs/capo-lite GIT_TAG v2.0.1 + GIT_SHALLOW TRUE ) # libxmp @@ -22,6 +24,7 @@ FetchContent_Declare( libxmp GIT_REPOSITORY https://github.com/libxmp/libxmp GIT_TAG libxmp-4.6.3 + GIT_SHALLOW TRUE ) # djson @@ -29,8 +32,11 @@ FetchContent_Declare( djson GIT_REPOSITORY https://github.com/karnkaul/djson GIT_TAG v2.1.1 + GIT_SHALLOW TRUE ) +set(BUILD_SHARED OFF CACHE BOOL "" FORCE) +set(LIBXMP_PIC ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(gvdi capo libxmp djson) add_library(jukebox-deps INTERFACE) From ebd2ee33f9d1516545dd723c030855684fb5cc57 Mon Sep 17 00:00:00 2001 From: Karn Kaul Date: Sun, 22 Jun 2025 20:48:37 -0700 Subject: [PATCH 3/8] Remove unused files --- deps/imgui/CMakeLists.txt | 51 --------------------------------------- deps/imgui/LICENSE.txt | 21 ---------------- 2 files changed, 72 deletions(-) delete mode 100644 deps/imgui/CMakeLists.txt delete mode 100644 deps/imgui/LICENSE.txt diff --git a/deps/imgui/CMakeLists.txt b/deps/imgui/CMakeLists.txt deleted file mode 100644 index 10bbe92..0000000 --- a/deps/imgui/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -cmake_minimum_required(VERSION 3.18) - -# Fetch imgui -FetchContent_Declare( - imgui - GIT_REPOSITORY https://github.com/ocornut/imgui - GIT_TAG v1.91.6 -) -FetchContent_MakeAvailable(imgui) -set(IMGUI_SOURCE_DIR ${imgui_SOURCE_DIR} CACHE STRING "ImGui source directory") - -project(imgui VERSION 1.91.6) - -include(FetchContent) - - - -# Find OpenGL -find_package(OpenGL REQUIRED) - -# Add the imgui library target -add_library(imgui) - -# Set include directories -target_include_directories(imgui SYSTEM PUBLIC - ${IMGUI_SOURCE_DIR} - ${IMGUI_SOURCE_DIR}/backends -) - -# Specify source files for the library -target_sources(imgui PRIVATE - ${IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp - ${IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.h - ${IMGUI_SOURCE_DIR}/imgui.cpp - ${IMGUI_SOURCE_DIR}/imgui_demo.cpp - ${IMGUI_SOURCE_DIR}/imgui_draw.cpp - ${IMGUI_SOURCE_DIR}/imgui_tables.cpp - ${IMGUI_SOURCE_DIR}/imgui_widgets.cpp -) - -# Link required libraries, including OpenGL -target_link_libraries(imgui PRIVATE - OpenGL::GL -) - -# Compiler-specific flags -if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU) - target_compile_options(imgui PRIVATE - -Wno-conversion - ) -endif() diff --git a/deps/imgui/LICENSE.txt b/deps/imgui/LICENSE.txt deleted file mode 100644 index 00ae473..0000000 --- a/deps/imgui/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2025 Omar Cornut - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. From cfae632bbbf675a83fda2c36bf117e4fd1819f19 Mon Sep 17 00:00:00 2001 From: Karn Kaul Date: Sun, 22 Jun 2025 20:49:46 -0700 Subject: [PATCH 4/8] Link to libxmp --- deps/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 84e0ea6..24d4783 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -46,4 +46,5 @@ target_link_libraries(jukebox-deps INTERFACE djson::djson capo::capo gvdi::gvdi + libxmp::xmp_static ) From 71531a142b7452fe05d3ec0947327120560eb90a Mon Sep 17 00:00:00 2001 From: Karn Kaul Date: Sun, 22 Jun 2025 22:53:03 -0700 Subject: [PATCH 5/8] Add JUKE_USE_LIBXMP, disable on CI --- .github/workflows/ci.yml | 12 ++++++------ CMakeLists.txt | 2 ++ deps/CMakeLists.txt | 22 +++++++++++++--------- library/CMakeLists.txt | 8 ++++++++ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bba05dd..988b3dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: - name: init run: uname -m; sudo apt update -yqq && sudo apt install -yqq ninja-build mesa-common-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules - name: configure - run: cmake -S . --preset=ninja-gcc -B build -DGLFW_BUILD_X11=OFF -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 + run: cmake -S . --preset=ninja-gcc -B build -DGLFW_BUILD_X11=OFF -DJUKE_USE_LIBXMP=OFF -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 - name: build debug run: cmake --build build --config=Debug -- -v - name: build release @@ -24,7 +24,7 @@ jobs: - name: init run: uname -m; sudo apt update -yqq && sudo apt install -yqq ninja-build clang-19 mesa-common-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules - name: configure - run: cmake -S . --preset=ninja-clang -B build -DGLFW_BUILD_X11=OFF -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 + run: cmake -S . --preset=ninja-clang -B build -DGLFW_BUILD_X11=OFF -DJUKE_USE_LIBXMP=OFF -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 - name: build debug run: cmake --build build --config=Debug -- -v - name: build release @@ -40,7 +40,7 @@ jobs: - name: init run: uname -m; sudo apt update -yqq && sudo apt install -yqq ninja-build mesa-common-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules - name: configure - run: cmake -S . --preset=ninja-gcc -B build -DGLFW_BUILD_X11=OFF -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 + run: cmake -S . --preset=ninja-gcc -B build -DGLFW_BUILD_X11=OFF -DJUKE_USE_LIBXMP=OFF -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 - name: build debug run: cmake --build build --config=Debug -- -v - name: build release @@ -56,7 +56,7 @@ jobs: - name: init run: uname -m; sudo apt update -yqq && sudo apt install -yqq ninja-build clang-19 mesa-common-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules - name: configure - run: cmake -S . --preset=ninja-clang -B build -DGLFW_BUILD_X11=OFF -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 + run: cmake -S . --preset=ninja-clang -B build -DGLFW_BUILD_X11=OFF -DJUKE_USE_LIBXMP=OFF -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 - name: build debug run: cmake --build build --config=Debug -- -v - name: build release @@ -70,7 +70,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: configure - run: cmake -S . --preset=vs22 -B build + run: cmake -S . --preset=vs22 -B build -DJUKE_USE_LIBXMP=OFF - name: build debug run: cmake --build build --config=Debug --parallel - name: build release @@ -84,7 +84,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: configure - run: cmake -S . --preset=ninja-clang -B build + run: cmake -S . --preset=ninja-clang -B build -DJUKE_USE_LIBXMP=OFF - name: build debug run: cmake --build build --config=Debug -- -v - name: build release diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a619d7..e5e4208 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ project(jukebox VERSION 1.0 ) +option(JUKE_USE_LIBXMP "Use libxmp backend" ON) + set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 24d4783..f3b277e 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -4,6 +4,8 @@ project(jukebox-deps) include(FetchContent) set(BUILD_SHARED_LIBS OFF) +set(fetch_list gvdi capo djson) + # gvdi FetchContent_Declare(gvdi GIT_REPOSITORY https://github.com/karnkaul/gvdi @@ -19,13 +21,16 @@ FetchContent_Declare( GIT_SHALLOW TRUE ) -# libxmp -FetchContent_Declare( - libxmp - GIT_REPOSITORY https://github.com/libxmp/libxmp - GIT_TAG libxmp-4.6.3 - GIT_SHALLOW TRUE -) +if(JUKE_USE_LIBXMP) + # libxmp + FetchContent_Declare( + libxmp + GIT_REPOSITORY https://github.com/libxmp/libxmp + GIT_TAG libxmp-4.6.3 + GIT_SHALLOW TRUE + ) + list(APPEND fetch_list libxmp) +endif() # djson FetchContent_Declare( @@ -37,7 +42,7 @@ FetchContent_Declare( set(BUILD_SHARED OFF CACHE BOOL "" FORCE) set(LIBXMP_PIC ON CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(gvdi capo libxmp djson) +FetchContent_MakeAvailable(${fetch_list}) add_library(jukebox-deps INTERFACE) add_library(jukebox::deps ALIAS jukebox-deps) @@ -46,5 +51,4 @@ target_link_libraries(jukebox-deps INTERFACE djson::djson capo::capo gvdi::gvdi - libxmp::xmp_static ) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 54820a3..c0d9ca0 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -8,6 +8,14 @@ target_link_libraries(juke jukebox::deps ) +if(JUKE_USE_LIBXMP) + target_link_libraries(juke + PRIVATE + libxmp::xmp_static + ) + target_compile_definitions(juke PRIVATE JUKE_USE_LIBXMP) +endif() + # Glob all headers file(GLOB_RECURSE headers "include/*.hpp") From 635bd42ba3b6e393ccf352c6521025b746a06449 Mon Sep 17 00:00:00 2001 From: swagween <109032389+swagween@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:29:32 +0200 Subject: [PATCH 6/8] fix crash on close --- library/include/juke/core/MediaPlayer.hpp | 1 + library/src/core/Application.cpp | 1 + library/src/core/MediaPlayer.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/library/include/juke/core/MediaPlayer.hpp b/library/include/juke/core/MediaPlayer.hpp index 9cc29bf..2d4f456 100644 --- a/library/include/juke/core/MediaPlayer.hpp +++ b/library/include/juke/core/MediaPlayer.hpp @@ -17,6 +17,7 @@ class MediaPlayer { bool load_media(std::filesystem::path const& path); void handle_input(); void update(std::chrono::duration dt); + void stop(); [[nodiscard]] auto playing() const -> bool { return m_status == MediaStatus::playing; } [[nodiscard]] auto paused() const -> bool { return m_status == MediaStatus::paused; } diff --git a/library/src/core/Application.cpp b/library/src/core/Application.cpp index 47dc924..3ddbd44 100644 --- a/library/src/core/Application.cpp +++ b/library/src/core/Application.cpp @@ -34,6 +34,7 @@ void Application::run() { m_context->render(); } + m_player->stop(); } Application& Application::self(GLFWwindow* window) { return *static_cast(glfwGetWindowUserPointer(window)); } diff --git a/library/src/core/MediaPlayer.cpp b/library/src/core/MediaPlayer.cpp index efd5333..29f0c58 100644 --- a/library/src/core/MediaPlayer.cpp +++ b/library/src/core/MediaPlayer.cpp @@ -78,4 +78,6 @@ void MediaPlayer::update([[maybe_unused]] std::chrono::duration const dt) if (m_status == MediaStatus::playing && !m_source->is_playing()) { m_status = MediaStatus::stopped; } } +void MediaPlayer::stop() { m_source->stop(); } + } // namespace juke From 3826e20b044ee83a9d90cb20913914cf616145c5 Mon Sep 17 00:00:00 2001 From: swagween <109032389+swagween@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:34:45 +0200 Subject: [PATCH 7/8] better fix for crash --- library/include/juke/core/MediaPlayer.hpp | 4 +--- library/src/core/Application.cpp | 1 - library/src/core/MediaPlayer.cpp | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/library/include/juke/core/MediaPlayer.hpp b/library/include/juke/core/MediaPlayer.hpp index 2d4f456..e2cea48 100644 --- a/library/include/juke/core/MediaPlayer.hpp +++ b/library/include/juke/core/MediaPlayer.hpp @@ -17,19 +17,17 @@ class MediaPlayer { bool load_media(std::filesystem::path const& path); void handle_input(); void update(std::chrono::duration dt); - void stop(); [[nodiscard]] auto playing() const -> bool { return m_status == MediaStatus::playing; } [[nodiscard]] auto paused() const -> bool { return m_status == MediaStatus::paused; } [[nodiscard]] auto stopped() const -> bool { return m_status == MediaStatus::stopped; } private: - std::unique_ptr m_source{}; - MediaStatus m_status; [[maybe_unused]] bool m_trigger{}; std::optional m_file{}; + std::unique_ptr m_source{}; std::string m_status_string{"stopped"}; }; diff --git a/library/src/core/Application.cpp b/library/src/core/Application.cpp index 3ddbd44..47dc924 100644 --- a/library/src/core/Application.cpp +++ b/library/src/core/Application.cpp @@ -34,7 +34,6 @@ void Application::run() { m_context->render(); } - m_player->stop(); } Application& Application::self(GLFWwindow* window) { return *static_cast(glfwGetWindowUserPointer(window)); } diff --git a/library/src/core/MediaPlayer.cpp b/library/src/core/MediaPlayer.cpp index 29f0c58..efd5333 100644 --- a/library/src/core/MediaPlayer.cpp +++ b/library/src/core/MediaPlayer.cpp @@ -78,6 +78,4 @@ void MediaPlayer::update([[maybe_unused]] std::chrono::duration const dt) if (m_status == MediaStatus::playing && !m_source->is_playing()) { m_status = MediaStatus::stopped; } } -void MediaPlayer::stop() { m_source->stop(); } - } // namespace juke From a356d3540a5cb9f6e2d0113859d45e53336a4ed7 Mon Sep 17 00:00:00 2001 From: swagween <109032389+swagween@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:39:15 +0200 Subject: [PATCH 8/8] fix build --- library/include/juke/core/MediaPlayer.hpp | 2 +- library/src/core/MediaPlayer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/include/juke/core/MediaPlayer.hpp b/library/include/juke/core/MediaPlayer.hpp index e2cea48..466dc26 100644 --- a/library/include/juke/core/MediaPlayer.hpp +++ b/library/include/juke/core/MediaPlayer.hpp @@ -23,7 +23,7 @@ class MediaPlayer { [[nodiscard]] auto stopped() const -> bool { return m_status == MediaStatus::stopped; } private: - MediaStatus m_status; + MediaStatus m_status{MediaStatus::stopped}; [[maybe_unused]] bool m_trigger{}; std::optional m_file{}; diff --git a/library/src/core/MediaPlayer.cpp b/library/src/core/MediaPlayer.cpp index efd5333..2cb199e 100644 --- a/library/src/core/MediaPlayer.cpp +++ b/library/src/core/MediaPlayer.cpp @@ -8,7 +8,7 @@ namespace juke { -MediaPlayer::MediaPlayer(capo::IEngine& audio_engine) : m_source(audio_engine.create_source()), m_status{MediaStatus::stopped} { +MediaPlayer::MediaPlayer(capo::IEngine& audio_engine) : m_source(audio_engine.create_source()) { if (!m_source) { throw std::runtime_error{"Failed to create Audio Source"}; } }