Skip to content

Commit

Permalink
msk: do not divide power by 4
Browse files Browse the repository at this point in the history
As dm_buffer from SDR input only contains positive values (cabsf()),
i.e. half of the power scale (just like the matched filter), this
normalization which would normally apply to full scale content (positive
and negative samples) skews the actual dB scale readout and prevents
reporting clipping (i.e. overloads).

This change has been matched with a readout of an audio dump of a live
SDR capture normalized in an audio processing software: the reported
value of the normalized file is '-0.0' as expected, vs '-6.0' with the
previous code. The lowest reported values for SDR input are now also
more in line with the expected SNR.

In order to keep soundfile input values consistent with this change, the
audio samples are "normalized" to half scale. That means that audio
files generated through DEBUG will appear 6dB quieter than the original
signal (i.e. the readback will report the same value as was reported for
SDR input *before* this patch). The rationale is to show "true" values
for "standard" audio input.
  • Loading branch information
f00b4r0 committed Sep 9, 2024
1 parent 1c18835 commit e101abb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion msk.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void demodMSK(channel_t *ch, int len)
v /= lvl + 1e-8;

/* update level exp moving average. Average over last 16*8 bits */
lvl = lvl * lvl / 4;
lvl = lvl * lvl;
ch->MskLvl = ch->MskLvl - (1.0F/128.0F * (ch->MskLvl - lvl));

if (ch->MskS & 1) {
Expand Down
2 changes: 1 addition & 1 deletion soundfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int runSoundfileSample(void)
for (i = 0; i < nbi; i++) { // vectorizable
for (d = 0, j = 0; j < mult; j++) // vectorizable
d += sndbuff[n + (i*mult + j) * nch];
R.channels[n].dm_buffer[i] = d / mult;
R.channels[n].dm_buffer[i] = d / mult / 2; // normalize to half-scale for power readout
}
}
for (n = 0; n < nch; n++)
Expand Down

0 comments on commit e101abb

Please sign in to comment.