Skip to main content

Crate sdl3_sound_sys

Crate sdl3_sound_sys 

Source
Expand description

§sdl3-sound-sys: Low level Rust bindings for SDL3_sound

These are low level Rust bindings for SDL_sound 3, an add-on library for SDL 3 for decoding several popular sound file formats. This version of sdl3-sound-sys has bindings for SDL_sound version 3.2.0.

sdl3-sound-sys works out of the box on any target that SDL_sound 3 supports and doesn’t require anything else if the SDL_sound 3 library is installed or otherwise available. On targets that support it you can use pkg-config or vcpkg to locate the SDL_sound 3 library if required (see below).

If the SDL_sound 3 library isn’t already available, you have the option of building it from source as part of the build (see below), which requires CMake, a C compiler, and SDL (which can also be built from source via the sdl3-sys crate). Builds for web are supported via Emscripten (wasm32-unknown-emscripten).

Most of the docs are generated directly from the original C headers, which documents how SDL works in C. Using it from Rust might work differently in some cases. For example, macros in C are usually translated to constants or constant functions in Rust, but the docs may still refer to them as macros. Documentation specific to these Rust bindings are tagged with sdl3-sys.

Browse the API at docs.rs!

§Usage

sdl3-sound-sys is compatible with SDL_sound version 3.2.0 or later. Some APIs may require later versions; you can check availability in the documentation. The latest available stable release is recommended.

By default, sdl3-sound-sys will attempt to link to a dynamic/shared library named SDL3_sound in the default library search path, using the usual platform specific naming convention for libraries. You can change this behaviour with the following feature flags.

FeatureDescription
use-pkg-configUse pkg-config to find and link the SDL_sound library.
use-vcpkgUse vcpkg to find and link the SDL_sound library.
build-from-sourceBuild and link SDL_sound from source. You have to install any dependencies SDL needs to build for your target first. See below for build related features.
build-from-source-staticShortcut for enabling both the build-from-source and link-static features. This should no longer be necessary.
link-staticLink SDL_sound statically.
no-linkDon’t link anything, and provide linking flags via Cargo metadata so you can do manual linking if desired.

§Building from source

When building from source with the build-from-source feature flag, you can use features to configure which audio formats to support. Features marked with “(cmake)” below all have an sdlsound- prefix and correspond to SDL_sound’s cmake variables. They’re autodetected if not set. You can use a no- prefix to disable a cmake feature, for example no-sdlsound-mp3 disables mp3 support. Activated features override features disabled with the no- prefix.

§Defaults

Formats are autodetected by default, except for MIDI which is disabled by default because it’s LGPL licensed. You can disable all formats by default and enable only the formats you want.

(This is not a cmake feature)

FeatureDescription
no-default-formatsDisable all formats by default
§Formats

Use sdlsound- prefix to enable and no-sdlsound- prefix to disable, e.g. sdlsound-wav to enable wav. Enables override disables.

None of these formats require additional dependencies.

Feature (cmake)Description
wavEnable WAV support
aiffEnable AIFF support
auEnable AU support
vocEnable VOC support
flacEnable FLAC support
vorbisEnable Vorbis support
rawEnable raw audio support
shnEnable Shorten support
modplugEnable support for various module formats via ModPlug
mp3Enabole MP3, MP2 and MP1 support
midiEnable MIDI support via Timidity. This usues LGPL licensed code. (disabled by default)
coreaudioEnable CoreAudio support on Apple targets

§Other features

FeatureDescription
debug-implsImplement the Debug trait for most SDL_sound types.
metadataEnable metadata. Also see only-metadata.
only-metadataShortcut for enabling both the metadata and no-link features. Recommended when you need metadata but don’t need to call into SDL_sound, e.g. for build scripts.

§Recent changes

  • 0.6.0:
    • First release

See ChangeLog.md for older changes

Modules§

sound
The latest version of SDL_sound can be found at: