From b5a4035788c962399f8aa480c4033b4223182fe1 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Thu, 14 Apr 2022 01:47:28 -0700 Subject: [PATCH 1/8] bug fix - fix memory leaks --- Contest.pas | 2 ++ Main.pas | 2 +- Qsb.pas | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Contest.pas b/Contest.pas index c3888ef..cb0bb3d 100644 --- a/Contest.pas +++ b/Contest.pas @@ -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; diff --git a/Main.pas b/Main.pas index 0857843..1b7f63e 100644 --- a/Main.pas +++ b/Main.pas @@ -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 diff --git a/Qsb.pas b/Qsb.pas index 939efd9..9eddc1e 100644 --- a/Qsb.pas +++ b/Qsb.pas @@ -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; @@ -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 From 9e682f364075ce5939d79ceb5ef9362e30f7d787 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Mon, 6 Jun 2022 08:39:56 -0700 Subject: [PATCH 2/8] refactor - early code simplification/reformat to original code. --- Main.pas | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Main.pas b/Main.pas index 1b7f63e..08cc573 100644 --- a/Main.pas +++ b/Main.pas @@ -858,9 +858,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; From 959c6cdd89e3c192e4d1755f44e31bd3a7c8b3cc Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Sat, 2 Jul 2022 03:01:39 -0700 Subject: [PATCH 3/8] comments - update comments to bh1scw's prior work --- Contest.pas | 2 +- DxStn.pas | 6 ++++-- Log.pas | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Contest.pas b/Contest.pas index cb0bb3d..7c96fab 100644 --- a/Contest.pas +++ b/Contest.pas @@ -202,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; diff --git a/DxStn.pas b/DxStn.pas index 32b63b5..86c3843 100644 --- a/DxStn.pas +++ b/DxStn.pas @@ -138,7 +138,8 @@ 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 @@ -146,7 +147,8 @@ procedure TDxStation.DataToLastQso; TrueRst := Self.Rst; TrueNR := Self.NR; end; - Free; + + Free; // removes Self from Stations[] container end; diff --git a/Log.pas b/Log.pas index e2d26dd..e9d554c 100644 --- a/Log.pas +++ b/Log.pas @@ -409,9 +409,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; From 0ed508a953fca79924fc720b21ac2d72f21d39db Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Fri, 29 Apr 2022 12:48:44 -0700 Subject: [PATCH 4/8] fix compiler warnings in debug mode --- Contest.pas | 2 +- VCL/VolmSldr.pas | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Contest.pas b/Contest.pas index 7c96fab..5444f18 100644 --- a/Contest.pas +++ b/Contest.pas @@ -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 diff --git a/VCL/VolmSldr.pas b/VCL/VolmSldr.pas index 141b333..b522489 100644 --- a/VCL/VolmSldr.pas +++ b/VCL/VolmSldr.pas @@ -4,6 +4,7 @@ interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + System.Types, Math, PermHint; type From 2f365909ba66427feb1b739d063bf6e79013600b Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Wed, 7 Sep 2022 19:18:51 -0700 Subject: [PATCH 5/8] remove QuickAvg and SndTypes from QrmStn.pas and QrnStn.pas --- QrmStn.pas | 3 +-- QrnStn.pas | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/QrmStn.pas b/QrmStn.pas index a0380c0..42ef9c6 100644 --- a/QrmStn.pas +++ b/QrmStn.pas @@ -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) diff --git a/QrnStn.pas b/QrnStn.pas index 92e82dc..00ec217 100644 --- a/QrnStn.pas +++ b/QrnStn.pas @@ -8,7 +8,7 @@ interface uses - SysUtils, Classes, Station, RndFunc, Ini, CallLst, QuickAvg, SndTypes, + SysUtils, Classes, Station, RndFunc, Ini, CallLst, Math; type From 415dec752e6ea020ce0c364000d29eb40bf0e097 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Thu, 12 May 2022 15:23:59 -0700 Subject: [PATCH 6/8] convert 'Integer(Result) := 0;' to 'Result := nil;' in VCL/Mixer.pas. --- VCL/Mixers.pas | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/VCL/Mixers.pas b/VCL/Mixers.pas index e9d26a6..2be48d3 100644 --- a/VCL/Mixers.pas +++ b/VCL/Mixers.pas @@ -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); @@ -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); @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 From 4bfd3e3b8f7749d7ae9231a957859f823250ac12 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Sat, 11 Jun 2022 22:51:09 -0700 Subject: [PATCH 7/8] bug fix - reading corrupt Pitch/Bandwidth from .INI file (e.g. Pitch=-1) results in bad audio. (revised) --- Main.pas | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Main.pas b/Main.pas index 08cc573..ba3342a 100644 --- a/Main.pas +++ b/Main.pas @@ -618,18 +618,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; From fd2c0e8d881203e56b4fcddff8e865e525b7ec00 Mon Sep 17 00:00:00 2001 From: Mike Brashler Date: Fri, 24 Jun 2022 17:23:46 -0700 Subject: [PATCH 8/8] bug fix - in Single station mode, sending a corrected callsign causes DX station to send NR? --- DxOper.pas | 6 ++++-- Log.pas | 3 ++- Main.pas | 29 +++++++++++++++-------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/DxOper.pas b/DxOper.pas index b8d138e..a840611 100644 --- a/DxOper.pas +++ b/DxOper.pas @@ -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; diff --git a/Log.pas b/Log.pas index e9d554c..f7d9aef 100644 --- a/Log.pas +++ b/Log.pas @@ -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; diff --git a/Main.pas b/Main.pas index ba3342a..bf565ed 100644 --- a/Main.pas +++ b/Main.pas @@ -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; @@ -750,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;