Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 1.93 KB

README.md

File metadata and controls

62 lines (45 loc) · 1.93 KB

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.