Crate hps_decode

Crate hps_decode 

Source
Expand description

A 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:

Install dependencies:

cargo add rodio --no-default-features --features playback
cargo add hps_decode --features rodio-source

In 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 library
    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(())
}

§.HPS File Layout

For general purpose, language agnostic documentation of the .hps file format, see here.

Re-exports§

pub use hps::Hps;

Modules§

decoded_hps
Contains DecodedHps for iterating over decoded PCM samples. For looping songs, this is an infinite iterator. While an iterator like this is useful for audio playback, you may need to access the samples directly for other kinds of applications.
decoded_hps_rodio_sourcerodio-source
Contains DecodedHpsRodioSource which can be used to play the song using the rodio crate.
hps
Contains Hps for representing the contents of an .hps file in a structured format.