mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-09 08:31:33 +11:00
Add s3m and mod support to the desktop player
This commit is contained in:
parent
05b5b3e882
commit
5b9332556d
|
@ -12,6 +12,7 @@ agb_xm_core = { version = "0.21.0", path = "../agb-xm-core" }
|
||||||
agb_tracker = { version = "0.21.0", path = "../agb-tracker", default-features = false }
|
agb_tracker = { version = "0.21.0", path = "../agb-tracker", default-features = false }
|
||||||
agb_fixnum = { version = "0.21.0", path = "../../agb-fixnum" }
|
agb_fixnum = { version = "0.21.0", path = "../../agb-fixnum" }
|
||||||
|
|
||||||
|
anyhow = "1"
|
||||||
xmrs = "0.7"
|
xmrs = "0.7"
|
||||||
|
|
||||||
cpal = "0.15"
|
cpal = "0.15"
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
use std::{env, error::Error, fs, path::Path, sync::mpsc};
|
use std::{env, fs, path::Path, sync::mpsc};
|
||||||
|
|
||||||
use cpal::{
|
use cpal::{
|
||||||
traits::{DeviceTrait, HostTrait, StreamTrait},
|
traits::{DeviceTrait, HostTrait, StreamTrait},
|
||||||
SampleFormat, SampleRate,
|
SampleFormat, SampleRate,
|
||||||
};
|
};
|
||||||
use mixer::Mixer;
|
use mixer::Mixer;
|
||||||
use xmrs::{module::Module, xm::xmmodule::XmModule};
|
use xmrs::{
|
||||||
|
amiga::amiga_module::AmigaModule, module::Module, s3m::s3m_module::S3mModule,
|
||||||
|
xm::xmmodule::XmModule,
|
||||||
|
};
|
||||||
|
|
||||||
mod mixer;
|
mod mixer;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
let file_path = &args[1];
|
let file_path = &args[1];
|
||||||
|
@ -60,7 +63,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_module_from_file(xm_path: &Path) -> Result<Module, Box<dyn Error>> {
|
fn load_module_from_file(xm_path: &Path) -> anyhow::Result<Module> {
|
||||||
let file_content = fs::read(xm_path)?;
|
let file_content = fs::read(xm_path)?;
|
||||||
Ok(XmModule::load(&file_content)?.to_module())
|
|
||||||
|
match xm_path.extension().and_then(|ex| ex.to_str()) {
|
||||||
|
Some("xm") => Ok(XmModule::load(&file_content)?.to_module()),
|
||||||
|
Some("s3m") => Ok(S3mModule::load(&file_content)?.to_module()),
|
||||||
|
Some("mod") => Ok(AmigaModule::load(&file_content)?.to_module()),
|
||||||
|
ex => anyhow::bail!("Invalid file extension {ex:?}"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue