Add decibel to gain converters
This commit is contained in:
parent
bd16679b97
commit
8111af2c54
1 changed files with 10 additions and 0 deletions
|
|
@ -19,4 +19,14 @@ namespace psemek::audio
|
|||
return static_cast<float>(samples) * 0.5f * inv_frequency;
|
||||
}
|
||||
|
||||
inline float to_db(float amplitude)
|
||||
{
|
||||
return 10.f * std::log10(amplitude);
|
||||
}
|
||||
|
||||
inline float from_db(float db)
|
||||
{
|
||||
return std::pow(10.f, db / 10.f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue