generated from lks/eframe_template_android
Compare commits
2 Commits
24d9fc7972
...
6445949083
| Author | SHA1 | Date | |
|---|---|---|---|
| 6445949083 | |||
| dbbd6ab849 |
@ -57,7 +57,8 @@ impl AudioFFT {
|
|||||||
let output: Vec<u8> = fft_out
|
let output: Vec<u8> = fft_out
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
(((c.re * c.re) + (c.im * c.im)).sqrt() / size as f32 * 255.0) as u8
|
(((c.re * c.re) + (c.im * c.im)).sqrt() / output_len as f32 * 255.0)
|
||||||
|
as u8
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(output_len, output.len());
|
assert_eq!(output_len, output.len());
|
||||||
|
|||||||
@ -71,7 +71,7 @@ impl DebugPlots {
|
|||||||
plot_ui.line(line);
|
plot_ui.line(line);
|
||||||
plot_ui.set_plot_bounds(PlotBounds::from_min_max(
|
plot_ui.set_plot_bounds(PlotBounds::from_min_max(
|
||||||
[-1.0, -1.0],
|
[-1.0, -1.0],
|
||||||
[(v.len() + 1) as f64, 256.0],
|
[(v.len() + 1) as f64, core::u8::MAX as f64 + 1.0],
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -79,19 +79,25 @@ impl DebugPlots {
|
|||||||
ui.heading("Bode Plot");
|
ui.heading("Bode Plot");
|
||||||
let mag_line =
|
let mag_line =
|
||||||
Line::new(PlotPoints::from_iter(v.iter().enumerate().map(|(i, c)| {
|
Line::new(PlotPoints::from_iter(v.iter().enumerate().map(|(i, c)| {
|
||||||
[i as f64, ((c.re * c.re) + (c.im * c.im)).sqrt() as f64]
|
[
|
||||||
|
i as f64,
|
||||||
|
((c.re * c.re) + (c.im * c.im)).sqrt() as f64 / v.len() as f64,
|
||||||
|
]
|
||||||
})));
|
})));
|
||||||
let phase_line = Line::new(PlotPoints::from_iter(
|
let phase_line = Line::new(PlotPoints::from_iter(
|
||||||
v.iter()
|
v.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, c)| [i as f64, c.arg() as f64]),
|
.map(|(i, c)| [i as f64, c.arg() as f64 / core::f64::consts::PI]),
|
||||||
));
|
));
|
||||||
let plot = Plot::new(title);
|
let plot = Plot::new(title);
|
||||||
plot.show(ui, |plot_ui| {
|
plot.show(ui, |plot_ui| {
|
||||||
plot_ui.line(mag_line);
|
plot_ui.line(mag_line);
|
||||||
plot_ui.line(phase_line);
|
plot_ui.line(phase_line);
|
||||||
|
plot_ui.set_plot_bounds(PlotBounds::from_min_max(
|
||||||
|
[0.0, -1.0],
|
||||||
|
[(v.len() + 1) as f64, 1.0],
|
||||||
|
));
|
||||||
});
|
});
|
||||||
ui.heading("TODO");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user