Make gain_to_db() branchless
This commit is contained in:
parent
ab9adaf13e
commit
74a9e294b1
1 changed files with 1 additions and 5 deletions
|
@ -39,11 +39,7 @@ pub fn db_to_gain(dbs: f32) -> f32 {
|
|||
/// [`MINUS_INFINITY_DB`].
|
||||
#[inline]
|
||||
pub fn gain_to_db(gain: f32) -> f32 {
|
||||
if gain > MINUS_INFINITY_GAIN {
|
||||
gain.log10() * 20.0
|
||||
} else {
|
||||
MINUS_INFINITY_DB
|
||||
}
|
||||
f32::max(gain, MINUS_INFINITY_GAIN).log10() * 20.0
|
||||
}
|
||||
|
||||
/// Convert a MIDI note ID to a frequency at A4 = 440 Hz equal temperament and middle C = note 60 =
|
||||
|
|
Loading…
Add table
Reference in a new issue