mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-12-02 22:11:48 +00:00
Change baseband floats to normalize at +/-1.0.
This commit is contained in:
@@ -82,15 +82,14 @@ float fast_pow2(const float val) {
|
||||
return u.f;
|
||||
}
|
||||
|
||||
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared) {
|
||||
constexpr float input_component_max = 32768;
|
||||
constexpr float mag2_max = (input_component_max * input_component_max) * 2;
|
||||
float mag2_to_dbv_norm(const float mag2) {
|
||||
constexpr float mag2_max = 1.0f;
|
||||
constexpr float mag2_log2_max = std::log2(mag2_max);
|
||||
constexpr float log_mag2_mag_factor = 0.5f;
|
||||
constexpr float log2_log10_factor = std::log10(2.0f);
|
||||
constexpr float log10_dbv_factor = 20.0f;
|
||||
constexpr float mag2_to_db_factor = log_mag2_mag_factor * log2_log10_factor * log10_dbv_factor;
|
||||
return (fast_log2(c16_mag_squared) - mag2_log2_max) * mag2_to_db_factor;
|
||||
return (fast_log2(mag2) - mag2_log2_max) * mag2_to_db_factor;
|
||||
}
|
||||
|
||||
/* GCD implementation derived from recursive implementation at
|
||||
|
||||
@@ -72,7 +72,7 @@ constexpr size_t log_2(const size_t n, const size_t p = 0) {
|
||||
float fast_log2(const float val);
|
||||
float fast_pow2(const float val);
|
||||
|
||||
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared);
|
||||
float mag2_to_dbv_norm(const float mag2);
|
||||
|
||||
inline float magnitude_squared(const std::complex<float> c) {
|
||||
const auto r = c.real();
|
||||
|
||||
Reference in New Issue
Block a user