#fmod

libfmod

A library wrapper for integrating FMOD Engine in Rust applications

10 stable releases

2.217.0 Sep 18, 2023
2.2.607 Mar 13, 2023
2.2.604 Nov 14, 2022
2.2.601 Mar 22, 2022
0.1.6 Feb 23, 2022

#84 in Concurrency

Download history 8/week @ 2023-06-07 11/week @ 2023-06-14 38/week @ 2023-06-21 41/week @ 2023-06-28 12/week @ 2023-07-05 9/week @ 2023-07-12 18/week @ 2023-07-19 12/week @ 2023-07-26 5/week @ 2023-08-02 11/week @ 2023-08-09 30/week @ 2023-08-16 25/week @ 2023-08-23 5/week @ 2023-08-30 49/week @ 2023-09-06 149/week @ 2023-09-13 36/week @ 2023-09-20

241 downloads per month
Used in bevy_fmod

MIT license

775KB
19K SLoC

libFMOD Crates.io

A library wrapper for integrating FMOD Engine in Rust applications. FFI wrapped in Rust code to make them safe, more idiomatic and abstract away uncomfortable manual C interface using.

Installation

A crate uses FMOD development libraries version to simplify version match and avoid link-time errors because of incompatible FMOD API changes in patched versions.

FMOD API version encoded in left-most major and minor components. But changes and bug fixes in library wrapper encoded using patch component, such as 2.206.1 or 2.217.1.

For example for FMOD Engine 2.02.06 you should use:

[dependencies]
libfmod = "~2.206"

That means that if backwards compatible bug fix 2.206.2 is published, that will be chosen as the greatest release for your project with FMOD 2.02.06 version.

FMOD Development Libraries

FMOD development libraries can't be integrated and distributed as part of this crate. You should download and install it considering your current licensing option from: https://www.fmod.com/download

Windows

You should manually provide FMOD development libraries for MSVC linker. For the first time you can just put following files to .\target\debug\deps from default FMOD Engine installation folder C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\:

api\core\lib\x64\fmod.dll
api\core\lib\x64\fmod_vc.lib
api\studio\lib\x64\fmodstudio.dll
api\studio\lib\x64\fmodstudio_vc.lib

And then rename fmod_vc.lib and fmodstudio_vc.lib to fmod.lib and fmodstudio.lib accordingly.

Features

You can enable or disable wrapper features depending on your needs:

  • flags provides C-style flags with ergonomic Rust API based on bitflags crate

Getting Started

The simplest way to get started is to initialize the FMOD system, load a sound, and play it. Playing a sound does not block the application, all functions execute immediately, so we should poll for the sound to finish.

use libfmod::{Error, System, Init, Mode};

fn test_playing_sound() -> Result<(), Error> {
    let system = System::create()?;
    system.init(512, Init::NORMAL, None)?;
    let sound = system.create_sound("./data/heartbeat.ogg", Mode::DEFAULT, None)?;
    let channel = system.play_sound(sound, None, false)?;
    while channel.is_playing()? {
        // do something else
    }
    system.release()
}

See more examples in tests folder.

Contributing

This library is automatically generated by libfmod-gen and can't be changed manually. All issues and pull requests must be created in repository of generator.

Dependencies