summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2013-10-05 14:45:42 -0500
committerDavid Barksdale <amatus@amatus.name>2013-10-05 14:45:42 -0500
commit91418dd8b477f415eb0e9ef09e7e4a2cec6b0a8b (patch)
tree9d09190c28c6eb2c13900f1c7e8c3f049ef8b445
parent283c16f6b98c11e77a9d8fc911d3a4d579b3b84e (diff)
Added dump feature.
-rw-r--r--per.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/per.rs b/per.rs
index 9437055..ecfe187 100644
--- a/per.rs
+++ b/per.rs
@@ -1,6 +1,7 @@
extern mod extra;
use extra::getopts::*;
use extra::time::*;
+use std::io::{stdout, stderr};
use std::os;
use std::path::Path;
use std::rt::io::{Create, io_error, Open, Write, Writer};
@@ -23,6 +24,7 @@ fn main() {
"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"),
+ groups::optflag("d", "dump", "Dumps raw samples to stdout"),
];
let DSP_FILES = ~[~"/dev/dsp", ~"/dev/dsp1"];
let DSP_SPEEDS = ~[44100i, 48000i];
@@ -82,8 +84,10 @@ fn main() {
lame.set_bitrate(bitrate);
lame.set_disable_reservoir(true);
lame.init_params();
- println(fmt!("Recording sample rate: %d Hz", speed));
- println(fmt!("Encoding sample rate: %d Hz", lame.get_out_samplerate()));
+ stderr().write_str(fmt!("Recording sample rate: %d Hz\n", speed));
+ stderr().write_str(fmt!("Encoding sample rate: %d Hz\n",
+ lame.get_out_samplerate()));
+ let dump = matches.opt_present("d");
let split = match matches.opt_str("s") {
Some(s) => from_str::<int>(s).unwrap() * 60,
None => 3600
@@ -112,6 +116,9 @@ fn main() {
}
let buffer = port.recv();
debug!("Read buffer of length %u", buffer.len());
+ if dump {
+ stdout().write(buffer);
+ }
let mp3buf = lame.encode_buffer_interleaved(buffer);
debug!("Encoded buffer of length %u", mp3buf.len());
out_file.write(mp3buf);