egui
This commit is contained in:
4486
Cargo.lock
generated
4486
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,4 +4,8 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
eframe = "0.34.3"
|
||||
egui = "0.34.3"
|
||||
egui_plot = "0.35.0"
|
||||
indicatif = "0.18.4"
|
||||
num-complex = "0.4.6"
|
||||
|
||||
@ -28,12 +28,14 @@ pub struct FileSource {
|
||||
pub chunk_samples_size: usize,
|
||||
// raw_buffer position (in samples)
|
||||
pub cursor: usize,
|
||||
// The length of the file in samples
|
||||
pub len: u64,
|
||||
}
|
||||
|
||||
impl FileSource {
|
||||
pub fn new(file_path: &str, chunk_samples_size: usize) -> Result<Self, Box<dyn Error>> {
|
||||
let file = File::open(file_path)?;
|
||||
|
||||
let len = file.metadata().unwrap().len() / 2;
|
||||
// Init buffer with size 16 Mo
|
||||
let reader = BufReader::with_capacity(16 * 1024 * 1024, file);
|
||||
|
||||
@ -45,13 +47,20 @@ impl FileSource {
|
||||
raw_buffer: raw_reader,
|
||||
chunk_samples_size,
|
||||
cursor: chunk_samples_size,
|
||||
len,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ExactSizeIterator for FileSource {}
|
||||
|
||||
impl Iterator for FileSource {
|
||||
type Item = Result<IqSample, Box<dyn Error>>;
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
(self.len as usize, Some(self.len as usize))
|
||||
}
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.cursor >= self.chunk_samples_size {
|
||||
// Buffer read chunk
|
||||
|
||||
60
src/main.rs
60
src/main.rs
@ -1,6 +1,7 @@
|
||||
use crate::iq_reader::FileSource;
|
||||
use crate::pipeline::{AfterDemodPiplineExt, DspPipelineExt};
|
||||
use std::error::Error;
|
||||
use egui_plot::{Line, Plot};
|
||||
use indicatif::ProgressIterator;
|
||||
|
||||
mod agc;
|
||||
mod dc_blocker;
|
||||
@ -11,23 +12,54 @@ mod low_pass;
|
||||
mod pipeline;
|
||||
mod utils;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let source = FileSource::new("test.iq", 32769)?;
|
||||
|
||||
// Fir coefs
|
||||
fn main() -> eframe::Result {
|
||||
let source = FileSource::new("test.iq", 32769).unwrap();
|
||||
let taps = [0.5; 64];
|
||||
|
||||
let pipeline = source
|
||||
let samples: Vec<f32> = source
|
||||
.progress()
|
||||
.agc(20_000_000.0, 1.0, 0.001, 100.0)
|
||||
.fir::<64>(taps, 4)
|
||||
//.fir::<64>(taps, 4)
|
||||
.demodulate()
|
||||
.dc_block(0.995)
|
||||
.lowpass(0.75);
|
||||
.lowpass(0.75)
|
||||
.filter_map(|r| r.ok())
|
||||
.collect();
|
||||
|
||||
for s_r in pipeline {
|
||||
let s = s_r?;
|
||||
println!("phase : {}", s);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
eframe::run_ui_native("DSP", Default::default(), move |ui, _frame| {
|
||||
egui::CentralPanel::default().show(ui, |ui| {
|
||||
Plot::new("plot").show(ui, |plot_ui| {
|
||||
plot_ui.line(Line::new(
|
||||
"Signal",
|
||||
samples
|
||||
.iter()
|
||||
.take(10000)
|
||||
.enumerate()
|
||||
.map(|(i, x)| [i as f64, *x as f64])
|
||||
.collect::<Vec<_>>(),
|
||||
))
|
||||
})
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// fn main() -> Result<(), Box<dyn Error>> {
|
||||
// let source = FileSource::new("test.iq", 32769)?;
|
||||
//
|
||||
// // Fir coefs
|
||||
// let taps = [0.5; 64];
|
||||
//
|
||||
// let pipeline = source
|
||||
// .agc(20_000_000.0, 1.0, 0.001, 100.0)
|
||||
// .fir::<64>(taps, 4)
|
||||
// .demodulate()
|
||||
// .dc_block(0.995)
|
||||
// .lowpass(0.75);
|
||||
//
|
||||
// for s_r in pipeline {
|
||||
// let s = s_r?;
|
||||
// println!("phase : {}", s);
|
||||
// }
|
||||
//
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user