mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
69 lines
1.5 KiB
ObjectPascal
69 lines
1.5 KiB
ObjectPascal
program dmr_frontend_test;
|
|
|
|
{$MODE Delphi}
|
|
|
|
uses
|
|
{$IFDEF UNIX}cthreads,{$ENDIF}
|
|
Classes, SysUtils, DMRDecoder;
|
|
|
|
const
|
|
BS_VOICE_SYNC = '131111333113313313113313';
|
|
|
|
procedure FeedSync(D: TDMRDecoder; const Pattern: string; Invert: Boolean);
|
|
var
|
|
L, R: array of Single;
|
|
i, j, p: Integer;
|
|
V: Single;
|
|
begin
|
|
// Three leading samples ensure the detector really searches all ten timing
|
|
// hypotheses instead of relying on an aligned first sample.
|
|
SetLength(L, 3 + Length(Pattern) * DMR_SAMPLES_PER_SYM + 20);
|
|
SetLength(R, Length(L));
|
|
p := 3;
|
|
for i := 1 to Length(Pattern) do
|
|
begin
|
|
if Pattern[i] = '1' then V := 0.7 else V := -0.7;
|
|
if Invert then V := -V;
|
|
for j := 0 to DMR_SAMPLES_PER_SYM - 1 do
|
|
begin
|
|
L[p] := V;
|
|
R[p] := V;
|
|
Inc(p);
|
|
end;
|
|
end;
|
|
D.FeedAudio(L, R, Length(L));
|
|
end;
|
|
|
|
var
|
|
D: TDMRDecoder;
|
|
S: TDMRStatus;
|
|
begin
|
|
D := TDMRDecoder.Create;
|
|
try
|
|
D.SetEnabled(True);
|
|
FeedSync(D, BS_VOICE_SYNC, False);
|
|
Sleep(50);
|
|
D.GetStatus(S);
|
|
if (not S.Synced) or (S.SyncKind <> dskBSVoice) or S.Inverted then
|
|
begin
|
|
WriteLn('normal sync failed');
|
|
Halt(1);
|
|
end;
|
|
|
|
D.SetEnabled(False);
|
|
D.SetInverted(True);
|
|
D.SetEnabled(True);
|
|
FeedSync(D, BS_VOICE_SYNC, True);
|
|
Sleep(50);
|
|
D.GetStatus(S);
|
|
if (not S.Synced) or (S.SyncKind <> dskBSVoice) or (not S.Inverted) then
|
|
begin
|
|
WriteLn('inverted sync failed');
|
|
Halt(2);
|
|
end;
|
|
WriteLn('DMR front-end sync tests passed');
|
|
finally
|
|
D.Free;
|
|
end;
|
|
end.
|