A Rust library for parsing and decoding Super Smash Bros. Melee music files.
Decoding a stereo .hps file into audio and listening to it with
rodio:
Install dependencies:
cargo add rodio --no-default-features --features playback
cargo add hps_decode --features rodio-sourceIn your main.rs:
use hps_decode::Hps;
use rodio::{OutputStreamBuilder, Sink};
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
// Decode an .hps file into raw audio data
let hps: Hps = std::fs::read("./respect-your-elders.hps")?.try_into()?;
let audio = hps.decode()?;
// Play it using the rodio crate
let stream_handle = OutputStreamBuilder::open_default_stream()?;
let sink = Sink::connect_new(&stream_handle.mixer());
let source = audio.into_rodio_source();
sink.append(source);
sink.play();
sink.sleep_until_end();
Ok(())
}Check out docs.rs for more details about the library.
This library can be benchmarked using criterion by running cargo bench. Reports with the results will be generated at target/criterion/report/index.html
For general purpose, language agnostic information about the .hps file format,
see here.