Final clean up and tweaks
This commit is contained in:
parent
604355d906
commit
a98675b3ca
112
src/main.rs
112
src/main.rs
|
@ -7,6 +7,7 @@ mod resamplers;
|
||||||
mod amdemod;
|
mod amdemod;
|
||||||
mod aptsyncer;
|
mod aptsyncer;
|
||||||
|
|
||||||
|
use std::io::prelude::*;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -20,71 +21,32 @@ const LINES_PER_SECOND: u32 = 2;
|
||||||
const PIXELS_PER_LINE: u32 = 2080;
|
const PIXELS_PER_LINE: u32 = 2080;
|
||||||
|
|
||||||
const LOWPASS_COEFFS : [f32; 63] = [ -7.383784e-03,
|
const LOWPASS_COEFFS : [f32; 63] = [ -7.383784e-03,
|
||||||
-3.183046e-03,
|
-3.183046e-03, 2.255039e-03, 7.461166e-03, 1.091908e-02,
|
||||||
2.255039e-03,
|
1.149109e-02, 8.769802e-03, 3.252932e-03, -3.720606e-03,
|
||||||
7.461166e-03,
|
-1.027446e-02, -1.447403e-02, -1.486427e-02, -1.092423e-02,
|
||||||
1.091908e-02,
|
-3.307958e-03, 6.212477e-03, 1.511364e-02, 2.072873e-02,
|
||||||
1.149109e-02,
|
2.096037e-02, 1.492345e-02, 3.347624e-03, -1.138407e-02,
|
||||||
8.769802e-03,
|
-2.560252e-02, -3.507114e-02, -3.591225e-02, -2.553830e-02,
|
||||||
3.252932e-03,
|
-3.371569e-03, 2.882645e-02, 6.711368e-02, 1.060042e-01,
|
||||||
-3.720606e-03,
|
1.394643e-01, 1.620650e-01, 1.700462e-01, 1.620650e-01,
|
||||||
-1.027446e-02,
|
1.394643e-01, 1.060042e-01, 6.711368e-02, 2.882645e-02,
|
||||||
-1.447403e-02,
|
-3.371569e-03, -2.553830e-02, -3.591225e-02, -3.507114e-02,
|
||||||
-1.486427e-02,
|
-2.560252e-02, -1.138407e-02, 3.347624e-03, 1.492345e-02,
|
||||||
-1.092423e-02,
|
2.096037e-02, 2.072873e-02, 1.511364e-02, 6.212477e-03,
|
||||||
-3.307958e-03,
|
-3.307958e-03, -1.092423e-02, -1.486427e-02, -1.447403e-02,
|
||||||
6.212477e-03,
|
-1.027446e-02, -3.720606e-03, 3.252932e-03, 8.769802e-03,
|
||||||
1.511364e-02,
|
1.149109e-02, 1.091908e-02, 7.461166e-03, 2.255039e-03,
|
||||||
2.072873e-02,
|
-3.183046e-03, -7.383784e-03];
|
||||||
2.096037e-02,
|
|
||||||
1.492345e-02,
|
|
||||||
3.347624e-03,
|
|
||||||
-1.138407e-02,
|
|
||||||
-2.560252e-02,
|
|
||||||
-3.507114e-02,
|
|
||||||
-3.591225e-02,
|
|
||||||
-2.553830e-02,
|
|
||||||
-3.371569e-03,
|
|
||||||
2.882645e-02,
|
|
||||||
6.711368e-02,
|
|
||||||
1.060042e-01,
|
|
||||||
1.394643e-01,
|
|
||||||
1.620650e-01,
|
|
||||||
1.700462e-01,
|
|
||||||
1.620650e-01,
|
|
||||||
1.394643e-01,
|
|
||||||
1.060042e-01,
|
|
||||||
6.711368e-02,
|
|
||||||
2.882645e-02,
|
|
||||||
-3.371569e-03,
|
|
||||||
-2.553830e-02,
|
|
||||||
-3.591225e-02,
|
|
||||||
-3.507114e-02,
|
|
||||||
-2.560252e-02,
|
|
||||||
-1.138407e-02,
|
|
||||||
3.347624e-03,
|
|
||||||
1.492345e-02,
|
|
||||||
2.096037e-02,
|
|
||||||
2.072873e-02,
|
|
||||||
1.511364e-02,
|
|
||||||
6.212477e-03,
|
|
||||||
-3.307958e-03,
|
|
||||||
-1.092423e-02,
|
|
||||||
-1.486427e-02,
|
|
||||||
-1.447403e-02,
|
|
||||||
-1.027446e-02,
|
|
||||||
-3.720606e-03,
|
|
||||||
3.252932e-03,
|
|
||||||
8.769802e-03,
|
|
||||||
1.149109e-02,
|
|
||||||
1.091908e-02,
|
|
||||||
7.461166e-03,
|
|
||||||
2.255039e-03,
|
|
||||||
-3.183046e-03,
|
|
||||||
-7.383784e-03];
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut reader = match hound::WavReader::open("noaa19_20160814_mono.wav") {
|
let args : Vec<String> = std::env::args().collect();
|
||||||
|
|
||||||
|
if args.len() != 3 {
|
||||||
|
println!("Usage: {} <wav file> <output file>", args[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut reader = match hound::WavReader::open(&args[1]) {
|
||||||
Err(e) => panic!("Could not open inputfile: {}", e),
|
Err(e) => panic!("Could not open inputfile: {}", e),
|
||||||
Ok(r) => r
|
Ok(r) => r
|
||||||
};
|
};
|
||||||
|
@ -120,7 +82,20 @@ fn main() {
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
let mut max_level = 0.0;
|
let mut max_level = 0.0;
|
||||||
|
|
||||||
|
let mut progress = 0;
|
||||||
|
let step = sample_count * 13 / 150 / 10;
|
||||||
|
|
||||||
|
print!("0%");
|
||||||
|
std::io::stdout().flush().unwrap();
|
||||||
for synced_sample in syncer {
|
for synced_sample in syncer {
|
||||||
|
progress += 1;
|
||||||
|
|
||||||
|
if progress % step == 0 {
|
||||||
|
print!("...{}%", progress / step * 10);
|
||||||
|
std::io::stdout().flush().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let sample = match synced_sample {
|
let sample = match synced_sample {
|
||||||
SyncedSample::Sample(s) => s,
|
SyncedSample::Sample(s) => s,
|
||||||
SyncedSample::SyncA(s) =>{
|
SyncedSample::SyncA(s) =>{
|
||||||
|
@ -136,8 +111,6 @@ fn main() {
|
||||||
max_level = f32::max(sample, max_level);
|
max_level = f32::max(sample, max_level);
|
||||||
let color = (sample / max_level * 255.0) as u8;
|
let color = (sample / max_level * 255.0) as u8;
|
||||||
|
|
||||||
//println!("{}", color);
|
|
||||||
|
|
||||||
if y < lines {
|
if y < lines {
|
||||||
img.put_pixel(x,y,image::Luma([color]));
|
img.put_pixel(x,y,image::Luma([color]));
|
||||||
}
|
}
|
||||||
|
@ -148,7 +121,14 @@ fn main() {
|
||||||
y += 1;
|
y += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("");
|
||||||
|
|
||||||
let ref mut fout = File::create(&Path::new("decoded.png")).unwrap();
|
let ref mut fout = match File::create(&Path::new(&args[2])) {
|
||||||
|
Err(e) => panic!("Could not open outputfile: {}", e),
|
||||||
|
Ok(f) => f
|
||||||
|
};
|
||||||
|
|
||||||
image::ImageLuma8(img).save(fout, image::PNG).unwrap();
|
image::ImageLuma8(img).save(fout, image::PNG).unwrap();
|
||||||
|
|
||||||
|
println!("Done !");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue