Use db_to_gain_fast() in plugins
This commit is contained in:
parent
3b57ebe895
commit
11d9476a5f
|
@ -187,7 +187,7 @@ impl Plugin for Sine {
|
||||||
};
|
};
|
||||||
|
|
||||||
for sample in channel_samples {
|
for sample in channel_samples {
|
||||||
*sample = sine * util::db_to_gain(gain);
|
*sample = sine * util::db_to_gain_fast(gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -881,9 +881,9 @@ impl CompressorBank {
|
||||||
|
|
||||||
// This threshold must never reach zero as it's used in divisions to get a gain ratio
|
// This threshold must never reach zero as it's used in divisions to get a gain ratio
|
||||||
// above the threshold
|
// above the threshold
|
||||||
*threshold = util::db_to_gain(threshold_db).max(f32::EPSILON);
|
*threshold = util::db_to_gain_fast(threshold_db);
|
||||||
*knee_start = util::db_to_gain(knee_start_db).max(f32::EPSILON);
|
*knee_start = util::db_to_gain_fast(knee_start_db);
|
||||||
*knee_end = util::db_to_gain(knee_end_db).max(f32::EPSILON);
|
*knee_end = util::db_to_gain_fast(knee_end_db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,9 +910,9 @@ impl CompressorBank {
|
||||||
let knee_end_db =
|
let knee_end_db =
|
||||||
threshold_db + (params.compressors.upwards.knee_width_db.value() / 2.0);
|
threshold_db + (params.compressors.upwards.knee_width_db.value() / 2.0);
|
||||||
|
|
||||||
*threshold = util::db_to_gain(threshold_db).max(f32::EPSILON);
|
*threshold = util::db_to_gain_fast(threshold_db);
|
||||||
*knee_start = util::db_to_gain(knee_start_db).max(f32::EPSILON);
|
*knee_start = util::db_to_gain_fast(knee_start_db);
|
||||||
*knee_end = util::db_to_gain(knee_end_db).max(f32::EPSILON);
|
*knee_end = util::db_to_gain_fast(knee_end_db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,9 @@ pub fn gain_to_db(gain: f32) -> f32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An approximation of [`db_to_gain()`] using `exp()`. Does not treat values below
|
/// An approximation of [`db_to_gain()`] using `exp()`. Does not treat values below
|
||||||
/// [`MINUS_INFINITY_DB`] as 0.0 gain to avoid branching. Will run faster on most architectures, but
|
/// [`MINUS_INFINITY_DB`] as 0.0 gain to avoid branching. As a result this function will thus also
|
||||||
/// the result may be slightly different.
|
/// never return 0.0 for normal input values. Will run faster on most architectures, but the result
|
||||||
|
/// may be slightly different.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn db_to_gain_fast(dbs: f32) -> f32 {
|
pub fn db_to_gain_fast(dbs: f32) -> f32 {
|
||||||
const CONVERSION_FACTOR: f32 = std::f32::consts::LN_10 / 20.0;
|
const CONVERSION_FACTOR: f32 = std::f32::consts::LN_10 / 20.0;
|
||||||
|
|
Loading…
Reference in a new issue