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"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
eframe = "0.34.3"
|
||||||
|
egui = "0.34.3"
|
||||||
|
egui_plot = "0.35.0"
|
||||||
|
indicatif = "0.18.4"
|
||||||
num-complex = "0.4.6"
|
num-complex = "0.4.6"
|
||||||
|
|||||||
@ -28,12 +28,14 @@ pub struct FileSource {
|
|||||||
pub chunk_samples_size: usize,
|
pub chunk_samples_size: usize,
|
||||||
// raw_buffer position (in samples)
|
// raw_buffer position (in samples)
|
||||||
pub cursor: usize,
|
pub cursor: usize,
|
||||||
|
// The length of the file in samples
|
||||||
|
pub len: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSource {
|
impl FileSource {
|
||||||
pub fn new(file_path: &str, chunk_samples_size: usize) -> Result<Self, Box<dyn Error>> {
|
pub fn new(file_path: &str, chunk_samples_size: usize) -> Result<Self, Box<dyn Error>> {
|
||||||
let file = File::open(file_path)?;
|
let file = File::open(file_path)?;
|
||||||
|
let len = file.metadata().unwrap().len() / 2;
|
||||||
// Init buffer with size 16 Mo
|
// Init buffer with size 16 Mo
|
||||||
let reader = BufReader::with_capacity(16 * 1024 * 1024, file);
|
let reader = BufReader::with_capacity(16 * 1024 * 1024, file);
|
||||||
|
|
||||||
@ -45,13 +47,20 @@ impl FileSource {
|
|||||||
raw_buffer: raw_reader,
|
raw_buffer: raw_reader,
|
||||||
chunk_samples_size,
|
chunk_samples_size,
|
||||||
cursor: chunk_samples_size,
|
cursor: chunk_samples_size,
|
||||||
|
len,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ExactSizeIterator for FileSource {}
|
||||||
|
|
||||||
impl Iterator for FileSource {
|
impl Iterator for FileSource {
|
||||||
type Item = Result<IqSample, Box<dyn Error>>;
|
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> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.cursor >= self.chunk_samples_size {
|
if self.cursor >= self.chunk_samples_size {
|
||||||
// Buffer read chunk
|
// Buffer read chunk
|
||||||
|
|||||||
60
src/main.rs
60
src/main.rs
@ -1,6 +1,7 @@
|
|||||||
use crate::iq_reader::FileSource;
|
use crate::iq_reader::FileSource;
|
||||||
use crate::pipeline::{AfterDemodPiplineExt, DspPipelineExt};
|
use crate::pipeline::{AfterDemodPiplineExt, DspPipelineExt};
|
||||||
use std::error::Error;
|
use egui_plot::{Line, Plot};
|
||||||
|
use indicatif::ProgressIterator;
|
||||||
|
|
||||||
mod agc;
|
mod agc;
|
||||||
mod dc_blocker;
|
mod dc_blocker;
|
||||||
@ -11,23 +12,54 @@ mod low_pass;
|
|||||||
mod pipeline;
|
mod pipeline;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> eframe::Result {
|
||||||
let source = FileSource::new("test.iq", 32769)?;
|
let source = FileSource::new("test.iq", 32769).unwrap();
|
||||||
|
|
||||||
// Fir coefs
|
|
||||||
let taps = [0.5; 64];
|
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)
|
.agc(20_000_000.0, 1.0, 0.001, 100.0)
|
||||||
.fir::<64>(taps, 4)
|
//.fir::<64>(taps, 4)
|
||||||
.demodulate()
|
.demodulate()
|
||||||
.dc_block(0.995)
|
.dc_block(0.995)
|
||||||
.lowpass(0.75);
|
.lowpass(0.75)
|
||||||
|
.filter_map(|r| r.ok())
|
||||||
|
.collect();
|
||||||
|
|
||||||
for s_r in pipeline {
|
eframe::run_ui_native("DSP", Default::default(), move |ui, _frame| {
|
||||||
let s = s_r?;
|
egui::CentralPanel::default().show(ui, |ui| {
|
||||||
println!("phase : {}", s);
|
Plot::new("plot").show(ui, |plot_ui| {
|
||||||
}
|
plot_ui.line(Line::new(
|
||||||
|
"Signal",
|
||||||
Ok(())
|
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