Skip to content

Commit

Permalink
new indicator for monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosprint committed May 22, 2024
1 parent 04e8cbb commit fb647ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ fn main() {
}
.prompt();
match output {
Ok(output) => {
record_audio(&args.output, &cli.device, cli.jack).unwrap()
}
Ok(output) => record_audio(output, &cli.device, cli.jack).unwrap(),
Err(_) => println!("Recording cancelled."),
}
}
Expand Down Expand Up @@ -183,9 +181,7 @@ fn main() {
let ans: Result<String, InquireError> =
Select::new("Select a wav file to play", options).prompt();
match ans {
Ok(input) => {
play_audio(&args.input, &cli.device, cli.jack).unwrap()
}
Ok(input) => play_audio(input, &cli.device, cli.jack).unwrap(),
Err(_) => println!("Playback cancelled."),
}
}
Expand Down
56 changes: 35 additions & 21 deletions src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use ratatui::{
prelude::{CrosstermBackend, Terminal, *},
style::{Color, Style},
text::{Span, Text},
widgets::{Block, Borders, Gauge, Paragraph},
widgets::{Block, Borders, Gauge, LineGauge, Paragraph},
};

use ratatui::style::Modifier;
Expand Down Expand Up @@ -222,18 +222,18 @@ fn draw_rec_waveform(
.constraints(
[
Constraint::Length(2),
Constraint::Length(1),
// Constraint::Length(1),
Constraint::Length(1),
// Constraint::Length(4),
// Constraint::Length(4),
Constraint::Length(4),
Constraint::Length(4),
Constraint::Min(4),
Constraint::Length(3),
Constraint::Length(3),
Constraint::Min(3),
]
.as_ref(),
);

let [title, indicator, _padding, rect_left, rect_right, help] = vertical.areas(f.size());
let [title, indicator, rect_left, rect_right, help] = vertical.areas(f.size());

let devices = Paragraph::new(Text::raw(format!(
"INPUT: {};\t OUTPUT: {};",
Expand Down Expand Up @@ -272,6 +272,20 @@ fn draw_rec_waveform(
Color::Green
};

let line_gauge_test = LineGauge::default()
// .block(Block::bordered().title("Progress"))
.gauge_style(
Style::default()
.fg(Color::Green)
.bg(Color::Red)
.add_modifier(Modifier::BOLD),
)
.label("")
.line_set(symbols::line::THICK)
.ratio(0.9);

f.render_widget(line_gauge_test, indicator);

// let peak_db_left = (20. * level[1].0.log10()) as i32;
// let peak_db_right = (20. * level[1].0.log10()) as i32;

Expand Down Expand Up @@ -342,24 +356,24 @@ fn draw_rec_waveform(
f.render_widget(g, rect_right);

// let peak_left = (level[0].1 * 90.) as u64;
let [low, high] =
Layout::horizontal([Constraint::Percentage(90), Constraint::Percentage(10)])
.areas(indicator);
// let [low, high] =
// Layout::horizontal([Constraint::Percentage(90), Constraint::Percentage(10)])
// .areas(indicator);

// let red_line = Block::default()
// .borders(Borders::NONE)
// .style(Style::default().bg(Color::Red));
// // let red_line = Block::default()
// // .borders(Borders::NONE)
// // .style(Style::default().bg(Color::Red));

// f.render_widget(red_line, clippy_indicator);
// // f.render_widget(red_line, clippy_indicator);

let low_level_rect = Block::default()
.borders(Borders::NONE)
.style(Style::default().bg(Color::Green));
f.render_widget(low_level_rect, low);
let high_level_rect = Block::default()
.borders(Borders::NONE)
.style(Style::default().bg(Color::Red));
f.render_widget(high_level_rect, high);
// let low_level_rect = Block::default()
// .borders(Borders::NONE)
// .style(Style::default().bg(Color::Green));
// f.render_widget(low_level_rect, low);
// let high_level_rect = Block::default()
// .borders(Borders::NONE)
// .style(Style::default().bg(Color::Red));
// f.render_widget(high_level_rect, high);
})?;
Ok(())
}
Expand Down

0 comments on commit fb647ec

Please sign in to comment.