feat(dmr): assemble aligned dibit bursts

This commit is contained in:
2026-07-14 18:42:20 +03:00
parent 53a3681618
commit 3fcf737685
2 changed files with 217 additions and 13 deletions
+63
View File
@@ -34,6 +34,64 @@ begin
D.FeedAudio(L, R, Length(L));
end;
procedure TestBurst(D: TDMRDecoder);
var
Want, Got: array[0..DMR_BURST_DIBITS - 1] of Byte;
L, R: array of Single;
i, j, p: Integer;
V: Single;
Seq: QWord;
Status: TDMRStatus;
begin
for i := 0 to High(Want) do Want[i] := Byte((i * 3 + 1) and 3);
for i := 1 to Length(BS_VOICE_SYNC) do
if BS_VOICE_SYNC[i] = '1' then Want[65 + i] := 1
else Want[65 + i] := 3;
SetLength(L, 3 + (DMR_BURST_DIBITS + 2) * DMR_SAMPLES_PER_SYM);
SetLength(R, Length(L));
// One complete preceding symbol mirrors a continuous stream and fills the
// 90-dibit history even for the latest timing hypothesis.
V := 0.70; // Want[0] = 1
p := 3 + DMR_SAMPLES_PER_SYM;
for j := 0 to p - 1 do begin L[j] := V; R[j] := V; end;
for i := 0 to High(Want) do
begin
case Want[i] of
0: V := 0.23;
1: V := 0.70;
2: V := -0.23;
else
V := -0.70;
end;
for j := 0 to DMR_SAMPLES_PER_SYM - 1 do
begin
L[p] := V; R[p] := V; Inc(p);
end;
end;
// Hold the last level for one symbol so every one of the ten timing
// hypotheses has enough tail samples to close dibit 143.
for j := 0 to DMR_SAMPLES_PER_SYM - 1 do
begin
L[p] := V; R[p] := V; Inc(p);
end;
D.FeedAudio(L, R, Length(L));
Sleep(80);
if not D.GetLastBurst(Got, Seq) then
begin
D.GetStatus(Status);
WriteLn('burst was not assembled; sync=', Status.SyncCount,
' bursts=', Status.BurstCount, ' pos=', Status.BurstDibits);
Halt(3);
end;
for i := 0 to High(Want) do
if Got[i] <> Want[i] then
begin
WriteLn('burst dibit mismatch at ', i, ': ', Got[i], ' <> ', Want[i]);
Halt(4);
end;
end;
var
D: TDMRDecoder;
S: TDMRStatus;
@@ -61,6 +119,11 @@ begin
WriteLn('inverted sync failed');
Halt(2);
end;
D.SetEnabled(False);
D.SetInverted(False);
D.SetEnabled(True);
TestBurst(D);
WriteLn('DMR front-end sync tests passed');
finally
D.Free;