35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
pub mod types;
|
|
|
|
use std::io::Write;
|
|
use tool_helper::{Error, Input};
|
|
use types::MonoADPCMIterator;
|
|
|
|
pub fn convert(input: Input, _output: &mut dyn Write) -> Result<(), Error> {
|
|
let mut wav_file = hound::WavReader::new(input)?;
|
|
let wav_header = wav_file.spec();
|
|
|
|
validate(&wav_header)?;
|
|
let mut sample_count = 0;
|
|
for _adpcm_samples in MonoADPCMIterator::create(wav_file.samples::<i16>()) {
|
|
sample_count += 1;
|
|
}
|
|
|
|
println!("Parsed {} vag samples", sample_count);
|
|
Err(Error::not_implemented("my vag convert"))
|
|
}
|
|
|
|
fn validate(wav_header: &hound::WavSpec) -> Result<(), Error> {
|
|
if wav_header.sample_format != hound::SampleFormat::Int {
|
|
return Err(Error::from_str("VAG: Only integer samples are supported as input."));
|
|
}
|
|
|
|
if wav_header.bits_per_sample != 16 {
|
|
return Err(Error::from_str("VAG: Only 16bits samples are currently supported as input."));
|
|
}
|
|
|
|
if wav_header.channels != 1 {
|
|
return Err(Error::from_str("VAG: Only mono samples are currently supported"));
|
|
}
|
|
|
|
Ok(())
|
|
} |