Skip to content

Commit

Permalink
Remove round_to from audio_length; update lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Oct 11, 2024
1 parent 3ca75a2 commit db89c51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions crates/audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use symphonia::core::{
};

#[byond_fn]
pub fn audio_length(path: PathBuf, round_to: Option<u32>) -> Option<u32> {
let round_to = round_to.unwrap_or(5);
pub fn audio_length(path: PathBuf) -> Option<u32> {
// Open the file
let file = File::open(path).ok()?;

Expand Down Expand Up @@ -50,11 +49,5 @@ pub fn audio_length(path: PathBuf, round_to: Option<u32>) -> Option<u32> {
})?;

// Convert to deciseconds
let deciseconds = (duration.as_secs_f64() * 10.0).ceil() as u32;

// Round to the specified number of deciseconds
match round_to {
0 => Some(deciseconds),
_ => Some(((deciseconds + round_to - 1) / round_to) * round_to),
}
Some((duration.as_secs_f64() * 10.0).ceil() as u32)
}

0 comments on commit db89c51

Please sign in to comment.