o
odinpkg.dev
packages / binding / odin-faudio

odin-faudio

e938096binding

Odin bindings for the FAudio library

MIT ยท updated 11 months ago

๐ŸŽต Odin-FAudio

License: MIT

๐Ÿš€ Overview

Bindings for the FAudio library, a cross-platform, open-source implementation of the XAudio APIs.

โš ๏ธ WARNING: These bindings are mostly a bindgen-generated first attempt, so keep that in mind and create an issue if you encounter any problems.

โœจ FAudio Features

These bindings provide access to all of FAudio's powerful features:

  • ๐Ÿ”Š XAudio2 API implementation with support for submix voices and mastering
  • ๐ŸŽ› Built-in audio processing effects (reverb, equalization, etc.)
  • ๐ŸŽง Hardware-accelerated 3D audio positioning via F3DAUDIO
  • ๐Ÿ”„ Real-time audio format conversion and resampling
  • ๐Ÿ”Š Support for various audio formats (PCM, ADPCM, xWMA)
  • ๐ŸŽš๏ธ XAPO (audio processing objects) framework for custom audio effects
  • ๐ŸŽจ XACT3 audio engine support for content-driven audio
  • ๐Ÿ“ฑ Cross-platform compatibility (Windows, macOS, Linux, iOS, Android)
  • ๐ŸŽฎ Designed specifically for game audio needs
  • ๐ŸŽน STB Vorbis integration for Ogg Vorbis decoding

๐Ÿ”ง Usage

import "path/to/faudio"

// Initialize FAudio
faudio_engine: ^faudio.FAudio
faudio.FAudioCreate(&faudio_engine, 0, faudio.FAUDIO_DEFAULT_PROCESSOR)

// Create a mastering voice
mastering_voice: ^faudio.FAudioMasteringVoice
faudio.FAudio_CreateMasteringVoice(
    faudio_engine,
    &mastering_voice,
    2,                // Two channels for stereo
    48000,            // 48kHz sample rate
    0,                // No special effects
    nil,              // Use default device ID
    nil,              // No effect chain
    faudio.AudioCategory_GameEffects
)

// Clean up when done
faudio.FAudioVoice_DestroyVoice(mastering_voice)
faudio.FAudio_Release(faudio_engine)

๐Ÿ› ๏ธ Building Projects

When using these bindings in your project:

  • ๐Ÿ’ป On Windows: Link against FAudio.lib
  • ๐Ÿง On Linux/macOS: The library will be linked as system:FAudio, so either have FAudio installed in your system or follow the Linux/macOS Configuration instructions below.

Linux/macOS Configuration

On Linux/macOS, if you want to use a local FAudio installation, you'll also need an SDL3 build, and after that you can follow these steps:

# Clone or git subtree the FAudio repository
git subtree add --prefix=vendor/FAudio https://github.com/FNA-XNA/FAudio.git [LATEST_TAG] --squash

# Build it (SDL3 is required, and we're using an example `vendor` directory here)
mkdir -p vendor/FAudio/build
cd ./vendor/FAudio/build
cmake .. -DSDL3_DIR=/path/to/SDL3/build
make -j$(nproc)

# Make sure the linker can find your local FAudio build
odin build [your_project] \
    -extra-linker-flags:"-L/path/to/vendor/FAudio/build -Wl,-rpath,/path/to/vendor/FAudio/build"

I'm sure you can do something similar in Windows, but I don't know how to do it ๐Ÿคทโ€โ™‚๏ธ.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgements

  • FAudio - The amazing library these bindings are built for
  • Odin Language - The programming language used for these bindings