From 2a3ded6ece091bad01be8077006e628119542fd0 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sat, 5 Oct 2013 13:56:10 -0500 Subject: Added bitrate and quality command line options. --- per.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/per.rs b/per.rs index d476346..f6ac820 100644 --- a/per.rs +++ b/per.rs @@ -20,7 +20,9 @@ fn main() { groups::optopt("s", "split", "Number of minutes at which to split MP3 files", "60"), groups::optflag("a", - "Align splits as if the first one happened midnight Jan. 1, 1970", "") + "Align splits as if the first one happened midnight Jan. 1, 1970", ""), + groups::optopt("b", "bitrate", "MP3 bitrate in kbps", "128"), + groups::optopt("q", "quality", "MP3 quality", "2"), ]; let DSP_FILES = ~[~"/dev/dsp", ~"/dev/dsp1"]; let DSP_SPEEDS = ~[44100i, 48000i]; @@ -67,9 +69,17 @@ fn main() { break; } } + let quality = match matches.opt_str("q") { + Some(q) => from_str::(q).unwrap(), + None => 2 + }; + let bitrate = match matches.opt_str("b") { + Some(b) => from_str::(b).unwrap(), + None => 128 + }; lame.set_in_samplerate(speed); - lame.set_quality(2); - lame.set_bitrate(128); + lame.set_quality(quality); + lame.set_bitrate(bitrate); lame.set_disable_reservoir(true); lame.init_params(); println(fmt!("Recording sample rate: %d Hz", speed)); -- cgit v1.2.3-18-g5258