hxflac

FLAC audio format support for Haxe
https://github.com/GreenColdTea/hxflac

To install, run:

haxelib install hxflac 1.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

HxFLAC

Haxe support for the FLAC audio format.

This library works on the C++ target only!

Tested on Windows only!

Inspired by hxopus

Installation

haxelib install hxflac

Or through git.

haxelib git hxflac https://github.com/GreenColdTea/hxflac.git

Usage

Hxflac seamlessly integrates with some popular Haxe game frameworks through easy-to-use helper classes:

OpenFL

// Passing the filename in directly
var sound:Sound = FLACHelper.toOpenFLFromFile("path/to/your/sound.flac");
sound.play();

// Or with the raw bytes
var sound:Sound = FLACHelper.toOpenFL(Assets.getBytes("path/to/your/sound.flac"));
sound.play();

// Get metadata from file
var metadata:FLACMetadata = FLACHelper.getMetadataFromFile("path/to/your/sound.flac");
trace('Artist: ${metadata.artist}, Title: ${metadata.title}');

Flixel

// Passing the filename in directly
var sound:FlxSound = FLACHelper.toFlxSoundFromFile("path/to/your/sound.flac");
sound.play();

// Or with the raw bytes
var sound:FlxSound = FLACHelper.toFlxSound(Assets.getBytes("path/to/your/sound.flac"));
sound.play();

// Get sound with metadata
var result = FLACHelper.toFlxSoundWithMetadata("path/to/your/sound.flac");
trace('Playing: ${result.metadata.artist} - ${result.metadata.title}');
result.sound.play();

Metadata Extraction

Hxflac supports reading FLAC metadata including:

Title, Artist, Album Genre, Year, Track Number Comments and etc.

var metadata = FLACHelper.getMetadataFromFile("path/to/your/sound.flac");
if (metadata != null) {
    trace('Title: ${metadata.title}');
    trace('Artist: ${metadata.artist}');
    trace('Album: ${metadata.album}');
    trace('Genre: ${metadata.genre}');
    trace('Year: ${metadata.year}');
    trace('Track: ${metadata.track}');
    trace('Comment: ${metadata.comment}');
}

Other

If you're using another framework, you can use the low-level decoding functions:

// Get decoded PCM bytes
var decodedBytes = FLACHelper.decodeFLAC(bytes);

// Get FLAC version
var version = FLACHelper.getVersionString();

Format Support

FormatStatusOutput
16-bit FLAC16-bit PCM
24-bit FLAC24-bit PCM

Credits

Xiph.org Foundation - LibFLAC.

Vortex2Oblivion - hxopus - Initial idea for creating this library.

NoCopyrightSounds - waera - harinezumi Song used for testing this library.

Contributors
GreenColdTea
Version
1.1.0
Published
today
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