Skip to main content

Python bindings for Game Audio Module - a C++ audio system built on miniaudio

Project description

Game Audio Module

A C++20 audio system built on miniaudio with full Python bindings for game development.

Features

  • Layered Music: Multi-track audio with independent layer control and fading
  • Sound Groups: Categorize and control collections of sounds
  • Volume Control: Master, group, and individual sound volume
  • Smooth Transitions: Fade sounds in/out with customizable durations
  • Random Sound Containers: Randomized playback with pitch variation
  • Spatial Audio: 3D positional audio with distance attenuation and directional panning
  • High-Level API: Core primitives designed for user-defined wrappers
  • Python Bindings: Full pybind11 bindings for Python projects (including Basilisk engine)
  • Cross-Platform: Windows, macOS, Linux via miniaudio

Quick Start

For Python Users

Option 1: Install via pip (Recommended for most users)

From PyPI (Recommended - Simplest Version Management)

# Install latest version
pip install game-audio

# Install specific version
pip install game-audio==2.0.0

# Install version range (e.g., any 1.x version, but not 2.0+)
pip install "game-audio>=2.0.0,<3.0.0"

# Upgrade to latest
pip install --upgrade game-audio

# Downgrade to specific version
pip install game-audio==1.0.0

From GitHub Releases (Alternative - For Specific Versions)

If you need a specific version or PyPI is unavailable, install directly from GitHub releases:

# Install specific version (pip will auto-select the correct wheel for your platform)
pip install https://github.com/hannaharmon/game-audio/releases/download/v2.0.0/game_audio-2.0.0-*.whl

# Or specify exact wheel for your platform (Windows example)
pip install https://github.com/hannaharmon/game-audio/releases/download/v2.0.0/game_audio-2.0.0-cp311-cp311-win_amd64.whl

Note: When installing from GitHub releases, you must uninstall before switching to PyPI (or vice versa), as pip treats them as different sources.

Option 2: Build from source with CMake

If you need to build from source or integrate into a CMake project:

1. Add to your project's CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(
    audio_module
    GIT_REPOSITORY https://github.com/hannaharmon/game-audio
    GIT_TAG v2.1.0  # Use a specific version tag for stability
)
FetchContent_MakeAvailable(audio_module)

Important: Always use version tags (e.g., v1.0.0) rather than main branch. Using main means your project may break when breaking changes are merged. Version tags provide stability, predictability, and control over when you upgrade. See RELEASE_MANAGEMENT.md for details.

2. Use in Python (recommended):

import game_audio

# Initialize (keep the session alive for the app lifetime)
session = game_audio.AudioSession()
audio = game_audio.AudioManager.get_instance()

# Create groups and play
music_group = audio.create_group()
sfx_group = audio.create_group()

# Cleanup (optional; session destructor will also handle this)
session.close()

Direct Usage (advanced/engine-controlled):

import game_audio

audio = game_audio.AudioManager.get_instance()
audio.initialize()

music_group = audio.create_group()
sfx_group = audio.create_group()

audio.shutdown()

Full Guide: PYTHON_BINDINGS.md

Note: For use with game engines like Basilisk Engine, you can simply use pip install game-audio instead of adding it to your CMakeLists.txt. This makes integration much simpler!

For C++ Users

1. Add to your CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(
    audio_module
    GIT_REPOSITORY https://github.com/hannaharmon/game-audio
    GIT_TAG v2.1.0  # Pin to specific version for stability
)
FetchContent_MakeAvailable(audio_module)
target_link_libraries(your_game PRIVATE audio_module)

Important: Always use version tags (e.g., v1.0.0) rather than main branch. Using main means your project may break when breaking changes are merged. Version tags provide stability, predictability, and control over when you upgrade. See RELEASE_MANAGEMENT.md for details.

2. Use in C++ (recommended):

#include "audio_manager.h"
#include "audio_session.h"

// Initialize (keep the session alive for the app lifetime)
audio::AudioSession session;
auto& audio = audio::AudioManager::GetInstance();

// Create groups
auto music = audio.CreateGroup();
auto sfx = audio.CreateGroup();

// Cleanup handled automatically by AudioSession destructor (or call session.Close())

Direct Usage (advanced/engine-controlled):

#include "audio_manager.h"

auto& audio = audio::AudioManager::GetInstance();
audio.Initialize();

auto music = audio.CreateGroup();
auto sfx = audio.CreateGroup();

audio.Shutdown();

Full API Reference: Online Documentation

Examples

Building Locally

# Build (cross-platform via PowerShell)
./scripts/build.ps1 -Configurations Debug,Release  # Windows (C++ + Python)
./scripts/build.ps1 -Configurations Release        # Linux/macOS

# Run all tests (C++ + Python)
./tests/scripts/run_all_tests.ps1

# Run only C++ tests
./tests/scripts/run_cpp_tests.ps1

# Run only Python tests
./tests/scripts/run_python_tests.ps1

Build Options:

  • -DBUILD_PYTHON_BINDINGS=OFF - Disable Python bindings
  • -DBUILD_AUDIO_TESTS=OFF - Disable test builds
  • -DBUILD_AUDIO_EXAMPLES=OFF - Disable example builds

Architecture

Core Components:

  • AudioManager - Main API (singleton)
  • AudioSession - RAII helper for scoped initialization/shutdown
  • AudioTrack - Multi-layer synchronized audio
  • AudioGroup - Volume group management
  • Sound - Individual sound instances
  • AudioSystem - miniaudio wrapper

Handles:

  • TrackHandle, GroupHandle, SoundHandle are opaque handle types returned by the API.

High-Level Utilities:

  • RandomSoundContainer - Wwise-style random containers

Testing

Run the comprehensive test suite:

# Run all tests (C++ + Python, both source build and installed wheel)
./tests/scripts/run_all_tests.ps1

# Run only C++ tests
./tests/scripts/run_cpp_tests.ps1

# Run only Python tests (source build)
./tests/scripts/run_python_tests.ps1

# Run only Python tests (installed wheel)
./tests/scripts/run_python_tests.ps1 -UseWheel

The test suite covers:

  • System initialization and lifecycle - AudioSession, AudioManager initialization/shutdown
  • Logging controls - Runtime log level configuration and output
  • Volume control - Master, group, and individual sound volume with proper clamping
  • Group operations - Creation, destruction, volume control, and management
  • Sound loading and playback - File loading, playback control, and state management
  • Track and layer management - Multi-track audio, layer control, and synchronization
  • Input validation - Error handling for invalid handles, paths, and parameters
  • Thread safety - Concurrent operations and resource access
  • Resource management - Proper cleanup, handle validation, and memory management
  • Cross-platform compatibility - Platform-specific code isolation and portability checks

Tests run automatically on every push via GitHub Actions, validating both source builds and installed Python wheels on Windows, Linux, and macOS.

Documentation

Logging

Logging is always available but defaults to Off. Control it at runtime:

// C++
audio::AudioManager::SetLogLevel(audio::LogLevel::Info);  // Enable logging
audio::AudioManager::SetLogLevel(audio::LogLevel::Off);    // Disable logging
# Python
game_audio.AudioManager.set_log_level(game_audio.LogLevel.Info)  # Enable logging
game_audio.AudioManager.set_log_level(game_audio.LogLevel.Off)    # Disable logging

License

This project is released under the Unlicense. See LICENSE for full terms and third-party notices (including miniaudio).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

game_audio-2.1.0-cp313-cp313-win_amd64.whl (420.8 kB view details)

Uploaded CPython 3.13Windows x86-64

game_audio-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (634.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

game_audio-2.1.0-cp313-cp313-macosx_11_0_arm64.whl (453.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

game_audio-2.1.0-cp312-cp312-win_amd64.whl (420.8 kB view details)

Uploaded CPython 3.12Windows x86-64

game_audio-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (634.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

game_audio-2.1.0-cp312-cp312-macosx_11_0_arm64.whl (453.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

game_audio-2.1.0-cp311-cp311-win_amd64.whl (419.2 kB view details)

Uploaded CPython 3.11Windows x86-64

game_audio-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (633.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

game_audio-2.1.0-cp311-cp311-macosx_11_0_arm64.whl (453.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

game_audio-2.1.0-cp310-cp310-win_amd64.whl (418.2 kB view details)

Uploaded CPython 3.10Windows x86-64

game_audio-2.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (631.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file game_audio-2.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 420.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for game_audio-2.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 276eb96fa3fe1f17ff7be64912a3bd81d08f2cfc616aaf645bb275598785e417
MD5 07345acf93443e631609ca24c546d36d
BLAKE2b-256 949ce4862f2bd7e59c4769b8f96ff82cdd980699e5f68bc49aef124717fc5894

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp313-cp313-win_amd64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f25963bcdb2bf1f456e69d79bd1aa08d9137467817c956254337a14c83fe82ee
MD5 892bb65bf6cc92663b1f9cc11f974f8a
BLAKE2b-256 b5d7d8213e55ecd201349d79bf7c0cf7b4f8cd6a5f5002d9f2e4003422643e3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfd95f837271f5f24508a677f0f6581887d70e504b488c5d72dadb5c3a667e48
MD5 7e2b1f1bcd64643db2f5054fe0610438
BLAKE2b-256 f499a3b260eed731e901aaf0589d5ea94b90309f0c6b589af6144705f872fa33

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 420.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for game_audio-2.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 118c776f5bec057c94f030be3fe53af26ec39e04411dc834bfe3cb60d0b83c49
MD5 0e26044b90cd8db37dd92c2185dfd38e
BLAKE2b-256 f5acda1f82105a44e5c64b5dcacd7ee143dfb80c2b02a58a7917e4dc25ac343f

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp312-cp312-win_amd64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2dd5eef5d43c22d299fd0b0d79a76c9bfe2d7c5f013d943ff0712f7e38bbe24d
MD5 83e6d253ac0e4c9ffb54d45625fdb9dd
BLAKE2b-256 daaa6ade3f8fff1d1141353c14a852a1e97d570592fb6f8e1c2238971edfb2e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bbe8a270a5cea617eb820fef80c074960b81ea18baaf18bb751e0adfa7eaa09
MD5 d77d2a76082fd5818ecc417500d7379d
BLAKE2b-256 063e6bce1b8ade8223e2c73a99f6d1e8437c809bd2972d88749730ea9ee74936

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 419.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for game_audio-2.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3e260f33d9825cef6ba846b150844ce097020b8a5e2233dc32490dc68a07acaa
MD5 8656138740815c401a5c79152795a776
BLAKE2b-256 797a51442f829e1dbc9103b876c20c8fccc03fc366d30753eb13da3e862fb972

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp311-cp311-win_amd64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0fae3d5f06b820de87b9248a0562f33124f52ed1f8bd20a50c0cc7467c4f25d
MD5 ce0453277f8f8d47a24a430282a64085
BLAKE2b-256 61817010a365ff1097e6c9bed3876261835473736e81c1f02d2b07fbb93e0492

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 202c302b8ea6f8bfcf67f89d49fe30faaa383e28e4737fcb07fa8ca4c5e4388e
MD5 bd1690f2b4269dec7ae99d240a450d19
BLAKE2b-256 0bfef762919c9e32b4ab12bd80528f66c497fe49ee5cb3216f464d3847df0fc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 418.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for game_audio-2.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2d853952912587e7df33bc2493974402b1fee9684677a5d1beb9d0a11f14d755
MD5 a274c7c6fefbc388c21fce9c41923571
BLAKE2b-256 616674113289250ae21f3fbc70426e6217aed95a14469e0cf593fcd779ec9c6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp310-cp310-win_amd64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file game_audio-2.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c3837e2d6b2df525af2031fc7e8a5354747f658507e563ade831729e0c1480e5
MD5 c83474fe2f537992cb89fdf637b14456
BLAKE2b-256 5925251efee7ab9ca3181fe799cae8f74f79a4f2b3a7240ecf1b70e5cdb6d69a

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on hannaharmon/game-audio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page