DarylPinto / hps_decode

A Rust library for parsing and decoding Super Smash Bros. Melee music files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HPS Decode

Latest Version Rust Documentation Build Status

A Rust library for parsing and decoding Super Smash Bros. Melee music files.

Quick Start

Decoding a stereo .hps file into audio and listening to it with rodio:

In your Cargo.toml:

[dependencies]
hps_decode = { version = "0.2.1", features = ["rodio-source"] }
rodio = { version = "0.17.3", default-features = false }

In your main.rs:

use hps_decode::Hps;
use rodio::{OutputStream, Sink};
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    // Decode an .hps file into PCM samples for playback
    let hps: Hps = std::fs::read("./respect-your-elders.hps")?.try_into()?;
    let audio = hps.decode()?;

    // Play the song with the rodio library
    let (_stream, stream_handle) = OutputStream::try_default()?;
    let sink = Sink::try_new(&stream_handle)?;

    sink.append(audio);
    sink.play();
    sink.sleep_until_end();

    Ok(())
}

Documentation

Check out docs.rs for more details about the library.

Benchmarking

This library can be benchmarked using criterion by running cargo bench. Reports with the results will be generated at target/criterion/report/index.html

.HPS File Layout

For general purpose, language agnostic information about the .hps file format, see here.

About

A Rust library for parsing and decoding Super Smash Bros. Melee music files

License:MIT License


Languages

Language:Rust 100.0%