Skip to content

Commit

Permalink
update spectrogram
Browse files Browse the repository at this point in the history
  • Loading branch information
aizcutei committed Jul 1, 2024
1 parent 174918a commit 30fdafe
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 408 deletions.
5 changes: 2 additions & 3 deletions src/audio/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ pub fn get_callback(
0.2991878257 * (fc.log10() - 1.0)
};
let t = tc / 0.02133333333;
let c = (db + 80.0)
* 3.1875
let c = (db + 70.0) * 255.0 / 70.0
* buf.setting.spectrogram.brightness_boost as f32;
send_data.spectrogram.f.push(f);
send_data.spectrogram.t.push(t);
Expand Down Expand Up @@ -452,7 +451,7 @@ pub fn get_callback(
send_data.db.r = gain_to_db(amp_r);
}

tx_data.send(send_data).unwrap();
tx_data.send(send_data).unwrap_or_default();
})
}

Expand Down
68 changes: 34 additions & 34 deletions src/frame/setting_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,46 +170,46 @@ impl NanometersApp {
self.tx_setting.as_ref().unwrap().send(self.setting.clone());
};
});
ui.horizontal(|ui| {
ui.label("Contrast");
if ui
.selectable_value(
&mut self.setting.spectrogram.contrast,
setting::SpectrogramContrast::L,
"Low",
)
.changed()
{
self.tx_setting.as_ref().unwrap().send(self.setting.clone());
};
if ui
.selectable_value(
&mut self.setting.spectrogram.contrast,
setting::SpectrogramContrast::M,
"Mid",
)
.changed()
{
self.tx_setting.as_ref().unwrap().send(self.setting.clone());
};
if ui
.selectable_value(
&mut self.setting.spectrogram.contrast,
setting::SpectrogramContrast::H,
"High",
)
.changed()
{
self.tx_setting.as_ref().unwrap().send(self.setting.clone());
};
});
// ui.horizontal(|ui| {
// ui.label("Contrast");
// if ui
// .selectable_value(
// &mut self.setting.spectrogram.contrast,
// setting::SpectrogramContrast::L,
// "Low",
// )
// .changed()
// {
// self.tx_setting.as_ref().unwrap().send(self.setting.clone());
// };
// if ui
// .selectable_value(
// &mut self.setting.spectrogram.contrast,
// setting::SpectrogramContrast::M,
// "Mid",
// )
// .changed()
// {
// self.tx_setting.as_ref().unwrap().send(self.setting.clone());
// };
// if ui
// .selectable_value(
// &mut self.setting.spectrogram.contrast,
// setting::SpectrogramContrast::H,
// "High",
// )
// .changed()
// {
// self.tx_setting.as_ref().unwrap().send(self.setting.clone());
// };
// });
ui.horizontal(|ui| {
ui.label("Brightness Boost");
if ui
.add(
egui::Slider::new(
&mut self.setting.spectrogram.brightness_boost,
0.01..=1.0,
0.01..=1.5,
)
.text(""),
)
Expand Down
Loading

0 comments on commit 30fdafe

Please sign in to comment.