mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
normalize amplitude from avg absolute amplitude
This commit is contained in:
parent
3974468399
commit
80eabf5acb
|
|
@ -145,13 +145,14 @@ void decode(int samples) {
|
|||
*saved_width = 0;
|
||||
*saved_height = 0;
|
||||
for (int sample = 0; sample < samples; ++sample, ++buffer_pos) {
|
||||
float amp = audio_buffer[sample] / 32768.0f;
|
||||
float power = amp * amp;
|
||||
if (filter(&avg_power, power) < 0.0000001f)
|
||||
int amp = audio_buffer[sample];
|
||||
float avg_amp = filter(&avg_amplitude, abs(amp));
|
||||
if (avg_amp < 16.0f)
|
||||
continue;
|
||||
float norm_amp = amp / avg_amp;
|
||||
|
||||
complex_t cnt_baseband = convert(&cnt_ddc, amp);
|
||||
complex_t dat_baseband = convert(&dat_ddc, amp);
|
||||
complex_t cnt_baseband = convert(&cnt_ddc, norm_amp);
|
||||
complex_t dat_baseband = convert(&dat_ddc, norm_amp);
|
||||
|
||||
float cnt_value = demodulate(&cnt_fmd, cnt_baseband);
|
||||
float dat_value = demodulate(&dat_fmd, dat_baseband);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ void initialize(float rate, int length, int width, int height)
|
|||
const float dat_bandwidth = 800.0f;
|
||||
const float cnt_bandwidth = 200.0f;
|
||||
|
||||
avg_power = ema_cutoff(10.0f, sample_rate);
|
||||
avg_amplitude = ema_cutoff(10.0f, sample_rate);
|
||||
leader_lowpass = ema_cutoff(100.0f, sample_rate);
|
||||
|
||||
cnt_ddc = ddc(cnt_carrier, cnt_bandwidth, sample_rate);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
#ifndef STATE_RSH
|
||||
#define STATE_RSH
|
||||
|
||||
static ema_t avg_power, leader_lowpass;
|
||||
static ema_t avg_amplitude, leader_lowpass;
|
||||
static ddc_t cnt_ddc, dat_ddc;
|
||||
static fmd_t cnt_fmd, dat_fmd;
|
||||
static int current_decoder;
|
||||
|
|
|
|||
Loading…
Reference in a new issue