modified output mechanism
This commit is contained in:
parent
5d48bac3ba
commit
2958db55d1
11
src/main.rs
11
src/main.rs
|
@ -6,6 +6,7 @@ use rustfft::num_complex::Complex;
|
|||
use rustfft::num_traits::Zero;
|
||||
|
||||
use std::io::prelude::*;
|
||||
use std::io::stdout;
|
||||
use std::io::ErrorKind;
|
||||
|
||||
fn main() {
|
||||
|
@ -39,6 +40,9 @@ fn main() {
|
|||
|
||||
let colors:Vec<u8> = vec![16,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255];
|
||||
|
||||
let sout = stdout();
|
||||
let mut slock = sout.lock();
|
||||
|
||||
loop {
|
||||
match source.read_exact(&mut ibuffer) {
|
||||
Err(why) => match why.kind() {
|
||||
|
@ -66,6 +70,7 @@ fn main() {
|
|||
fft_lo.push(filter);
|
||||
}
|
||||
let mut linemax:f32 = 0.0;
|
||||
let mut linestring:String = String::new();
|
||||
for i in 0..width {
|
||||
let fft_pos_1 = (2*i+0)*fft_window_size/(width*2);
|
||||
let fft_pos_2 = (2*i+1)*fft_window_size/(width*2);
|
||||
|
@ -85,10 +90,12 @@ fn main() {
|
|||
if colorindex2 >= colors.len() {
|
||||
colorindex2 = colors.len()-1;
|
||||
}
|
||||
print!("\x1b[38;5;{}m\x1b[48;5;{}m▌", colors[colorindex1], colors[colorindex2]);
|
||||
linestring.push_str(&format!("\x1b[38;5;{}m\x1b[48;5;{}m▌", colors[colorindex1], colors[colorindex2]));
|
||||
//print!("{:10}", power.round());
|
||||
}
|
||||
println!("\x1b[0m");
|
||||
linestring.push_str("\x1b[0m\n");
|
||||
let _ = slock.write_all(&linestring.as_bytes());
|
||||
let _ = slock.flush();
|
||||
if autoscale {
|
||||
scalemax = scalemax*0.99 + linemax*0.01;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue