mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-27 06:47:13 -05:00
Extract complex16_mag_squared_to_dbv_norm to utility.
This commit is contained in:
parent
d855336985
commit
efaf13d2d1
@ -70,13 +70,6 @@
|
|||||||
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
||||||
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
||||||
|
|
||||||
static float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared) {
|
|
||||||
constexpr float mag2_max = -32768.0f * -32768.0f + -32768.0f * -32768.0f;
|
|
||||||
constexpr float mag2_log10_max = std::log10(mag2_max);
|
|
||||||
constexpr float mag2_to_db_factor = 20.0f / 2.0f;
|
|
||||||
return (std::log10(c16_mag_squared) - mag2_log10_max) * mag2_to_db_factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
class BasebandStatsCollector {
|
class BasebandStatsCollector {
|
||||||
public:
|
public:
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
uint32_t gcd(const uint32_t u, const uint32_t v) {
|
uint32_t gcd(const uint32_t u, const uint32_t v) {
|
||||||
@ -61,6 +62,13 @@ uint32_t gcd(const uint32_t u, const uint32_t v) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared) {
|
||||||
|
constexpr float mag2_max = -32768.0f * -32768.0f + -32768.0f * -32768.0f;
|
||||||
|
constexpr float mag2_log10_max = std::log10(mag2_max);
|
||||||
|
constexpr float mag2_to_db_factor = 20.0f / 2.0f;
|
||||||
|
return (std::log10(c16_mag_squared) - mag2_log10_max) * mag2_to_db_factor;
|
||||||
|
}
|
||||||
|
|
||||||
/* GCD implementation derived from recursive implementation at
|
/* GCD implementation derived from recursive implementation at
|
||||||
* http://en.wikipedia.org/wiki/Binary_GCD_algorithm
|
* http://en.wikipedia.org/wiki/Binary_GCD_algorithm
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +65,8 @@ static inline void clear_m4_flag_saturation() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
float complex16_mag_squared_to_dbv_norm(const float c16_mag_squared);
|
||||||
|
|
||||||
/* Override new/delete to use Chibi/OS heap functions */
|
/* Override new/delete to use Chibi/OS heap functions */
|
||||||
/* NOTE: Do not inline these, it doesn't work. ;-) */
|
/* NOTE: Do not inline these, it doesn't work. ;-) */
|
||||||
void* operator new(size_t size);
|
void* operator new(size_t size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user