Skip to content

Commit

Permalink
Roll own gain to dB conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
exa04 committed Apr 15, 2024
1 parent 0d7ac88 commit ba30a4d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod spectrum;
pub use buffers::*;
pub use spectrum::*;

use nih_plug::util::{db_to_gain, gain_to_db_fast};
use nih_plug::util::db_to_gain;
use nih_plug_vizia::vizia::binding::Res;
use nih_plug_vizia::vizia::context::{Context, EventContext};
use nih_plug_vizia::vizia::entity::Entity;
Expand Down Expand Up @@ -65,7 +65,10 @@ impl ValueScaling {
(value.log2() - minl) / range
}

ValueScaling::Decibels => unmap(gain_to_db_fast(value)),
ValueScaling::Decibels => unmap({
const CONVERSION_FACTOR: f32 = std::f32::consts::LOG10_E * 20.0;
value.ln() * CONVERSION_FACTOR
}),
}
.clamp(0., 1.)
}
Expand Down

0 comments on commit ba30a4d

Please sign in to comment.