haxefmod

Use FMOD Studio with Haxe on HTML5, HashLink, Windows, Linux, and macOS
https://github.com/Tanz0rz/haxe-fmod/

To install, run:

haxelib install haxefmod 3.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

FMOD for Haxe

This library provides FMOD Studio and FMOD Core support for Haxe

Setup instructions, guides, and the API reference live on the documentation site.

Having problems or want to chat? Join the Haxe Discord, then follow the haxe-fmod thread.

Features

If this library does not support something you need, open an Issue.

Supported Platforms

Built and tested on Haxe 4.3.6 and FMOD Engine 2.03.12

PlatformArchitectureHaxeFlixelHeapsKha
HTML5AllWebAssemblyWebAssemblyWebAssembly
Windowsx86_64C++, HashLinkHashLinkKore C++, Kore HL/C
Linuxx86_64C++, HashLinkHashLinkKore C++, Kore HL/C
macOSARM64 (Apple Silicon)C++, HashLinkHashLink through HL/CKore C++, Kore HL/C

Getting Started

The Getting Started section on the docs site is a complete guide to setting up this library in your Haxe project.

Using the Library in Code

The FmodManager class is the primary way to interact with FMOD in your game. The FmodEvents constants used below are generated from your banks (see Generating constants). Every call and its description is in the FmodManager API reference.

public function StartLevel():Void {
    // One background song at a time, additional transition functions available when using this to manage game music
    FmodManager.PlaySong(FmodEvents.MusicMainLevel);
}

public function JumpPressed():Void {
    // Fire-and-forget playback
    FmodManager.PlayOneShot(FmodEvents.SFXJump);
}

var engine:FmodEvent;
public function StartEngine():Void {
    // Handle-based playback for events you control after starting
    engine = FmodManager.PlayEvent(FmodEvents.SFXEngine);
    engine.setParameter("RPM", 0.2);
}

public function OnBeat():Void {
    // Typed callbacks with payloads
    FmodManager.OnSongEvent(data -> switch (data) {
        case TimelineBeat(beat): pulseUI(beat.bar, beat.beat); // your own function
        default:
    });
}

FmodManager covers most common cases, but deeper layers are available for more explicit control:

// Example of reaching beyond FmodManager: everything FMOD Studio exposes is reachable
import haxefmod.studio.StudioSystem;

var music = StudioSystem.getBus("bus:/Music");
music.setVolume(0.5);

var description = StudioSystem.getEvent("event:/Ambience/Forest");
trace(description.getParameterDescriptionCount());

Generating Constants From Your Banks

The export script turns every event, bus, VCA, snapshot, and parameter in your FMOD Studio project into a Haxe constant. Once installed, Ctrl+B in FMOD Studio writes the constants to your project and builds your banks.

Generating constants in the docs covers the details of the setup and what gets generated.

Haxe Constants Demo

FmodManager.PlaySong(FmodEvents.MusicLetsGo);
FmodManager.PlaySong("event:/Music/LetsGo"); // the same call using the explicit path string

FMOD Studio Live Update

One of the most powerful features of the FMOD ecosystem. Mix your sounds in real-time by binding FMOD Studio to a running instance of your game.

Live Update only works on HashLink and C++ builds. HTML5 builds do not support it. The FMOD team says this is a limitation of running games inside web browsers and they do not have plans to support it.

Live Update in the docs covers turning it on and off.

Tracking Sound Work With TODOs

If your code is ready for a sound effect that doesn't exist yet, leave an intelligent marker as a placeholder.

FmodManager.Todo("door creak when the vault opens");
  • haxelib run haxefmod todos lists every remaining marker with its file and line.
  • Builds with -D haxefmod_todo_beep play a short placeholder blip so you hear the sounds that are still missing while playtesting.

More details can be found in the docs here.

fmod.com Extension (beta)

Experimental feature: The code snippets are occasionally incorrect, but this will still provide value if you are a docs-first developer

This modifies the code examples in the official fmod.com documentation to natively include Haxe

The Haxe tab on fmod.com

Migrating From Previous haxe-fmod Versions?

See MIGRATION.md for the complete mapping.

License

MIT

Special Thanks

This entire project was started as an expansion of Aaron Shea's faxe.

Feature Requests and Contact

For feature requests or problems with the library, do one or both of the following:

Contributors
Tanz0rz
Version
3.0.0
Published
6 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂