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()))?;
|
||||
let wave_bank = WaveBank::parse(&xwb_data).context("failed to parse XWB file")?;
|
||||
|
||||
let audio_data = if wave_bank.sounds.contains_key(&basename) {
|
||||
wave_bank
|
||||
.sounds
|
||||
.get(&basename)
|
||||
.unwrap()
|
||||
.to_wav()
|
||||
.with_context(|| {
|
||||
let audio_data = wave_bank.sounds.get(&basename)
|
||||
.map(|sound| sound.to_wav().with_context(|| {
|
||||
format!(
|
||||
"failed to convert wave bank sound entry “{}” to WAV",
|
||||
basename
|
||||
)
|
||||
})?
|
||||
} else if wave_bank.sounds.len() == 2 {
|
||||
}))
|
||||
.unwrap_or_else(|| {
|
||||
if wave_bank.sounds.len() == 2 {
|
||||
warn!(
|
||||
"Sound {} not found in wave bank, but it has two entries; assuming these are preview and full song",
|
||||
basename
|
||||
|
@ -243,13 +239,14 @@ fn ddr2osu(
|
|||
"failed to convert wave bank sound entry “{}” to WAV",
|
||||
basename
|
||||
)
|
||||
})?
|
||||
})
|
||||
} else {
|
||||
return Err(anyhow!(
|
||||
Err(anyhow!(
|
||||
"Could not find matching sound in wave bank (searched for {})",
|
||||
basename,
|
||||
));
|
||||
};
|
||||
))
|
||||
}
|
||||
})?;
|
||||
|
||||
let osz = osu::osz::Archive {
|
||||
beatmaps,
|
||||
|
|
Reference in a new issue