|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
use std::{error::Error, fs::File, io::Read, convert::TryInto, collections::HashMap};
|
|
|
|
|
use flate2::read::ZlibDecoder;
|
|
|
|
|
use linked_hash_set::LinkedHashSet;
|
|
|
|
|
use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, print_info, sanitize_string}, soundtrack::types::{SampleFormat, PsgEnvelope, Note, Sample, PsgSettings, PatternRow, Effect, DcsgChannelMode, NoiseType, Instrument, InstrumentType, Fm2612Operator, Fm2612Settings, Channel, CombinedAssets}};
|
|
|
|
|
use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, print_info, sanitize_string, print_warning}, soundtrack::types::{SampleFormat, PsgEnvelope, Note, Sample, PsgSettings, PatternRow, Effect, DcsgChannelMode, NoiseType, Instrument, InstrumentType, Fm2612Operator, Fm2612Settings, Channel, CombinedAssets}};
|
|
|
|
|
|
|
|
|
|
const DMF_MAGIC_NUMBER: &'static str = ".DelekDefleMask.";
|
|
|
|
|
const DMF_SUPPORTED_VERSION: u8 = 27;
|
|
|
|
@ -669,7 +669,10 @@ impl DmfModule {
|
|
|
|
|
let bitrate = match get_u8( bytes.by_ref() )? {
|
|
|
|
|
8 => SampleFormat::Bits8,
|
|
|
|
|
16 => SampleFormat::Bits16,
|
|
|
|
|
invalid => return Err( format!( "invalid file: invalid bitrate {}", invalid ) )?
|
|
|
|
|
invalid => {
|
|
|
|
|
print_warning( &format!( "sample with invalid bitrate: {}", invalid ) );
|
|
|
|
|
SampleFormat::Invalid
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -685,8 +688,11 @@ impl DmfModule {
|
|
|
|
|
sample.data.push( get_i16( bytes.by_ref() )? );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't push no-names or invalid bitrates
|
|
|
|
|
if sample.name != "" && !matches!( sample.bitrate, SampleFormat::Invalid ) {
|
|
|
|
|
samples.push( sample );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(
|
|
|
|
|
DmfModule {
|
|
|
|
|