fix(dmr): use flat discriminator and reject noise sync

This commit is contained in:
2026-07-14 19:30:43 +03:00
parent 300bc91a46
commit a19c82a214
3 changed files with 118 additions and 10 deletions
+22 -2
View File
@@ -8,6 +8,7 @@ uses
const
BS_VOICE_SYNC = '131111333113313313113313';
DMR_TEST_SUPERFRAME_SAMPLES = DMR_INPUT_RATE * 360 div 1000;
type
TAudioSink = class
@@ -48,6 +49,23 @@ begin
D.FeedAudio(L, R, Length(L));
end;
procedure FeedConfirmedSync(D: TDMRDecoder; const Pattern: string;
Invert: Boolean);
var
L, R: array of Single;
GapSamples, RepeatIndex: Integer;
begin
GapSamples := DMR_TEST_SUPERFRAME_SAMPLES -
(3 + Length(Pattern) * DMR_SAMPLES_PER_SYM + 20);
SetLength(L, GapSamples);
SetLength(R, GapSamples);
for RepeatIndex := 1 to 3 do
begin
FeedSync(D, Pattern, Invert);
if RepeatIndex < 3 then D.FeedAudio(L, R, GapSamples);
end;
end;
procedure TestBurst(D: TDMRDecoder);
var
Want, Got: array[0..DMR_BURST_DIBITS - 1] of Byte;
@@ -116,7 +134,7 @@ begin
try
D.OnAudio := Sink.AudioReady;
D.SetEnabled(True);
FeedSync(D, BS_VOICE_SYNC, False);
FeedConfirmedSync(D, BS_VOICE_SYNC, False);
Sleep(50);
D.GetStatus(S);
if (not S.Synced) or (S.SyncKind <> dskBSVoice) or S.Inverted then
@@ -128,7 +146,7 @@ begin
D.SetEnabled(False);
D.SetInverted(True);
D.SetEnabled(True);
FeedSync(D, BS_VOICE_SYNC, True);
FeedConfirmedSync(D, BS_VOICE_SYNC, True);
Sleep(50);
D.GetStatus(S);
if (not S.Synced) or (S.SyncKind <> dskBSVoice) or (not S.Inverted) then
@@ -140,6 +158,8 @@ begin
D.SetEnabled(False);
D.SetInverted(False);
D.SetEnabled(True);
FeedConfirmedSync(D, BS_VOICE_SYNC, False);
Sleep(50);
TestBurst(D);
D.GetStatus(S);
if S.VocoderAvailable and