Simplify getting the audio data
This commit is contained in:
parent
f8ed0e2f1a
commit
c32adf47e6
23
src/main.rs
23
src/main.rs
|
@ -219,19 +219,15 @@ fn ddr2osu(
|
||||||
.with_context(|| format!("failed to read XWB file {}", &xwb_file.clone().display()))?;
|
.with_context(|| format!("failed to read XWB file {}", &xwb_file.clone().display()))?;
|
||||||
let wave_bank = WaveBank::parse(&xwb_data).context("failed to parse XWB file")?;
|
let wave_bank = WaveBank::parse(&xwb_data).context("failed to parse XWB file")?;
|
||||||
|
|
||||||
let audio_data = if wave_bank.sounds.contains_key(&basename) {
|
let audio_data = wave_bank.sounds.get(&basename)
|
||||||
wave_bank
|
.map(|sound| sound.to_wav().with_context(|| {
|
||||||
.sounds
|
|
||||||
.get(&basename)
|
|
||||||
.unwrap()
|
|
||||||
.to_wav()
|
|
||||||
.with_context(|| {
|
|
||||||
format!(
|
format!(
|
||||||
"failed to convert wave bank sound entry “{}” to WAV",
|
"failed to convert wave bank sound entry “{}” to WAV",
|
||||||
basename
|
basename
|
||||||
)
|
)
|
||||||
})?
|
}))
|
||||||
} else if wave_bank.sounds.len() == 2 {
|
.unwrap_or_else(|| {
|
||||||
|
if wave_bank.sounds.len() == 2 {
|
||||||
warn!(
|
warn!(
|
||||||
"Sound {} not found in wave bank, but it has two entries; assuming these are preview and full song",
|
"Sound {} not found in wave bank, but it has two entries; assuming these are preview and full song",
|
||||||
basename
|
basename
|
||||||
|
@ -243,13 +239,14 @@ fn ddr2osu(
|
||||||
"failed to convert wave bank sound entry “{}” to WAV",
|
"failed to convert wave bank sound entry “{}” to WAV",
|
||||||
basename
|
basename
|
||||||
)
|
)
|
||||||
})?
|
})
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow!(
|
Err(anyhow!(
|
||||||
"Could not find matching sound in wave bank (searched for {})",
|
"Could not find matching sound in wave bank (searched for {})",
|
||||||
basename,
|
basename,
|
||||||
));
|
))
|
||||||
};
|
}
|
||||||
|
})?;
|
||||||
|
|
||||||
let osz = osu::osz::Archive {
|
let osz = osu::osz::Archive {
|
||||||
beatmaps,
|
beatmaps,
|
||||||
|
|
Reference in a new issue