Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=YES \
-DBUILD_SHARED_LIBS="${shared_libs}" \
-DENABLE_BOOST_FILESYSTEM="${use_boost}" \
-DENABLE_CXX_INTERFACE=YES \
-DBUILD_TESTING=YES

- name: Build Debug
Expand All @@ -80,6 +81,16 @@ jobs:
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target install
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target install

- name: Test C++ Interface
run: |
cmake -G "Ninja Multi-Config" \
-S "${{ github.workspace }}/tests/cxx-interface" \
-B "${{ github.workspace }}/cmake-build-cxx-api" \
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install"

cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
-DBUILD_SHARED_LIBS="${shared_libs}" \
-DENABLE_BOOST_FILESYSTEM="${use_boost}" \
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
-DENABLE_CXX_INTERFACE=YES \
-DBUILD_TESTING=YES

- name: Build Debug
Expand All @@ -81,6 +82,17 @@ jobs:
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target install
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target install

- name: Test C++ Interface
run: |
cmake -G "Ninja Multi-Config" \
-S "${{ github.workspace }}/tests/cxx-interface" \
-B "${{ github.workspace }}/cmake-build-cxx-api" \
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}" \
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install"

cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=YES `
-DBUILD_SHARED_LIBS="$($shared_libs)" `
-DENABLE_BOOST_FILESYSTEM="$($use_boost)" `
-DBUILD_TESTING=YES
-DENABLE_CXX_INTERFACE=YES `
-DBUILD_TESTING=YES `
-DCMAKE_VERBOSE_MAKEFILE=ON

- name: Build Debug
run: cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --parallel
Expand All @@ -112,6 +114,39 @@ jobs:
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target INSTALL
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target INSTALL

- name: Test C++ Interface
run: |
if("${{ matrix.fslib }}" -eq "boost") {
$use_boost = "ON"
} else {
$use_boost = "OFF"
}
if("${{ matrix.arch }}" -eq "X64") {
$triplet = "x64-windows"
} else {
$triplet = "x86-windows"
}
if("${{ matrix.libs }}" -eq "shared") {
$runtime = "DLL"
} else {
$runtime = ""
$triplet = $triplet + "-static"
}

cmake -G "Visual Studio 17 2022" `
-A "${{ matrix.arch }}" `
-S "${{ github.workspace }}/tests/cxx-interface" `
-B "${{ github.workspace }}/cmake-build-cxx-api" `
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/install" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>$($runtime)" `
-DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" `
-DVCPKG_TARGET_TRIPLET="$($triplet)" `
-DENABLE_BOOST_FILESYSTEM="$($use_boost)" `
-DCMAKE_VERBOSE_MAKEFILE=ON

cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug"
cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release"

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,6 @@ else()
endif()
endif()

if(ENABLE_CXX_INTERFACE)
set(CMAKE_C_VISIBILITY_PRESET default)
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
else()
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
endif()

# Disable trace/debug logging in release builds unless explicitly requested
add_compile_definitions(
$<$<OR:$<CONFIG:Debug>,$<BOOL:${ENABLE_VERBOSE_LOGGING}>>:ENABLE_DEBUG_LOGGING>
Expand Down
20 changes: 20 additions & 0 deletions src/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ generate_export_header(projectM_api
EXPORT_FILE_NAME "${PROJECTM_EXPORT_HEADER}"
)

# Always generate the header, but we only install it if the C++ interface is actually enabled.
set(PROJECTM_CXX_EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/projectM_cxx_export.h")

generate_export_header(projectM_api
BASE_NAME projectM_CXX
EXPORT_FILE_NAME "${PROJECTM_CXX_EXPORT_HEADER}"
)

set(PROJECTM_PUBLIC_HEADERS
"${PROJECTM_EXPORT_HEADER}"
"${CMAKE_CURRENT_BINARY_DIR}/include/projectM-4/version.h"
Expand All @@ -28,6 +36,10 @@ set(PROJECTM_PUBLIC_HEADERS
include/projectM-4/user_sprites.h
)

if(ENABLE_CXX_INTERFACE)
list(APPEND PROJECTM_PUBLIC_HEADERS ${PROJECTM_CXX_EXPORT_HEADER})
endif()

target_sources(projectM_api
PRIVATE
${PROJECTM_PUBLIC_HEADERS}
Expand All @@ -46,6 +58,14 @@ target_include_directories(projectM_api
"$<INSTALL_INTERFACE:${PROJECTM_INCLUDE_DIR}>"
)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(projectM_api
INTERFACE
PROJECTM_STATIC_DEFINE
PROJECTM_CXX_STATIC_DEFINE
)
endif()

add_library(libprojectM::API ALIAS projectM_api)


Expand Down
16 changes: 15 additions & 1 deletion src/libprojectM/Audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@ target_include_directories(Audio
target_link_libraries(Audio
PUBLIC
libprojectM::API
)
)

if(BUILD_SHARED_LIBS)
if(ENABLE_CXX_INTERFACE)
target_compile_definitions(Audio
PRIVATE
projectM_api_EXPORTS
)
else()
target_compile_definitions(Audio
PRIVATE
PROJECTM_CXX_STATIC_DEFINE
)
endif()
endif()
4 changes: 2 additions & 2 deletions src/libprojectM/Audio/FrameAudioData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

#include "Audio/AudioConstants.hpp"

#include <projectM-4/projectM_export.h>
#include <projectM-4/projectM_cxx_export.h>

#include <array>

namespace libprojectM {
namespace Audio {

class PROJECTM_EXPORT FrameAudioData
class PROJECTM_CXX_EXPORT FrameAudioData
{
public:
float bass{0.f};
Expand Down
8 changes: 5 additions & 3 deletions src/libprojectM/Audio/Loudness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "Audio/AudioConstants.hpp"

#include <projectM-4/projectM_cxx_export.h>

#include <array>
#include <cstdint>

Expand All @@ -16,14 +18,14 @@ namespace Audio {
/**
* @brief Calculates beat-detection loudness relative to the previous frame(s).
*/
class Loudness
class PROJECTM_CXX_EXPORT Loudness
{
public:
/**
* @brief Frequency bands.
* Only the first half of the spectrum is used for these bands, each using one third of this half.
*/
enum class Band : int
enum class Band : std::uint8_t
{
Bass = 0, //!< Bass band (first sixth of the spectrum)
Middles = 1, //!< Middles band (second sixth of the spectrum)
Expand Down Expand Up @@ -76,7 +78,7 @@ class Loudness
void UpdateBandAverage(double secondsSinceLastFrame, uint32_t frame);

/**
* @brief Adjusts the dampening rate according the the current FPS.
* @brief Adjusts the dampening rate according to the current FPS.
* @param rate The rate to be dampened.
* @param secondsSinceLastFrame (Fractional) seconds passed since the last frame.
* @return The dampened rate value.
Expand Down
5 changes: 4 additions & 1 deletion src/libprojectM/Audio/MilkdropFFT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include <projectM-4/projectM_cxx_export.h>

#include <complex>
#include <cstddef>
#include <vector>

namespace libprojectM {
Expand All @@ -40,7 +43,7 @@ namespace Audio {
* Also applies an equalizer pattern with an envelope curve to the resulting data to smooth out
* certain artifacts.
*/
class MilkdropFFT
class PROJECTM_CXX_EXPORT MilkdropFFT
{
public:
/**
Expand Down
14 changes: 7 additions & 7 deletions src/libprojectM/Audio/PCM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "Audio/MilkdropFFT.hpp"
#include "Audio/WaveformAligner.hpp"

#include <projectM-4/projectM_export.h>
#include <projectM-4/projectM_cxx_export.h>

#include <atomic>
#include <cstdint>
Expand All @@ -23,7 +23,7 @@
namespace libprojectM {
namespace Audio {

class PCM
class PROJECTM_CXX_EXPORT PCM
{
public:
/**
Expand All @@ -33,7 +33,7 @@ class PCM
* @param channels The number of channels in the input data.
* @param count The amount of samples in the buffer
*/
PROJECTM_EXPORT void Add(const float* samples, uint32_t channels, size_t count);
void Add(const float* samples, uint32_t channels, size_t count);

/**
* @brief Adds new mono unsigned 8-bit PCM data to the storage
Expand All @@ -42,7 +42,7 @@ class PCM
* @param channels The number of channels in the input data.
* @param count The amount of samples in the buffer
*/
PROJECTM_EXPORT void Add(const uint8_t* samples, uint32_t channels, size_t count);
void Add(const uint8_t* samples, uint32_t channels, size_t count);

/**
* @brief Adds new mono signed 16-bit PCM data to the storage
Expand All @@ -51,7 +51,7 @@ class PCM
* @param channels The number of channels in the input data.
* @param count The amount of samples in the buffer
*/
PROJECTM_EXPORT void Add(const int16_t* samples, uint32_t channels, size_t count);
void Add(const int16_t* samples, uint32_t channels, size_t count);

/**
* @brief Updates the internal audio data values for rendering the next frame.
Expand All @@ -64,13 +64,13 @@ class PCM
* @param secondsSinceLastFrame Time passed since rendering the last frame. Basically 1.0/FPS.
* @param frame Frames rendered since projectM was started.
*/
PROJECTM_EXPORT void UpdateFrameAudioData(double secondsSinceLastFrame, uint32_t frame);
void UpdateFrameAudioData(double secondsSinceLastFrame, uint32_t frame);

/**
* @brief Returns a class holding a copy of the current frame audio data.
* @return A FrameAudioData class with waveform, spectrum and other derived values.
*/
PROJECTM_EXPORT auto GetFrameAudioData() const -> FrameAudioData;
auto GetFrameAudioData() const -> FrameAudioData;

private:
template<
Expand Down
8 changes: 5 additions & 3 deletions src/libprojectM/Audio/WaveformAligner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include "Audio/AudioConstants.hpp"

#include <cstddef>
#include <projectM-4/projectM_cxx_export.h>

#include <array>
#include <cstdint>
#include <vector>

Expand All @@ -23,7 +25,7 @@ namespace Audio {
* This will keep similar features in-place instead of randomly jumping around on each frame and creates
* for a smoother-looking waveform visualization.
*/
class WaveformAligner
class PROJECTM_CXX_EXPORT WaveformAligner
{
public:
WaveformAligner();
Expand All @@ -36,7 +38,7 @@ class WaveformAligner

protected:
void GenerateWeights();
int CalculateOffset(std::vector<WaveformBuffer>& newWaveformMips);
auto CalculateOffset(std::vector<WaveformBuffer>& newWaveformMips) -> int;
void ResampleOctaves(std::vector<WaveformBuffer>& dstWaveformMips, WaveformBuffer& newWaveform);

bool m_alignWaveReady{false}; //!< Alignment needs special treatment for the first buffer fill.
Expand Down
Loading
Loading