Add Audio tab toggle for transceiver built-in speaker

Adds a "Send audio stream to radio (built-in speaker)" checkbox on the
Settings → Audio tab. It is a single switch for the radio's built-in
speaker:

- ON  — RX audio is streamed to the radio via the DDC Audio packet
        (port 1028, 64 L/R pairs per packet) and the speaker is unmuted
        (High Priority byte 1400 bit1 = 0).
- OFF — speaker is muted (byte 1400 bit1 = 1, ANAN-8000DLE IO1 output)
        and no audio stream is sent.

The float->int16 conversion and 64-pair packet accumulation live in
THPSDRNetwork (SendSpeakerAudio/SetSpeakerAudio), next to SendDDCAudio;
MainForm only reads the setting and forwards the audio. State is
persisted per-MAC (send_audio_to_radio, default off) and re-applied on
each radio start.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-02 08:55:36 +03:00
co-authored by Claude Opus 4.8
parent d8584323ac
commit aff17aa3a6
4 changed files with 122 additions and 0 deletions
+35
View File
@@ -49,6 +49,7 @@ type
TOnAudioDevChange = procedure(DevIndex: Integer; const DevName: string) of object;
TOnAudioInDevChange = procedure(DevIndex: Integer; const DevName: string) of object;
TOnAudioBufferChange = procedure(BufferSize: Integer) of object;
TOnSendAudioToRadioChange = procedure(Enabled: Boolean) of object;
TOnVisibilityChange = procedure(ShowSpectrum, ShowWaterfall, ShowWideband,
WidebandFill, SpectrumFill: Boolean) of object;
TOnFPSChange = procedure(FPS: Integer) of object;
@@ -99,6 +100,7 @@ type
FTXDevIndices: array[0..63] of Integer;
FTXDevCount: Integer;
FCmbAudioBuffer: TFlatComboBox;
FChkSendAudioToRadio: TFlatCheckBox;
// ---- RX1 sub-tab controls ----
FCmbFFTSize: TFlatComboBox;
@@ -272,6 +274,7 @@ type
FOnAudioDevChange: TOnAudioDevChange;
FOnAudioInDevChange: TOnAudioInDevChange;
FOnAudioBufferChange: TOnAudioBufferChange;
FOnSendAudioToRadioChange: TOnSendAudioToRadioChange;
FOnVisibilityChange: TOnVisibilityChange;
FOnFPSChange: TOnFPSChange;
FOnThemeChange: TOnThemeChange;
@@ -335,6 +338,7 @@ type
procedure OnRXDevChange(Sender: TObject);
procedure OnTXDevChange(Sender: TObject);
procedure OnAudioBufferCmbChange(Sender: TObject);
procedure OnSendAudioToRadioChkChange(Sender: TObject);
procedure OnVisibilityChkChange(Sender: TObject);
procedure OnFPSCmbChange(Sender: TObject);
procedure OnLightThemeChkChange(Sender: TObject);
@@ -375,6 +379,7 @@ type
procedure RefreshAudioDevices(AudioOut: TAudioOutput; AudioIn: TAudioInput);
procedure LoadAudioBufferSize(BufferSize: Integer);
procedure LoadSendAudioToRadio(Enabled: Boolean);
procedure LoadVisibility(ShowSpectrum, ShowWaterfall, ShowWideband,
WidebandFill, SpectrumFill: Boolean);
procedure LoadFPS(FPS: Integer);
@@ -406,6 +411,7 @@ type
property OnAudioDevChange: TOnAudioDevChange read FOnAudioDevChange write FOnAudioDevChange;
property OnAudioInDevChange: TOnAudioInDevChange read FOnAudioInDevChange write FOnAudioInDevChange;
property OnAudioBufferChange: TOnAudioBufferChange read FOnAudioBufferChange write FOnAudioBufferChange;
property OnSendAudioToRadioChange: TOnSendAudioToRadioChange read FOnSendAudioToRadioChange write FOnSendAudioToRadioChange;
property OnVisibilityChange: TOnVisibilityChange read FOnVisibilityChange write FOnVisibilityChange;
property OnFPSChange: TOnFPSChange read FOnFPSChange write FOnFPSChange;
property OnThemeChange: TOnThemeChange read FOnThemeChange write FOnThemeChange;
@@ -765,6 +771,18 @@ begin
FCmbAudioBuffer.Items.Add('256 frames');
FCmbAudioBuffer.Items.Add('512 frames');
FCmbAudioBuffer.ItemIndex := 0;
Grp := MakeGroupPanel(FPageAudio, 'Transceiver Audio', MARGIN, 290, 650, 92);
FChkSendAudioToRadio := TFlatCheckBox.Create(Self);
FChkSendAudioToRadio.Parent := Grp;
FChkSendAudioToRadio.Caption := 'Send audio stream to radio (built-in speaker)';
FChkSendAudioToRadio.SetBounds(PAD, R1, 420, 22);
FChkSendAudioToRadio.Checked := False;
FChkSendAudioToRadio.Font.Color := CLR_TEXT;
FChkSendAudioToRadio.Font.Name := UI_FONT;
FChkSendAudioToRadio.Font.Size := 9;
FChkSendAudioToRadio.OnChange := OnSendAudioToRadioChkChange;
end;
// ---------------------------------------------------------------------------
@@ -2050,6 +2068,16 @@ begin
end;
end;
procedure TSettingsForm.LoadSendAudioToRadio(Enabled: Boolean);
begin
FLoading := True;
try
FChkSendAudioToRadio.Checked := Enabled;
finally
FLoading := False;
end;
end;
// ---------------------------------------------------------------------------
// RefreshAudioDevices
// ---------------------------------------------------------------------------
@@ -2338,6 +2366,13 @@ begin
FOnAudioBufferChange(BufferSize);
end;
procedure TSettingsForm.OnSendAudioToRadioChkChange(Sender: TObject);
begin
if FLoading then Exit;
if Assigned(FOnSendAudioToRadioChange) then
FOnSendAudioToRadioChange(FChkSendAudioToRadio.Checked);
end;
procedure TSettingsForm.LoadVisibility(ShowSpectrum, ShowWaterfall,
ShowWideband, WidebandFill, SpectrumFill: Boolean);
begin