Add panic logging test
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@@ -324,7 +324,10 @@ dependencies = [
|
|||||||
name = "ebu-dsp"
|
name = "ebu-dsp"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"crossbeam",
|
||||||
|
"log",
|
||||||
"nih_plug",
|
"nih_plug",
|
||||||
|
"simplelog",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -336,6 +339,7 @@ dependencies = [
|
|||||||
"ebu-dsp",
|
"ebu-dsp",
|
||||||
"femtovg",
|
"femtovg",
|
||||||
"image",
|
"image",
|
||||||
|
"log",
|
||||||
"nih_plug",
|
"nih_plug",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -940,6 +944,17 @@ version = "0.3.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simplelog"
|
||||||
|
version = "0.12.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "16257adbfaef1ee58b1363bdc0664c9b8e1e30aed86049635fb5f147d065a9c0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"termcolor",
|
||||||
|
"time",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slotmap"
|
name = "slotmap"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ crossbeam = "0.8.4"
|
|||||||
femtovg = "0.18.1"
|
femtovg = "0.18.1"
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
image = { version = "0.25.9", default-features = false, features = ["png"] }
|
image = { version = "0.25.9", default-features = false, features = ["png"] }
|
||||||
|
log = "0.4.28"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["ebu-dsp"]
|
members = ["ebu-dsp"]
|
||||||
|
|||||||
@@ -5,3 +5,6 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false }
|
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", version = "0.0.0", default-features = false }
|
||||||
|
log = "0.4.28"
|
||||||
|
simplelog = "0.12.2"
|
||||||
|
crossbeam = "0.8.4"
|
||||||
|
|||||||
@@ -2,26 +2,28 @@ mod amplitude;
|
|||||||
mod biquad;
|
mod biquad;
|
||||||
mod comp;
|
mod comp;
|
||||||
mod decibel;
|
mod decibel;
|
||||||
|
mod eq;
|
||||||
mod freq_split;
|
mod freq_split;
|
||||||
mod meter;
|
mod meter;
|
||||||
mod ring_buffer;
|
mod ring_buffer;
|
||||||
mod smoother;
|
mod smoother;
|
||||||
mod traits;
|
mod traits;
|
||||||
mod eq;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Debug,
|
fmt::Debug, ops::Add, panic, time::Duration
|
||||||
ops::Add,
|
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub use amplitude::Amplitude;
|
||||||
pub use biquad::{BiquadFilter, BiquadFilterState, FilterMode, Slope};
|
pub use biquad::{BiquadFilter, BiquadFilterState, FilterMode, Slope};
|
||||||
pub use comp::{Compressor, CompressorState};
|
pub use comp::{Compressor, CompressorState};
|
||||||
pub use freq_split::{FreqSplitter, FreqSplitterState};
|
use crossbeam::atomic::AtomicCell;
|
||||||
pub use traits::{FloatFormatter, IntFormatter, Lerp, Processor};
|
|
||||||
pub use decibel::Decibel;
|
pub use decibel::Decibel;
|
||||||
pub use amplitude::Amplitude;
|
|
||||||
pub use eq::{Equalizer, EqualizerState};
|
pub use eq::{Equalizer, EqualizerState};
|
||||||
|
pub use freq_split::{FreqSplitter, FreqSplitterState};
|
||||||
|
use log::{error, info};
|
||||||
|
use nih_plug::{nih_error, util::permit_alloc};
|
||||||
|
use simplelog::{CombinedLogger, Config, SimpleLogger, WriteLogger};
|
||||||
|
pub use traits::{FloatFormatter, IntFormatter, Lerp, Processor};
|
||||||
|
|
||||||
pub struct Rect<T> {
|
pub struct Rect<T> {
|
||||||
pub x: T,
|
pub x: T,
|
||||||
@@ -196,3 +198,27 @@ pub fn rms<const N: usize>(sample_buffer: &RingBuffer<f64, N>, last_rms: f64) ->
|
|||||||
last_rms.powf(2.0)
|
last_rms.powf(2.0)
|
||||||
+ (1.0 / N as f64) * (sample_buffer[0].powf(2.0) - sample_buffer[N - 1].powf(2.0))
|
+ (1.0 / N as f64) * (sample_buffer[0].powf(2.0) - sample_buffer[N - 1].powf(2.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LOGGER: AtomicCell<Option<Box<CombinedLogger>>> = AtomicCell::new(None);
|
||||||
|
|
||||||
|
pub fn init() {
|
||||||
|
permit_alloc(|| {
|
||||||
|
let log_file = std::fs::File::create("airfreshener.log").unwrap();
|
||||||
|
let term_log = SimpleLogger::new(log::LevelFilter::Debug, Config::default());
|
||||||
|
let file_log = WriteLogger::new(log::LevelFilter::Debug, Config::default(), log_file);
|
||||||
|
LOGGER.store(Some(simplelog::CombinedLogger::new(vec![
|
||||||
|
term_log, file_log,
|
||||||
|
])));
|
||||||
|
info!("Log check");
|
||||||
|
panic::set_hook(Box::new(|info| {
|
||||||
|
if let Some(str) = info.payload().downcast_ref::<String>() {
|
||||||
|
error!("Panic! {str}\n{:?}", info.location());
|
||||||
|
nih_error!("Panic! {str}\n{:?}", info.location());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Panic! No info provided.\n{:?}", info.location());
|
||||||
|
nih_error!("Panic! No info provided.\n{:?}", info.location());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ impl Plugin for AirFreshener {
|
|||||||
buffer_config: &BufferConfig,
|
buffer_config: &BufferConfig,
|
||||||
_context: &mut impl InitContext<Self>,
|
_context: &mut impl InitContext<Self>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
ebu_dsp::init();
|
||||||
|
|
||||||
let sample_rate = SampleRate(buffer_config.sample_rate as f64);
|
let sample_rate = SampleRate(buffer_config.sample_rate as f64);
|
||||||
for _ in 0.._audio_io_layout
|
for _ in 0.._audio_io_layout
|
||||||
.main_input_channels
|
.main_input_channels
|
||||||
|
|||||||
Reference in New Issue
Block a user