Refactor into engines/formats folders

master
Ashley N. 2023-08-19 12:59:00 -04:00
parent 2e0a07c189
commit 3aa311c8f5
6 changed files with 19 additions and 11 deletions

View File

@ -8,7 +8,8 @@ use std::error::Error;
use std::fs::File;
use std::io::Write;
use clap::{App, Arg, SubCommand};
use reskit::soundtrack::dmf::DmfModule;
use reskit::soundtrack::engines::echo::EchoFormat;
use reskit::soundtrack::formats::dmf::DmfModule;
use reskit::utility;
use reskit::tileset;

View File

@ -0,0 +1,7 @@
use std::{collections::HashMap, error::Error};
pub trait EchoFormat {
fn get_eefs( &self ) -> Result<HashMap<String, Vec<u8>>, Box<dyn Error>>;
}

View File

@ -0,0 +1 @@
pub mod echo;

View File

@ -1,8 +1,6 @@
use std::{error::Error, fs::File, io::Read, convert::TryInto, collections::HashMap, cmp::{min, max}};
use flate2::read::ZlibDecoder;
use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, Ring}, soundtrack::types::{SampleRate, SampleFormat, PsgEnvelope}};
use super::types::{Sample, Note, PsgSettings};
use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, Ring}, soundtrack::{types::{SampleRate, SampleFormat, PsgEnvelope, Note, Sample, PsgSettings}, engines::echo::EchoFormat}};
const DMF_MAGIC_NUMBER: &'static str = ".DelekDefleMask.";
const DMF_SUPPORTED_VERSION: u8 = 0x18;
@ -596,7 +594,11 @@ impl DmfModule {
)
}
pub fn get_eefs( &self ) -> Result<HashMap<String, Vec<u8>>, Box<dyn Error>> {
}
impl EchoFormat for DmfModule {
fn get_eefs( &self ) -> Result<HashMap<String, Vec<u8>>, Box<dyn Error>> {
let mut eefs: HashMap<String, Vec<u8>> = HashMap::new();
for instrument in &self.instruments {
@ -725,11 +727,6 @@ impl DmfModule {
Ok( eefs )
}
pub fn get_esf( &self ) -> Result<Vec<u8>, Box<dyn Error>> {
// TODO !!
todo!()
}
}
fn get_eef_volume( dmf_volume: u8 ) -> Result<u8, Box<dyn Error>> {

View File

@ -0,0 +1 @@
pub mod dmf;

View File

@ -1,2 +1,3 @@
pub mod dmf;
pub mod formats;
pub mod engines;
pub mod types;