mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-13 00:09:43 -05:00
Simplify FM demodulator class. Remove duplicate code.
This commit is contained in:
parent
10bce4b845
commit
86cf967464
@ -37,37 +37,23 @@ public:
|
|||||||
|
|
||||||
class FM {
|
class FM {
|
||||||
public:
|
public:
|
||||||
constexpr FM(
|
|
||||||
) : z_ { 0 },
|
|
||||||
k { 0 }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* angle: -pi to pi. output range: -32768 to 32767.
|
|
||||||
* Maximum delta-theta (output of atan2) at maximum deviation frequency:
|
|
||||||
* delta_theta_max = 2 * pi * deviation / sampling_rate
|
|
||||||
*/
|
|
||||||
constexpr FM(
|
|
||||||
const float sampling_rate,
|
|
||||||
const float deviation_hz
|
|
||||||
) : z_ { 0 },
|
|
||||||
k { static_cast<float>(32767.0f / (2.0 * pi * deviation_hz / sampling_rate)) }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer_s16_t execute(
|
buffer_s16_t execute(
|
||||||
buffer_c16_t src,
|
buffer_c16_t src,
|
||||||
buffer_s16_t dst
|
buffer_s16_t dst
|
||||||
);
|
);
|
||||||
|
|
||||||
void configure(const float sampling_rate, const float deviation_hz) {
|
void configure(const float sampling_rate, const float deviation_hz) {
|
||||||
|
/*
|
||||||
|
* angle: -pi to pi. output range: -32768 to 32767.
|
||||||
|
* Maximum delta-theta (output of atan2) at maximum deviation frequency:
|
||||||
|
* delta_theta_max = 2 * pi * deviation / sampling_rate
|
||||||
|
*/
|
||||||
k = static_cast<float>(32767.0f / (2.0 * pi * deviation_hz / sampling_rate));
|
k = static_cast<float>(32767.0f / (2.0 * pi * deviation_hz / sampling_rate));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
complex16_t::rep_type z_;
|
complex16_t::rep_type z_ { 0 };
|
||||||
float k;
|
float k { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace demodulate */
|
} /* namespace demodulate */
|
||||||
|
Loading…
Reference in New Issue
Block a user