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:
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(())
}
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.