Skip to content

Commit

Permalink
cleanup 3
Browse files Browse the repository at this point in the history
  • Loading branch information
lunarcoffee committed Mar 29, 2021
1 parent 04fb49f commit 2ef06de
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gui = ["druid"]

[dependencies]
clap = "2.33.3"
dasp = { version = "0.11.0", features = ["signal", "interpolate", "interpolate-floor", "interpolate-linear"] }
dasp = { version = "0.11.0", features = ["signal", "interpolate", "interpolate-linear"] }
lame = "0.1.3"
minimp3 = "0.5.1"

Expand Down
2 changes: 1 addition & 1 deletion src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn stretch(src: impl Read, dest: &mut impl Write, rate: f64) -> Result<()> {
dest.write_all(&buf[..written]).or(Err(AudioStretchError::DestinationIoError))
}

// Resamples dual channel PCM `samples` by a factor of `rate` in parallel with `threads` worker threads.
// Resamples dual channel PCM `samples` by a factor of `rate` in parallel with `n_threads` worker threads.
fn resample_parallel(samples: Vec<i16>, rate: f64, n_threads: usize) -> (Vec<i16>, Vec<i16>) {
// Split the samples into equally sized chunks and spawn a thread to process each.
let n_chunks = (samples.len() as f64 / n_threads as f64).ceil() as usize;
Expand Down
8 changes: 4 additions & 4 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::util;

pub fn run_gui() -> ! {
let main_window = WindowDesc::new(make_ui).title("osurate | osu! Rate Generator").resizable(false);
let data = AppData { rates_str: Arc::new(String::new()), files: vec![], log: "Info: started\n".to_string() };
let data = AppData { rates_str: Arc::new(String::new()), files: vec![], log: "[Info] started\n".to_string() };

AppLauncher::with_window(main_window)
.delegate(Delegate {})
Expand Down Expand Up @@ -82,16 +82,16 @@ fn make_ui() -> impl Widget<AppData> {
let rates = match rates_iter.collect::<Result<Vec<_>, _>>() {
Ok(r) if r.iter().all(|&r| r >= 0.01) => r,
_ => {
data.log += "Error: invalid rate(s) specified\n";
data.log += "[Error] invalid rate(s) specified\n";
return;
}
};

// Unlike the CLI version, press on after encountering errors.
for file in &data.files {
data.log += &match crate::generate_rates(file, &rates) {
Err(e) => format!("Error: {}\n", e),
Ok(map_name) => format!("Info: generated rate(s) for {}\n", map_name),
Err(e) => format!("[Error] {}\n", e),
Ok(map_name) => format!("[Info] generated rate(s) for {}\n", map_name),
};
}
})
Expand Down
3 changes: 0 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![feature(available_concurrency)]
#![feature(box_syntax)]
#![feature(pub_macro_rules)]
#![feature(slice_as_chunks)]
#![feature(try_trait)]

use std::fs::File;
Expand Down

0 comments on commit 2ef06de

Please sign in to comment.