Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #27 - restore whitespace differences #28

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
//file, You can obtain one at http://mozilla.org/MPL/2.0/.
//------------------------------------------------------------------------------
unit Contest;

interface

uses
SysUtils, SndTypes, Station, StnColl, MyStn, Math, Ini,
MovAvg, Mixers, VolumCtl, RndFunc, TypInfo, DxStn, DxOper, Log;

type
TContest = class
private
Expand All @@ -22,6 +25,7 @@ TContest = class
Modul: TModulator;
RitPhase: Single;
FStopPressed: boolean;

constructor Create;
destructor Destroy; override;
procedure Init;
Expand All @@ -30,30 +34,39 @@ TContest = class
procedure OnMeFinishedSending;
procedure OnMeStartedSending;
end;

var
Tst: TContest;


implementation

uses
Main;

{ TContest }

constructor TContest.Create;
begin
Me := TMyStation.CreateStation;
Stations := TStations.Create;
Filt := TMovingAverage.Create(nil);
Modul := TModulator.Create;
Agc := TVolumeControl.Create(nil);

Filt.Points := Round(0.7 * DEFAULTRATE / Ini.BandWidth);
Filt.Passes := 3;
Filt.SamplesInInput := Ini.BufSize;
Filt.GainDb := 10 * Log10(500/Ini.Bandwidth);

Filt2 := TMovingAverage.Create(nil);
Filt2.Passes := Filt.Passes;
Filt2.SamplesInInput := Filt.SamplesInInput;
Filt2.GainDb := Filt.GainDb;

Modul.SamplesPerSec := DEFAULTRATE;
Modul.CarrierFreq := Ini.Pitch;

Agc.NoiseInDb := 76;
Agc.NoiseOutDb := 76;
Agc.AttackSamples := 155; //AGC attack 5 ms
Expand All @@ -64,6 +77,7 @@ constructor TContest.Create;
Init;
end;


destructor TContest.Destroy;
begin
Me.Free;
Expand All @@ -73,13 +87,15 @@ destructor TContest.Destroy;
inherited;
end;


procedure TContest.Init;
begin
Me.Init;
Stations.Clear;
BlockNumber := 0;
end;


function TContest.GetAudio: TSingleArray;
const
NOISEAMP = 6000;
Expand All @@ -94,13 +110,15 @@ function TContest.GetAudio: TSingleArray;
SetLength(Result, 1);
Inc(BlockNumber);
if BlockNumber < 6 then Exit;

//complex noise
SetLengthReIm(ReIm, Ini.BufSize);
for i:=0 to High(ReIm.Re) do
begin
ReIm.Re[i] := 3 * NOISEAMP * (Random-0.5);
ReIm.Im[i] := 3 * NOISEAMP * (Random-0.5);
end;

//QRN
if Ini.Qrn then
begin
Expand All @@ -110,9 +128,11 @@ function TContest.GetAudio: TSingleArray;
//burst
if Random < 0.01 then Stations.AddQrn;
end;

//QRM
if Ini.Qrm and (Random < 0.0002) then Stations.AddQrm;


//audio from stations
Blk := nil;
for Stn:=0 to Stations.Count-1 do
Expand All @@ -126,11 +146,13 @@ function TContest.GetAudio: TSingleArray;
ReIm.Im[i] := ReIm.Im[i] - Blk[i] * Sin(Bfo);
end;
end;

//Rit
RitPhase := RitPhase + Ini.BufSize * TWO_PI * Ini.Rit / DEFAULTRATE;
while RitPhase > TWO_PI do RitPhase := RitPhase - TWO_PI;
while RitPhase < -TWO_PI do RitPhase := RitPhase + TWO_PI;


//my audio
if Me.State = stSending then
begin
Expand All @@ -155,21 +177,25 @@ function TContest.GetAudio: TSingleArray;
end;
end;


//LPF
Filt2.Filter(ReIm);
ReIm := Filt.Filter(ReIm);
if (BlockNumber mod 10) = 0 then SwapFilters;

//mix up to Pitch frequency
Result := Modul.Modulate(ReIm);
//AGC
Result := Agc.Process(Result);
//save
with MainForm.AlWavFile1 do
if IsOpen then WriteFrom(@Result[0], nil, Ini.BufSize);

//timer tick
Me.Tick;
for Stn:=Stations.Count-1 downto 0 do Stations[Stn].Tick;


//if DX is done, write to log and kill
for i:=Stations.Count-1 downto 0 do
if Stations[i] is TDxStation then
Expand All @@ -191,6 +217,7 @@ function TContest.GetAudio: TSingleArray;
MainForm.Panel2.Caption := FormatDateTime('hh:nn:ss', BlocksToSeconds(BlockNumber) / 86400);
if Ini.RunMode = rmPileUp then
MainForm.Panel4.Caption := Format('Pile-Up: %d', [DxCount]);

if (RunMode = rmSingle) and (DxCount = 0) then begin
Me.Msg := [msgCq]; //no need to send cq in this mode
Stations.AddCaller.ProcessEvent(evMeFinished);
Expand All @@ -202,6 +229,7 @@ function TContest.GetAudio: TSingleArray;
Stations.AddCaller.ProcessEvent(evMeFinished);
end;


if (BlocksToSeconds(BlockNumber) >= (Duration * 60)) or FStopPressed then
begin
if RunMode = rmHst then
Expand Down Expand Up @@ -229,6 +257,7 @@ function TContest.GetAudio: TSingleArray;
end;
end;


function TContest.DxCount: integer;
var
i: integer;
Expand All @@ -240,11 +269,13 @@ function TContest.DxCount: integer;
then Inc(Result);
end;


function TContest.Minute: Single;
begin
Result := BlocksToSeconds(BlockNumber) / 60;
end;


procedure TContest.OnMeFinishedSending;
var
i: integer;
Expand Down Expand Up @@ -276,6 +307,7 @@ procedure TContest.OnMeFinishedSending;
Stations[i].ProcessEvent(evMeFinished);
end;


procedure TContest.OnMeStartedSending;
var
i: integer;
Expand All @@ -285,6 +317,7 @@ procedure TContest.OnMeStartedSending;
Stations[i].ProcessEvent(evMeStarted);
end;


procedure TContest.SwapFilters;
var
F: TMovingAverage;
Expand All @@ -295,4 +328,7 @@ procedure TContest.SwapFilters;
Filt2.Reset;
end;



end.

1 change: 0 additions & 1 deletion DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ function TDxOperator.GetNR: integer;

function TDxOperator.GetName: string;
begin
// Result := 1 + Round(Random * Tst.Minute * Skills);
Result := 'ALEX';
end;

Expand Down
8 changes: 0 additions & 8 deletions DxStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ TDxStation = class(TStation)
end;



implementation

uses
Expand All @@ -38,9 +37,6 @@ constructor TDxStation.CreateStation;
begin
inherited Create(nil);




HisCall := Ini.Call;
if RunMode <> rmCwt then
MyCall := PickCall // Pick one Callsign from Calllist
Expand All @@ -65,13 +61,11 @@ constructor TDxStation.CreateStation;
end;
//showmessage(MyCall);


if Ini.Lids and (Random < 0.03) then
RST := 559 + 10 * Random(4)
else
RST := 599;


Qsb := TQsb.Create;

Qsb.Bandwidth := 0.1 + Random / 2;
Expand Down Expand Up @@ -182,5 +176,3 @@ function TDxStation.GetBlock: TSingleArray;

end.



2 changes: 2 additions & 0 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ procedure TMainForm.FormCreate(Sender: TObject);


end;


procedure TMainForm.FormDestroy(Sender: TObject);
begin
ToIni;
Expand Down
1 change: 0 additions & 1 deletion Station.pas
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ function TStation.NrAsText: string;
if Random < 0.97
then Result := StringReplace(Result, '9', 'N', [rfReplaceAll]);
end;

end;


Expand Down