Skip to content

Commit

Permalink
Part of Issue #20 - Merge in some cleanup and bug fixes found in orig…
Browse files Browse the repository at this point in the history
…inal code.

Merge commit 'fd2c0e8' into 20-fd-prototype
  • Loading branch information
w7sst committed Sep 19, 2022
2 parents 1d6abdf + fd2c0e8 commit fbcf7d8
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 39 deletions.
6 changes: 4 additions & 2 deletions Contest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
interface

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

type
Expand Down Expand Up @@ -80,9 +80,11 @@ constructor TContest.Create;
destructor TContest.Destroy;
begin
Me.Free;
FreeAndNil(Stations);
Filt.Free;
Filt2.Free;
Modul.Free;
FreeAndNil(Agc);
inherited;
end;

Expand Down Expand Up @@ -200,7 +202,7 @@ function TContest.GetAudio: TSingleArray;
if Stations[i] is TDxStation then
with Stations[i] as TDxStation do
if (Oper.State = osDone) and (QsoList <> nil) and (MyCall = QsoList[High(QsoList)].Call) then begin
DataToLastQso;
DataToLastQso; // deletes this TDxStation from Stations[]
//with MainForm.RichEdit1.Lines do Delete(Count-1);
// Delete(Count-1);
//Log.LastQsoToScreen;
Expand Down
6 changes: 4 additions & 2 deletions DxOper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ procedure TDxOperator.MsgReceived(AMsg: TStationMessages);
case State of
osNeedPrevEnd: ;
osNeedQso: State := osNeedPrevEnd;
osNeedNr: if (Random < 0.9) or (RunMode = rmHst) then SetState(osNeedEnd);
osNeedNr: if (Random < 0.9) or (RunMode in [rmHst, rmSingle]) then
SetState(osNeedEnd);
osNeedCall: ;
osNeedCallNr: if (Random < 0.9) or (RunMode = rmHst) then SetState(osNeedCall);
osNeedCallNr: if (Random < 0.9) or (RunMode in [rmHst, rmSingle]) then
SetState(osNeedCall);
osNeedEnd: ;
end;

Expand Down
6 changes: 4 additions & 2 deletions DxStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ procedure TDxStation.ProcessEvent(AEvent: TStationEvent);
end;



// copies data from this DxStation to top of QsoList[].
// removes Self from Stations[] container array.
procedure TDxStation.DataToLastQso;
begin
with QsoList[High(QsoList)] do begin
TrueCall := Self.MyCall;
TrueRst := Self.Rst;
TrueNR := Self.NR;
end;
Free;

Free; // removes Self from Stations[] container
end;


Expand Down
7 changes: 4 additions & 3 deletions Log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ THisto= class(TObject)
var
QsoList: array of TQso;
PfxList: TStringList;
CallSent, NrSent: boolean;
CallSent: boolean; // msgHisCall has been sent; cleared upon edit.
NrSent: boolean; // msgNR has been sent. Seems to imply exchange sent.
Histo: THisto;


Expand Down Expand Up @@ -409,9 +410,9 @@ procedure SaveQso;
if Tst.Stations[i] is TDxStation then
with Tst.Stations[i] as TDxStation do
if (Oper.State = osDone) and (MyCall = Qso.Call) then begin
DataToLastQso;
DataToLastQso; //deletes this dx station!
Break;
end; //deletes the dx station!
end;
//QsoList[High(QsoList)].Err:= '...';
CheckErr;
end;
Expand Down
47 changes: 27 additions & 20 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,12 @@ procedure TMainForm.FormDestroy(Sender: TObject);
begin
ToIni;
ARRLDX.Free;
Histo.Free;
Tst.Free;
DestroyKeyer;
end;



procedure TMainForm.AlSoundOut1BufAvailable(Sender: TObject);
begin
if AlSoundOut1.Enabled then
Expand All @@ -355,26 +355,20 @@ procedure TMainForm.SendClick(Sender: TObject);
Msg := TStationMessage((Sender as TComponent).Tag);

SendMsg(Msg);

case Msg of
msgHisCall:
CallSent:= true;
msgNR:
NrSent:= true;
end;
end;


procedure TMainForm.SendMsg(Msg: TStationMessage);
begin
if Msg = msgHisCall then begin
if Edit1.Text <> '' then
Tst.Me.HisCall := Edit1.Text;
CallSent := true;
// retain current callsign, including ''. if empty, return.
Tst.Me.HisCall := Edit1.Text;
CallSent := Edit1.Text <> '';
if not CallSent then
Exit;
end;

if Msg = msgNR then NrSent := true;

if Msg = msgNR then
NrSent := true;
Tst.Me.SendMsg(Msg);
end;

Expand Down Expand Up @@ -618,18 +612,26 @@ procedure TMainForm.SetMyCall(ACall: string);
Tst.Me.MyCall := ACall;
end;

{
Set pitch based on menu item number.
Must be within range [0, ComboBox1.Items.Count).
}
procedure TMainForm.SetPitch(PitchNo: integer);
begin
PitchNo := Max(0, Min(PitchNo, ComboBox1.Items.Count-1));
Ini.Pitch := 300 + PitchNo * 50;
ComboBox1.ItemIndex := PitchNo;
Tst.Modul.CarrierFreq := Ini.Pitch;
end;


{
Set bandwidth based on menu item number.
Must be within range [0, ComboBox2.Items.Count).
}
procedure TMainForm.SetBw(BwNo: integer);
begin
if (BwNo < 0) or (BwNo >= ComboBox2.Items.Count) then Exit;

BwNo := Max(0, Min(BwNo, ComboBox2.Items.Count-1));
Ini.Bandwidth := 100 + BwNo * 50;
ComboBox2.ItemIndex := BwNo;

Expand Down Expand Up @@ -742,12 +744,19 @@ procedure TMainForm.Readme1Click(Sender: TObject);
end;


{
called whenever callsign field (Edit1) changes. Any callsign edit will
invalidate the callsign and NR (Exchange) field(s) already sent, so clear
the CallSent and NrSent values.
}
procedure TMainForm.Edit1Change(Sender: TObject);
begin
if Edit1.Text = '' then
NrSent := false;
if not Tst.Me.UpdateCallInMessage(Edit1.Text) then
if not Tst.Me.UpdateCallInMessage(Edit1.Text) then begin
CallSent := false;
NrSent := false;
end;
end;


Expand Down Expand Up @@ -858,9 +867,7 @@ procedure TMainForm.Run(Value: TRunMode);

//mode caption
Panel4.Caption := Title[Value];
if BCompet
then Panel4.Font.Color := clRed else Panel4.Font.Color := clGreen;

Panel4.Font.Color := IfThen(BCompet, clRed, clGreen);
if not BStop then
begin
Tst.Me.AbortSend;
Expand Down
3 changes: 1 addition & 2 deletions QrmStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
interface

uses
SysUtils, Classes, Station, RndFunc, Ini, CallLst, QuickAvg, SndTypes,
Math;
SysUtils, Classes, Station, RndFunc, Ini, CallLst;

type
TQrmStation = class(TStation)
Expand Down
2 changes: 1 addition & 1 deletion QrnStn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
interface

uses
SysUtils, Classes, Station, RndFunc, Ini, CallLst, QuickAvg, SndTypes,
SysUtils, Classes, Station, RndFunc, Ini, CallLst,
Math;

type
Expand Down
7 changes: 7 additions & 0 deletions Qsb.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ TQsb = class
public
QsbLevel: Single;
constructor Create;
destructor Destroy; override;
procedure ApplyTo(Arr: TSingleArray);
property Bandwidth: Single read FBandwidth write SetBandwidth;
end;
Expand All @@ -37,6 +38,12 @@ constructor TQsb.Create;
Bandwidth := 0.1;
end;

destructor TQsb.Destroy;
begin
FreeAndNil(Filt);
inherited;
end;

function TQsb.NewGain: Single;
begin
with Filt.Filter(RndUniform, RndUniform) do
Expand Down
14 changes: 7 additions & 7 deletions VCL/Mixers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function TDownMixer.Mix(Data: TSingleArray): TComplexArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));
if Phase > TWO_PI then Phase := Phase - TWO_PI * Trunc(Phase/TWO_PI);

Expand All @@ -110,7 +110,7 @@ function TDownMixer.Mix(Data: TComplexArray): TComplexArray;
i: integer;
Sn, Cs, rr, ii: Single;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));
if Phase > TWO_PI then Phase := Phase - TWO_PI*Trunc(Phase/TWO_PI);

Expand Down Expand Up @@ -242,7 +242,7 @@ function TModulator.Modulate(Data: TReImArrays): TSingleArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data.Re));
for i:=0 to High(Result) do
begin
Expand All @@ -256,7 +256,7 @@ function TModulator.Modulate(Data: TSingleArray): TSingleArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));
for i:=0 to High(Result) do
begin
Expand All @@ -270,7 +270,7 @@ function TModulator.Modulate(Data: TComplexArray): TSingleArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));
for i:=0 to High(Result) do
begin
Expand All @@ -294,7 +294,7 @@ function TFastDownMixer.Mix(Data: TComplexArray): TComplexArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));

for i:=0 to High(Data) do
Expand Down Expand Up @@ -329,7 +329,7 @@ function TFastDownMixer.Mix(Data: TSingleArray): TComplexArray;
var
i: integer;
begin
Integer(Result) := 0;
Result := nil;
SetLength(Result, Length(Data));

for i:=0 to High(Data) do
Expand Down
1 change: 1 addition & 0 deletions VCL/VolmSldr.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
System.Types,
Math, PermHint;

type
Expand Down

0 comments on commit fbcf7d8

Please sign in to comment.