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
95 changes: 95 additions & 0 deletions .github/workflows/ci-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Web

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
# Test Emscripten builds from all host platforms to validate host OS independence
- name: "Linux (Ubuntu) Host"
os: ubuntu-latest
emsdk-version: '3.1.57'
setup-deps: 'sudo apt-get update && sudo apt-get install -y ninja-build'

- name: "Windows Host"
os: windows-latest
emsdk-version: '3.1.57'
setup-deps: 'choco install ninja'

- name: "macOS Host"
os: macos-latest
emsdk-version: '3.1.57'
setup-deps: 'brew install ninja'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install host dependencies
run: ${{ matrix.setup-deps }}
shell: bash

- name: Setup Emscripten SDK
uses: mymindstorm/setup-emsdk@v13
with:
version: ${{ matrix.emsdk-version }}

- name: Verify Emscripten installation
run: |
emcc --version
echo "EMSDK environment: $EMSDK"
echo "CMAKE_SYSTEM_NAME will be set to 'Emscripten' by emcmake"
shell: bash

- name: Configure CMake for WebAssembly
run: |
mkdir -p build
cd build
emcmake cmake .. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release
echo "Note: Tests are automatically disabled for Emscripten builds due to testcoe compatibility issues"
shell: bash

- name: Build WebAssembly artifacts
run: |
cd build
emmake ninja
shell: bash

- name: Validate WebAssembly artifacts
run: |
echo "=== Validating WebAssembly build artifacts ==="
cd build

# Look for .wasm and .js files
echo "=== WebAssembly Files Found ==="
find . -name "*.wasm" -type f | head -10
find . -name "*.js" -type f | head -10

# Validate soundcoe library was built
SOUNDCOE_LIB=$(find . -name "libsoundcoe.a" -type f)
if [ -n "$SOUNDCOE_LIB" ]; then
echo "✅ soundcoe library built successfully at: $SOUNDCOE_LIB"
else
echo "❌ soundcoe library missing"
exit 1
fi

echo "✅ WebAssembly build validation completed"
echo "Note: Tests are disabled for Emscripten due to testcoe compatibility issues"
shell: bash


147 changes: 4 additions & 143 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,157 +5,18 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
include(cmake/soundcoe_config.cmake)

message(STATUS "[soundcoe] Fetching OpenAL-Soft from source...")

include(FetchContent)
FetchContent_Declare(
openal
GIT_REPOSITORY https://github.com/kcat/openal-soft.git
GIT_TAG 1.24.3
)

# Basic configuration options (for all platforms)
set(LIBTYPE "STATIC" CACHE STRING "Build static library" FORCE)
set(ALSOFT_UTILS OFF CACHE BOOL "" FORCE)
set(ALSOFT_EXAMPLES OFF CACHE BOOL "" FORCE)
set(ALSOFT_TESTS OFF CACHE BOOL "" FORCE)
set(ALSOFT_NO_CONFIG_UTIL ON CACHE BOOL "" FORCE)
set(ALSOFT_EMBED_HRTF_DATA ON CACHE BOOL "" FORCE)

# Platform-specific backend requirements
if(WIN32)
# Windows - Make backends optional to support different Windows versions
option(SOUNDCOE_ENABLE_WASAPI "Enable WASAPI backend (Vista+)" ON)
option(SOUNDCOE_ENABLE_DSOUND "Enable DirectSound backend" ON)
option(SOUNDCOE_ENABLE_WINMM "Enable WinMM backend" ON)

if(SOUNDCOE_ENABLE_WASAPI)
set(ALSOFT_REQUIRE_WASAPI ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_WASAPI OFF CACHE BOOL "" FORCE)
endif()

if(SOUNDCOE_ENABLE_DSOUND)
set(ALSOFT_REQUIRE_DSOUND ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_DSOUND OFF CACHE BOOL "" FORCE)
endif()

if(SOUNDCOE_ENABLE_WINMM)
set(ALSOFT_REQUIRE_WINMM ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_WINMM OFF CACHE BOOL "" FORCE)
endif()

# Disable non-Windows backends to prevent build issues
set(ALSOFT_BACKEND_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_ALSA OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OSS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_JACK OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_COREAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OPENSL OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OBOE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SOLARIS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SNDIO OFF CACHE BOOL "" FORCE)
elseif(APPLE)
if(IOS)
# iOS
set(ALSOFT_REQUIRE_COREAUDIO ON CACHE BOOL "" FORCE)
set(ALSOFT_UTILS OFF CACHE BOOL "" FORCE)
set(ALSOFT_EXAMPLES OFF CACHE BOOL "" FORCE)
set(ALSOFT_INSTALL OFF CACHE BOOL "" FORCE)

# Disable non-iOS backends to prevent build issues
set(ALSOFT_BACKEND_WASAPI OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_DSOUND OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_WINMM OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_ALSA OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OSS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_JACK OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OPENSL OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OBOE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SOLARIS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SNDIO OFF CACHE BOOL "" FORCE)
else()
# macOS
set(ALSOFT_REQUIRE_COREAUDIO ON CACHE BOOL "" FORCE)

# Disable non-macOS backends to prevent build issues
set(ALSOFT_BACKEND_WASAPI OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_DSOUND OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_WINMM OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_ALSA OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OSS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_JACK OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OPENSL OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OBOE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SOLARIS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SNDIO OFF CACHE BOOL "" FORCE)
endif()
elseif(ANDROID)
# Android
set(ALSOFT_REQUIRE_OPENSL ON CACHE BOOL "" FORCE)

# Disable non-Android backends to prevent build issues
set(ALSOFT_BACKEND_WASAPI OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_DSOUND OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_WINMM OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_COREAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_ALSA OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OSS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_JACK OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SOLARIS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SNDIO OFF CACHE BOOL "" FORCE)
elseif(UNIX)
# Linux - Make backends optional to support different distributions
option(SOUNDCOE_ENABLE_ALSA "Enable ALSA backend" ON)
option(SOUNDCOE_ENABLE_PULSEAUDIO "Enable PulseAudio backend" ON)
option(SOUNDCOE_ENABLE_PIPEWIRE "Enable PipeWire backend" ON)
option(SOUNDCOE_ENABLE_OSS "Enable OSS backend" OFF)

if(SOUNDCOE_ENABLE_ALSA)
set(ALSOFT_REQUIRE_ALSA ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_ALSA OFF CACHE BOOL "" FORCE)
endif()

if(SOUNDCOE_ENABLE_PULSEAUDIO)
set(ALSOFT_REQUIRE_PULSEAUDIO ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_PULSEAUDIO OFF CACHE BOOL "" FORCE)
endif()

if(SOUNDCOE_ENABLE_PIPEWIRE)
set(ALSOFT_REQUIRE_PIPEWIRE ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_PIPEWIRE OFF CACHE BOOL "" FORCE)
endif()

if(SOUNDCOE_ENABLE_OSS)
set(ALSOFT_REQUIRE_OSS ON CACHE BOOL "" FORCE)
else()
set(ALSOFT_BACKEND_OSS OFF CACHE BOOL "" FORCE)
endif()

# Disable non-Linux backends to prevent build issues
set(ALSOFT_BACKEND_WASAPI OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_DSOUND OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_WINMM OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_COREAUDIO OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OPENSL OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_OBOE OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SOLARIS OFF CACHE BOOL "" FORCE)
set(ALSOFT_BACKEND_SNDIO OFF CACHE BOOL "" FORCE)
endif()

include(cmake/utils.cmake)
configure_openal()
FetchContent_MakeAvailable(openal)
ignore_external_warnings(OpenAL)

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Modern C++ audio library built for game developers. Thread-safe, zero-config, si
[![Windows](https://github.com/nircoe/soundcoe/actions/workflows/ci-windows.yml/badge.svg)](https://github.com/nircoe/soundcoe/actions/workflows/ci-windows.yml)
[![Linux](https://github.com/nircoe/soundcoe/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/nircoe/soundcoe/actions/workflows/ci-linux.yml)
[![macOS](https://github.com/nircoe/soundcoe/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/nircoe/soundcoe/actions/workflows/ci-macos.yml)
[![Web](https://github.com/nircoe/soundcoe/actions/workflows/ci-web.yml/badge.svg)](https://github.com/nircoe/soundcoe/actions/workflows/ci-web.yml)

## Why soundcoe?

Expand All @@ -27,6 +28,15 @@ auto explosion = soundcoe::playSound3D("boom.wav", {10.0f, 0.0f, -20.0f});
- **CMake 3.14+** - Build system
- **OpenAL-Soft** - Audio backend (automatically fetched)
- **logcoe** - Logging system (automatically fetched)
- **testcoe** - Testing framework (automatically fetched, tests only)

## Platform Support

soundcoe is tested and validated on:
- **Windows**
- **macOS**
- **Linux**
- **WebAssembly/Emscripten**

## Quick Start

Expand Down Expand Up @@ -113,7 +123,7 @@ For advanced usage examples including 3D spatial audio, fade effects, and custom
- ⚡ **High Performance** - Resource pooling, priority-based allocation, efficient caching
- 🎨 **Sophisticated Effects** - Real-time fade effects with precise timing control
- 📦 **Zero Configuration** - Single include, static functions, no object management
- 🌐 **Cross-Platform** - Windows, Linux, macOS support with OpenAL backend
- 🌐 **Cross-Platform** - Windows, Linux, macOS, WebAssembly support with OpenAL backend

## API Reference

Expand Down Expand Up @@ -234,7 +244,7 @@ int main() {

- **Compiler**: C++17 compatible (GCC 7+, Clang 5+, MSVC 2017+)
- **Build System**: CMake 3.14+
- **Platforms**: Windows, Linux, macOS
- **Platforms**: Windows, Linux, macOS, WebAssembly/Emscripten
- **Audio Hardware**: Required for actual audio playback testing (CI systems are headless)

## Performance Considerations
Expand Down
Loading
Loading