Compare commits

..

3 commits

3 changed files with 36 additions and 6 deletions

View file

@ -26,7 +26,9 @@ The input music folder needs the following structure:
└ 💾 Music 1
```
Directory/File names must not exceed 31 characters.
Directory/File names must not exceed 31~ characters.
If you encounter issues with song not playing you could try to change the codec to wmav1 or lower the bitrate.
```
Usage: xbst [OPTIONS] [INPUT] [OUTPUT]
@ -36,14 +38,16 @@ Arguments:
[OUTPUT] Output folder for the database and converted musics [default: ./output]
Options:
-b, --bitrate <BITRATE> Bitrate for the output [default: 192]
-b, --bitrate <BITRATE> Bitrate for the output [default: 128]
-c, --codec <CODEC> Codec to use for conversion [default: wmav2] [possible values: wmav1, wmav2]
-h, --help Print help
-V, --version Print version
```
## Known issues
- The progress bar on soundtrack other than the first one doesn't progress
- The progress bar on soundtrack other than the first one doesn't progress.
- Some files, once converted, are quieter than usual?
- When using wmav1, some audio files might sounds absolute ass.
- Untested with a large library, probably has issues?
- Code is poo poo
- Code is poo poo :(

View file

@ -14,7 +14,7 @@ use deunicode::AsciiChars;
use thiserror::Error;
use zerocopy::IntoBytes;
use crate::utils::{Header, MusicFile, Song, Soundtrack};
use crate::utils::{Codec, Header, MusicFile, Song, Soundtrack};
#[derive(Error, Debug)]
enum Errors {
@ -47,6 +47,10 @@ struct Args {
/// Bitrate for the output
#[arg(short, long, default_value_t = 128)]
bitrate: i16,
/// Codec to use for conversion
#[clap(value_enum)]
#[arg(short, long, default_value_t = Codec::Wmav2)]
codec: Codec,
}
fn main() {
@ -139,6 +143,11 @@ fn process(args: &Args) -> Result<(), Errors> {
let song = f.as_ref().unwrap();
let song_path = song.path();
// Ignore non files for song groups
if !song_path.is_file() {
continue;
}
song_id[g] = total_songs_count as i32;
song_time_miliseconds[g] = match get_duration(song_path) {
Ok(s) => s,
@ -278,6 +287,7 @@ fn process(args: &Args) -> Result<(), Errors> {
f.path,
&args.output,
args.bitrate,
&args.codec,
f.soundtrack_index as usize,
f.index as usize,
)?;
@ -312,6 +322,7 @@ fn convert_to_wma(
input: PathBuf,
output: &String,
bitrate: i16,
codec: &Codec,
soundtrack_index: usize,
song_index: usize,
) -> Result<(), Errors> {
@ -326,7 +337,7 @@ fn convert_to_wma(
"-i",
input,
"-acodec",
"wmav1",
&codec.to_string(),
"-ac",
"2",
"-ar",

View file

@ -9,6 +9,21 @@ pub struct MusicFile {
pub index: u32,
}
#[derive(clap::ValueEnum, Debug, Clone)]
pub enum Codec {
Wmav1,
Wmav2,
}
impl ToString for Codec {
fn to_string(&self) -> String {
match self {
Codec::Wmav1 => String::from("wmav1"),
Codec::Wmav2 => String::from("wmav2"),
}
}
}
// https://xboxdevwiki.net/Soundtracks#ST.DB
#[derive(Debug, Immutable, IntoBytes)]
#[repr(C)]