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
  • 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.0.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.0.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.0.0-cp313-cp313-win_amd64.whl (403.5 kB view details)

Uploaded CPython 3.13Windows x86-64

game_audio-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (608.6 kB view details)

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

game_audio-2.0.0-cp313-cp313-macosx_11_0_arm64.whl (433.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

game_audio-2.0.0-cp312-cp312-win_amd64.whl (403.5 kB view details)

Uploaded CPython 3.12Windows x86-64

game_audio-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (608.6 kB view details)

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

game_audio-2.0.0-cp312-cp312-macosx_11_0_arm64.whl (433.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

game_audio-2.0.0-cp311-cp311-win_amd64.whl (401.8 kB view details)

Uploaded CPython 3.11Windows x86-64

game_audio-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (607.0 kB view details)

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

game_audio-2.0.0-cp311-cp311-macosx_11_0_arm64.whl (433.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

game_audio-2.0.0-cp310-cp310-win_amd64.whl (400.6 kB view details)

Uploaded CPython 3.10Windows x86-64

game_audio-2.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (605.4 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.0.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.0.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 403.5 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.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 077779bafff4d07c0f602f83c544d2e1d21d31e14aa479f5df382202494eb9bc
MD5 eaad06eb8d544a29b6583c1c70a5efc4
BLAKE2b-256 6be5097b27371b601040d6e5795eb606e8189bfc548c45012cffef97ec8aaa39

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 019dfe29f88f2f7e71af206cabcc04ce328c82a93b7b7ce1e899a2863a3f480a
MD5 693584b6f409adc305f045031a0ca2bc
BLAKE2b-256 7eb03d33ff7a9ed1ae1a2f7d6f9ae60155dd15617a4e943126fc7182adc9b6bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f522aa3cc915378e10d193090363462d9879f65425e746eb8aebd334dffe44d
MD5 33cd6be9d0d6e729855fb4993bfff6ae
BLAKE2b-256 08bae2b4d5f1b4af1ec22e87827cb3a2166e16b15f107a01ee0752c757099cea

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 403.5 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.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 75042d5eff39e71ad0d9a3335bc3074287f8fd57bedd424e5c93d1234be39a1e
MD5 2f443336f0f58e6e919d65a172706354
BLAKE2b-256 3891618c0e9d9c2ecd0667836dedbe58fbb9214e21261a70a4faf248065d4fe4

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 714aa0c309fd7139b0bc9671aa52969111538b3308ccbbd228a1eec85bd3dbbc
MD5 ede31ecdf685ee8141c35ae15d76e68e
BLAKE2b-256 fce9731295223d8f13d91e7cdda0d596feee1748630306a11cc61ad55568b8e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c8056370004b43d870236bfd982fdaf165741e11de2938e795278f53f0e81a6a
MD5 ae9c20dd7251dfdaa779ac15c7da2fca
BLAKE2b-256 92590c3b25d380e2637130dff4d2bfcc36f79b0a0721290006095b745f7f2352

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 401.8 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.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2c6922e047063cccc902175c3dff369e753d99fc689337a6c56aaec1b808d9d3
MD5 2301df85afb4199f01224431347fc7ef
BLAKE2b-256 51f213f10be7af45e51251927564721d10ce51b70060e4c03f3045b7a2a808b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d12eba7cb9a31f15cae0d4658b901d878a1e73edc95f7277e6e2aa709b88e739
MD5 4733b5a94f7a65a8915e92983164a33b
BLAKE2b-256 09a355fed582a4c0351e794660ce0f93c7393fc6d79feef21cf174f6eaf1c590

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b4851c495f38828f3917ba08baaa260e0f755269f5d2bb5fc1eb36da9c47fbc
MD5 fff8978bc5ef471aa0fb04a03f55eabc
BLAKE2b-256 b62bcd7ff5cfbead02884023a04a47368b512a48470464eef588600cee1300e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: game_audio-2.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 400.6 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.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 60cfca5e7d40682c83f0c47fa34404cce1a3547df52f74992d5af163bc4942fb
MD5 e03aece80e51dd858afc7d7b4af76cc3
BLAKE2b-256 a1fc48288e6893450d69e85066c66bba8a69a0ec6d81cd04eafa2d2e427d3402

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for game_audio-2.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00d04cff36b846b4f763f272402292b0e87f6adc5a787412a3eec856e4f8b567
MD5 b420f2aa0a727b8e24d808218f47e27d
BLAKE2b-256 e76d231368dab4f86112c7dd3b53f05ac0facd2afeda799d1290f5f5c5a49345

See more details on using hashes here.

Provenance

The following attestation bundles were made for game_audio-2.0.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