From 3cdcbeea3e2891f4a10c79b272da144f37ff24f3 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Tue, 12 Sep 2023 21:38:15 +0100 Subject: New upstream version 0.67 --- sm_main.c | 1836 +++++++------------------------------------------------------ 1 file changed, 198 insertions(+), 1638 deletions(-) (limited to 'sm_main.c') diff --git a/sm_main.c b/sm_main.c index 0e08aad..a75ea5f 100644 --- a/sm_main.c +++ b/sm_main.c @@ -28,13 +28,17 @@ void make_core_TXBPF(UCHAR snd_ch, float freq, float width); void make_core_INTR(UCHAR snd_ch); void make_core_LPF(UCHAR snd_ch, short width); void wf_pointer(int snd_ch); +void dw9600ProcessSample(int snd_ch, short Sample); +void init_RUH48(int snd_ch); +void init_RUH96(int snd_ch); -char modes_name[modes_count][20] = +char modes_name[modes_count][21] = { "AFSK AX.25 300bd","AFSK AX.25 1200bd","AFSK AX.25 600bd","AFSK AX.25 2400bd", "BPSK AX.25 1200bd","BPSK AX.25 600bd","BPSK AX.25 300bd","BPSK AX.25 2400bd", "QPSK AX.25 4800bd","QPSK AX.25 3600bd","QPSK AX.25 2400bd","BPSK FEC 4x100bd", - "DW QPSK V26A 2400bd","DW 8PSK V27 4800bd","DW QPSK V26B 2400bd", "ARDOP Packet" + "QPSK V26A 2400bps","8PSK V27 4800bps","QPSK V26B 2400bps", "Not Available", + "QPSK V26A 600bps", "8PSK 900bps", "RUH 4800(DW)", "RUH 9600(DW)" }; typedef struct wavehdr_tag { @@ -64,198 +68,7 @@ BOOL Secondwaterfall = 1; int multiCore = FALSE; -/* -type - TComboBox = class(StdCtrls.TComboBox) - private - procedure CMMouseWheel(var msg TCMMouseWheel); message CM_MOUSEWHEEL; - end; - TData16 = array [0..4095] of smallint; - PData16 = ^TData16; - TWaveHeader = record - RIFF dword; - ChunkLen integer; - WAVE dword; - fmt dword; - FormatLen integer; - Format word; - Channels word; - Frequency integer; - BytesPS integer; - BlockAlign word; - BitsPS word; - data dword; - DataLen integer - end; - TForm1 = class(TForm) - Panel5 TPanel; - ServerSocket1 TServerSocket; - MainMenu1 TMainMenu; - Settings1 TMenuItem; - OutputVolume1 TMenuItem; - InputVolume1 TMenuItem; - CoolTrayIcon1 TCoolTrayIcon; - ImageList1 TImageList; - ABout1 TMenuItem; - Panel1 TPanel; - Panel2 TPanel; - View1 TMenuItem; - Firstwaterfall1 TMenuItem; - Secondwaterfall1 TMenuItem; - Panel3 TPanel; - StringGrid1 TStringGrid; - Devices1 TMenuItem; - Statustable1 TMenuItem; - Monitor1 TMenuItem; - Panel4 TPanel; - PaintBox2 TPaintBox; - Filters1 TMenuItem; - Clearmonitor1 TMenuItem; - RxRichEdit1 TRxRichEdit; - MemoPopupMenu1 TPopupMenu; - Copytext1 TMenuItem; - Label1 TLabel; - Label5 TLabel; - ApplicationEvents1 TApplicationEvents; - PaintBox1 TPaintBox; - PaintBox3 TPaintBox; - ServerSocket2 TServerSocket; - Font1 TMenuItem; - FontDialog1 TFontDialog; - N1 TMenuItem; - Calibration1 TMenuItem; - Panel9 TPanel; - Panel6 TPanel; - Label4 TLabel; - Shape2 TShape; - ComboBox2 TComboBox; - SpinEdit2 TSpinEdit; - Panel7 TPanel; - Label3 TLabel; - Shape1 TShape; - ComboBox1 TComboBox; - SpinEdit1 TSpinEdit; - Panel8 TPanel; - Label2 TLabel; - TrackBar1 TTrackBar; - CheckBox1 TCheckBox; - OpenDialog1 TOpenDialog; - procedure FormCreate(Sender TObject); - procedure TrackBar1Change(Sender TObject); - procedure PaintBox1MouseMove(Sender TObject; Shift TShiftState; X, - Y Integer); - procedure PaintBox1MouseDown(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); - procedure ServerSocket1ClientRead(Sender TObject; - Socket TCustomWinSocket); - procedure ServerSocket1ClientError(Sender TObject; - Socket TCustomWinSocket; ErrorEvent TErrorEvent; - var ErrorCode Integer); - procedure OutputVolume1Click(Sender TObject); - procedure InputVolume1Click(Sender TObject); - procedure ServerSocket1ClientConnect(Sender TObject; - Socket TCustomWinSocket); - procedure ServerSocket1ClientDisconnect(Sender TObject; - Socket TCustomWinSocket); - procedure CoolTrayIcon1Click(Sender TObject); - procedure CoolTrayIcon1Cycle(Sender TObject; NextIndex Integer); - procedure ABout1Click(Sender TObject); - procedure PaintBox3MouseDown(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); - procedure PaintBox3MouseMove(Sender TObject; Shift TShiftState; X, - Y Integer); - procedure Firstwaterfall1Click(Sender TObject); - procedure Secondwaterfall1Click(Sender TObject); - procedure Devices1Click(Sender TObject); - procedure Statustable1Click(Sender TObject); - procedure Monitor1Click(Sender TObject); - procedure FormPaint(Sender TObject); - procedure Filters1Click(Sender TObject); - procedure SpinEdit1Change(Sender TObject); - procedure SpinEdit2Change(Sender TObject); - procedure Clearmonitor1Click(Sender TObject); - procedure Copytext1Click(Sender TObject); - procedure PaintBox3MouseUp(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); - procedure PaintBox1MouseUp(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); - procedure ApplicationEvents1Minimize(Sender TObject); - procedure ApplicationEvents1Restore(Sender TObject); - procedure ServerSocket2ClientConnect(Sender TObject; - Socket TCustomWinSocket); - procedure ServerSocket2ClientDisconnect(Sender TObject; - Socket TCustomWinSocket); - procedure ServerSocket2ClientError(Sender TObject; - Socket TCustomWinSocket; ErrorEvent TErrorEvent; - var ErrorCode Integer); - procedure ServerSocket2ClientRead(Sender TObject; - Socket TCustomWinSocket); - procedure Font1Click(Sender TObject); - procedure Calibration1Click(Sender TObject); - procedure ComboBox1Change(Sender TObject); - procedure ComboBox1KeyDown(Sender TObject; var Key Word; - Shift TShiftState); - procedure ComboBox1KeyPress(Sender TObject; var Key Char); - procedure ComboBox2Change(Sender TObject); - procedure FormDestroy(Sender TObject); - private - { Private declarations } - procedure BufferFull(var Msg TMessage); Message MM_WIM_DATA; - procedure BufferFull1(var Msg TMessage); Message MM_WOM_DONE; - procedure make_wave_buf(snd_ch byte; buf PChar); - procedure disp2(snd_ch byte); - procedure create_timer1; - procedure free_timer1; - procedure show_panels; - procedure show_combobox; - procedure Timer_Event2; - procedure waterfall_init; - procedure waterfall_free; - public - { Public declarations } - function get_idx_by_name(name string) word; - function frame_monitor(s,code string; tx_stat boolean) string; - procedure ChangePriority; - procedure put_frame(snd_ch byte; frame,code string; tx_stat,excluded boolean); - procedure show_grid; - procedure RX2TX(snd_ch byte); - procedure TX2RX(snd_ch byte); - procedure WriteIni; - procedure ReadIni; - procedure init_8P4800(snd_ch byte); - procedure init_DW2400(snd_ch byte); - procedure init_AE2400(snd_ch byte); - procedure init_MP400(snd_ch byte); - procedure init_Q4800(snd_ch byte); - procedure init_Q3600(snd_ch byte); - procedure init_Q2400(snd_ch byte); - procedure init_P2400(snd_ch byte); - procedure init_P1200(snd_ch byte); - procedure init_P600(snd_ch byte); - procedure init_P300(snd_ch byte); - procedure init_300(snd_ch byte); - procedure init_600(snd_ch byte); - procedure init_1200(snd_ch byte); - procedure init_2400(snd_ch byte); - procedure init_speed(snd_ch byte); - procedure get_filter_values(idx byte; var dbpf,dtxbpf,dbpftap,dlpf,dlpftap word); - procedure show_mode_panels; - procedure show_modes; - procedure show_freq_a; - procedure show_freq_b; - procedure ChkSndDevName; - procedure StartRx; - procedure StartTx(snd_ch byte); - procedure StopRx; - procedure StopTx(snd_ch byte); - procedure StartAGW; - procedure StartKISS; - procedure wf_scale; - procedure wf_pointer(snd_ch byte); - end; -var -/*/ BOOL MinOnStart = 0; //RS TReedSolomon; @@ -286,7 +99,7 @@ UCHAR tx_buf_num [5] = {0,0,0,0}; extern short active_rx_freq[5]; - +unsigned int pskStates[4] = {0, 0, 0, 0}; int speed[5] = {0,0,0,0}; int panels[6] = {1,1,1,1,1}; @@ -341,50 +154,7 @@ int MainPriority = 0; // MainThreadHandle THandle; UCHAR w_state = WIN_MAXIMIZED; - /* -implementation - -{$R *.DFM} - -uses ax25_mod, ax25_demod, ax25, ax25_l2, ax25_ptt, ax25_agw, ax25_about, rgb_rad, - AX25_set, ax25_filter, AX25_modem_set, kiss_mode, ax25_calibration; - -procedure TComboBox.CMMouseWheel(var msg TCMMouseWheel); -begin - if SendMessage(GetFocus, CB_GETDROPPEDSTATE, 0, 0) = 0 then msg.Result = 1; -end; - -procedure TForm1.ChangePriority; -begin - case MainPriority of - 0 SetThreadPriority(MainThreadHandle,THREAD_PRIORITY_NORMAL); - 1 SetThreadPriority(MainThreadHandle,THREAD_PRIORITY_ABOVE_NORMAL); - 2 SetThreadPriority(MainThreadHandle,THREAD_PRIORITY_HIGHEST); - 3 SetThreadPriority(MainThreadHandle,THREAD_PRIORITY_TIME_CRITICAL); - end; -end; - -procedure TForm1.show_modes; -var - s string; -begin - s = MODEM_CAPTION+" - Ver "+MODEM_VERSION+" - ["+modes_name[Speed[1]]; - if dualchan then s = s+" - "+modes_name[Speed[2]]; - form1.Caption = s+"]"; -end; - -procedure TForm1.show_freq_a; -begin - SpinEdit1.Value = round(rx_freq[1]); - SpinEdit1.Refresh; -end; - -procedure TForm1.show_freq_b; -begin - SpinEdit2.Value = round(rx_freq[2]); - SpinEdit2.Refresh; -end; -*/ + void get_filter_values(UCHAR snd_ch) { //, unsigned short dbpf, @@ -446,7 +216,7 @@ void get_filter_values(UCHAR snd_ch) break; case SPEED_DW2400: - case SPEED_AE2400: + case SPEED_2400V26B: lpf[snd_ch] = MODEM_DW2400_LPF; @@ -529,8 +299,31 @@ void get_filter_values(UCHAR snd_ch) BPF_tap[snd_ch] = MODEM_2400_BPF_TAP; LPF_tap[snd_ch] = MODEM_2400_LPF_TAP; break; - } + + case SPEED_Q300: + case SPEED_8PSK300: + + lpf[snd_ch] = MODEM_P300_LPF; + bpf[snd_ch] = MODEM_P300_BPF; + txbpf[snd_ch] = MODEM_P300_TXBPF; + BPF_tap[snd_ch] = MODEM_P300_BPF_TAP; + LPF_tap[snd_ch] = MODEM_P300_LPF_TAP; + + break; + +/* + + case SPEED_Q1200: + + lpf[snd_ch] = MODEM_P1200_LPF; + bpf[snd_ch] = MODEM_P1200_BPF; + txbpf[snd_ch] = MODEM_P1200_TXBPF; + BPF_tap[snd_ch] = MODEM_P1200_BPF_TAP; + LPF_tap[snd_ch] = MODEM_P1200_LPF_TAP; + break; +*/ + } } @@ -539,6 +332,7 @@ void init_2400(int snd_ch) modem_mode[snd_ch] = MODE_FSK; rx_shift[snd_ch] = 1805; rx_baudrate[snd_ch] = 2400; + tx_bitrate[snd_ch] = 2400; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -553,6 +347,7 @@ void init_1200(int snd_ch) rx_freq[snd_ch] = 1700; rx_baudrate[snd_ch] = 1200; + tx_bitrate[snd_ch] = 1200; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -564,6 +359,7 @@ void init_600(int snd_ch) rx_shift[snd_ch] = 450; rx_baudrate[snd_ch] = 600; + tx_bitrate[snd_ch] = 600; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -574,6 +370,7 @@ void init_300(int snd_ch) modem_mode[snd_ch] = MODE_FSK; rx_shift[snd_ch] = 200; rx_baudrate[snd_ch] = 300; + tx_bitrate[snd_ch] = 300; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -584,6 +381,7 @@ void init_MP400(int snd_ch) modem_mode[snd_ch] = MODE_MPSK; rx_shift[snd_ch] = 175 /*sbc*/ * 3; rx_baudrate[snd_ch] = 100; + tx_bitrate[snd_ch] = 400; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -598,12 +396,14 @@ void init_8P4800(int snd_ch) rx_shift[snd_ch] = 1600; rx_baudrate[snd_ch] = 1600; + tx_bitrate[snd_ch] = 4800; + pskStates[snd_ch] = 8; if (modem_def[snd_ch]) get_filter_values(snd_ch); } -void init_AE2400(int snd_ch) +void init_V26B2400(int snd_ch) { qpsk_set[snd_ch].mode = QPSK_V26; modem_mode[snd_ch] = MODE_PI4QPSK; @@ -613,6 +413,8 @@ void init_AE2400(int snd_ch) rx_shift[snd_ch] = 1200; rx_baudrate[snd_ch] = 1200; + tx_bitrate[snd_ch] = 2400; + pskStates[snd_ch] = 8; // Pretend 8 so quality calc works if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -628,6 +430,8 @@ void init_DW2400(int snd_ch) rx_shift[snd_ch] = 1200; rx_baudrate[snd_ch] = 1200; + tx_bitrate[snd_ch] = 2400; + pskStates[snd_ch] = 4; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -639,6 +443,9 @@ void init_Q4800(int snd_ch) modem_mode[snd_ch] = MODE_QPSK; rx_shift[snd_ch] = 2400; rx_baudrate[snd_ch] = 2400; + tx_bitrate[snd_ch] = 4800; + pskStates[snd_ch] = 4; + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -649,6 +456,7 @@ void init_Q3600(int snd_ch) modem_mode[snd_ch] = MODE_QPSK; rx_shift[snd_ch] = 1800; rx_baudrate[snd_ch] = 1800; + tx_bitrate[snd_ch] = 3600; if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -659,6 +467,9 @@ void init_Q2400(int snd_ch) modem_mode[snd_ch] = MODE_QPSK; rx_shift[snd_ch] = 1200; rx_baudrate[snd_ch] = 1200; + tx_bitrate[snd_ch] = 2400; + pskStates[snd_ch] = 4; + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -668,7 +479,10 @@ void init_P2400(int snd_ch) modem_mode[snd_ch] = MODE_BPSK; rx_shift[snd_ch] = 2400; rx_baudrate[snd_ch] = 2400; - if (modem_def[snd_ch]) + tx_bitrate[snd_ch] = 2400; + pskStates[snd_ch] = 2; + + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -677,6 +491,9 @@ void init_P1200(int snd_ch) modem_mode[snd_ch] = MODE_BPSK; rx_shift[snd_ch] = 1200; rx_baudrate[snd_ch] = 1200; + tx_bitrate[snd_ch] = 1200; + pskStates[snd_ch] = 2; + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -686,6 +503,9 @@ void init_P600(int snd_ch) modem_mode[snd_ch] = MODE_BPSK; rx_shift[snd_ch] = 600; rx_baudrate[snd_ch] = 600; + tx_bitrate[snd_ch] = 600; + pskStates[snd_ch] = 2; + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -695,6 +515,36 @@ void init_P300(int snd_ch) modem_mode[snd_ch] = MODE_BPSK; rx_shift[snd_ch] = 300; rx_baudrate[snd_ch] = 300; + pskStates[snd_ch] = 2; + tx_bitrate[snd_ch] = 300; + + if (modem_def[snd_ch]) + get_filter_values(snd_ch); +} + +void init_Q300(int snd_ch) +{ + qpsk_set[snd_ch].mode = QPSK_V26; + modem_mode[snd_ch] = MODE_QPSK; + + rx_shift[snd_ch] = 300; + rx_baudrate[snd_ch] = 300; + tx_bitrate[snd_ch] = 600; + pskStates[snd_ch] = 4; + + if (modem_def[snd_ch]) + get_filter_values(snd_ch); +} + +void init_8PSK300(int snd_ch) +{ + modem_mode[snd_ch] = MODE_8PSK; + + rx_shift[snd_ch] = 300; + rx_baudrate[snd_ch] = 300; + tx_bitrate[snd_ch] = 900; + pskStates[snd_ch] = 8; + if (modem_def[snd_ch]) get_filter_values(snd_ch); } @@ -705,6 +555,7 @@ void init_ARDOP(int snd_ch) rx_shift[snd_ch] = 500; rx_freq[snd_ch] = 1500; rx_baudrate[snd_ch] = 500; + tx_bitrate[snd_ch] = 500; if (modem_def[snd_ch]) get_filter_values(snd_ch); @@ -721,36 +572,23 @@ void set_speed(int snd_ch, int Modem) } +int needPSKRefresh = 0; + void init_speed(int snd_ch) { int low, high; - /* + pskStates[snd_ch] = 0; // Not PSK - if (BPF[snd_ch]>round(rx_samplerate/2) then BPF[snd_ch] = round(rx_samplerate/2); - if TXBPF[snd_ch]>round(rx_samplerate/2) then TXBPF[snd_ch] = round(rx_samplerate/2); - if LPF[snd_ch]>round(rx_samplerate/2) then LPF[snd_ch] = round(rx_samplerate/2); - if BPF[snd_ch]<1 then BPF[snd_ch] = 1; - if TXBPF[snd_ch]<1 then TXBPF[snd_ch] = 1; - if LPF[snd_ch]<1 then LPF[snd_ch] = 1; - if TXDelay[snd_ch]<1 then TXDelay[snd_ch] = 1; - if TXTail[snd_ch]<1 then TXTail[snd_ch] = 1; - if BPF_tap[snd_ch]>1024 then BPF_tap[snd_ch] = 1024; - if LPF_tap[snd_ch]>512 then LPF_tap[snd_ch] = 512; - if BPF_tap[snd_ch]<8 then BPF_tap[snd_ch] = 8; - if LPF_tap[snd_ch]<8 then LPF_tap[snd_ch] = 8; - if not (RCVR[snd_ch] in [0..8]) then RCVR[snd_ch] = 0; - if not (rcvr_offset[snd_ch] in [0..100]) then rcvr_offset[snd_ch] = 30; - if not (speed[snd_ch] in [0..modes_count]) then speed[snd_ch] = SPEED_300; -*/ switch (speed[snd_ch]) { case SPEED_8P4800: init_8P4800(snd_ch); break; - case SPEED_AE2400: - init_AE2400(snd_ch); + case SPEED_2400V26B: + init_V26B2400(snd_ch); + break; case SPEED_DW2400: @@ -780,6 +618,10 @@ void init_speed(int snd_ch) init_P1200(snd_ch); break; +// case SPEED_Q1200: +// init_Q1200(snd_ch); +// break; + case SPEED_P600: init_P600(snd_ch); break; @@ -788,6 +630,14 @@ void init_speed(int snd_ch) init_P300(snd_ch); break; + case SPEED_Q300: + init_Q300(snd_ch); + break; + + case SPEED_8PSK300: + init_8PSK300(snd_ch); + break; + case SPEED_300: init_300(snd_ch); @@ -812,12 +662,22 @@ void init_speed(int snd_ch) init_ARDOP(snd_ch); break; + + case SPEED_RUH48: + + init_RUH48(snd_ch); + break; + + case SPEED_RUH96: + + init_RUH96(snd_ch); + break; + } //QPSK_SM: begin move(#0#1#2#3, tx[0], 4); move(#0#32#64#96, rx[0], 4); end; //QPSK_V26: begin move(#2#3#1#0, tx[0], 4); move(#96#64#0#32, rx[0], 4); end; - if (modem_mode[snd_ch] == MODE_QPSK || modem_mode[snd_ch] == MODE_PI4QPSK) { switch (qpsk_set[snd_ch].mode) @@ -870,752 +730,9 @@ void init_speed(int snd_ch) */ wf_pointer(soundChannel[snd_ch]); - + CheckPSKWindows(); } -/* -procedure TForm1.show_combobox; -var - i word; -begin - for i = 0 to length(modes_name)-1 do - begin - ComboBox1.Items.Add(modes_name[i]); - ComboBox2.Items.Add(modes_name[i]); - end; - ComboBox1.ItemIndex = ComboBox1.Items.IndexOf(modes_name[Speed[1]]); - ComboBox2.ItemIndex = ComboBox2.Items.IndexOf(modes_name[Speed[2]]); -end; - -function TForm1.get_idx_by_name(name string) word; -var - i word; - found boolean; -begin - i = 0; - found = FALSE; - result = 0; - repeat - if name = modes_name[i] then - begin - found = TRUE; - result = i; - end - else inc(i); - until found or (i = length(modes_name)); -end; - -procedure TForm1.ReadIni; -var - snd_ch byte; -begin - TelIni = TIniFile.Create(cur_dir+"soundmodem.ini"); - with TelIni do - begin - UTC_Time = ReadBool("Init","UTCTime",FALSE); - MainPriority = ReadInteger("Init","Priority",2); - nr_monitor_lines = ReadInteger("Init","NRMonitorLines",500); - ptt = ReadString("Init","PTT","NONE"); - stop_wf = ReadBool("Init","StopWF",FALSE); - raduga = ReadBool("Init","DispMode",DISP_MONO); - stat_log = ReadBool("Init","StatLog",FALSE); - SND_RX_DEVICE = ReadInteger("Init","SndRXDevice",0); - SND_TX_DEVICE = ReadInteger("Init","SndTXDevice",0); - snd_rx_device_name = ReadString("Init","SndRXDeviceName",""); - snd_tx_device_name = ReadString("Init","SndTXDeviceName",""); - RX_SR = ReadInteger("Init","RXSampleRate",11025); - TX_SR = ReadInteger("Init","TXSampleRate",11025); - RX_PPM = ReadInteger("Init","RX_corr_PPM",0); - TX_PPM = ReadInteger("Init","TX_corr_PPM",0); - tx_bufcount = ReadInteger("Init","TXBufNumber",32); - rx_bufcount = ReadInteger("Init","RXBufNumber",32); - DebugMode = ReadInteger("Init","DisableUnit",0); - TX_rotate = ReadBool("Init","TXRotate",FALSE); - DualChan = ReadBool("Init","DualChan",FALSE); - DualPTT = ReadBool("Init","DualPTT",TRUE); - SCO = ReadBool("Init","SCO",FALSE); - stdtones = ReadBool("Init","UseStandardTones",TRUE); - // Channel A settings - maxframe[1] = ReadInteger("AX25_A","Maxframe",3); - fracks[1] = ReadInteger("AX25_A","Retries",15); - frack_time[1] = ReadInteger("AX25_A","FrackTime",5); - idletime[1] = ReadInteger("AX25_A","IdleTime",180); - slottime[1] = ReadInteger("AX25_A","SlotTime",100); - persist[1] = ReadInteger("AX25_A","Persist",128); - resptime[1] = ReadInteger("AX25_A","RespTime",1500); - TXFrmMode[1] = ReadInteger("AX25_A","TXFrmMode",1); - max_frame_collector[1] = ReadInteger("AX25_A","FrameCollector",6); - exclude_callsigns[1] = ReadString("AX25_A","ExcludeCallsigns",""); - exclude_APRS_frm[1] = ReadString("AX25_A","ExcludeAPRSFrmType",""); - KISS_opt[1] = ReadBool("AX25_A","KISSOptimization",FALSE); - dyn_frack[1] = ReadBool("AX25_A","DynamicFrack",FALSE); - recovery[1] = ReadInteger("AX25_A","BitRecovery",0); - NonAX25[1] = ReadBool("AX25_A","NonAX25Frm",FALSE); - MEMRecovery[1] = ReadInteger("AX25_A","MEMRecovery",200); - IPOLL[1] = ReadInteger("AX25_A","IPOLL",80); - MyDigiCall[1] = ReadString("AX25_A","MyDigiCall",""); - tx_hitoneraisedb[1] = ReadInteger("AX25_A","HiToneRaise",0); - // Channel B settings - maxframe[2] = ReadInteger("AX25_B","Maxframe",3); - fracks[2] = ReadInteger("AX25_B","Retries",15); - frack_time[2] = ReadInteger("AX25_B","FrackTime",5); - idletime[2] = ReadInteger("AX25_B","IdleTime",180); - slottime[2] = ReadInteger("AX25_B","SlotTime",100); - persist[2] = ReadInteger("AX25_B","Persist",128); - resptime[2] = ReadInteger("AX25_B","RespTime",1500); - TXFrmMode[2] = ReadInteger("AX25_B","TXFrmMode",1); - max_frame_collector[2] = ReadInteger("AX25_B","FrameCollector",6); - exclude_callsigns[2] = ReadString("AX25_B","ExcludeCallsigns",""); - exclude_APRS_frm[2] = ReadString("AX25_B","ExcludeAPRSFrmType",""); - KISS_opt[2] = ReadBool("AX25_B","KISSOptimization",FALSE); - dyn_frack[2] = ReadBool("AX25_B","DynamicFrack",FALSE); - recovery[2] = ReadInteger("AX25_B","BitRecovery",0); - NonAX25[2] = ReadBool("AX25_B","NonAX25Frm",FALSE); - MEMRecovery[2] = ReadInteger("AX25_B","MEMRecovery",200); - IPOLL[2] = ReadInteger("AX25_B","IPOLL",80); - MyDigiCall[2] = ReadString("AX25_B","MyDigiCall",""); - tx_hitoneraisedb[2] = ReadInteger("AX25_B","HiToneRaise",0); - // Modem settings - pkt_raw_min_len = ReadInteger("Modem","RawPktMinLen",17); - swap_ptt = ReadBool("Modem","SwapPTTPins",FALSE); - inv_ptt = ReadBool("Modem","InvPTTPins",FALSE); - Emph_all[1] = ReadBool("Modem","PreEmphasisAll1",TRUE); - Emph_all[2] = ReadBool("Modem","PreEmphasisAll2",TRUE); - emph_db[1] = ReadInteger("Modem","PreEmphasisDB1",0); - emph_db[2] = ReadInteger("Modem","PreEmphasisDB2",0); - txbpf[1] = ReadInteger("Modem","TXBPF1",500); - txbpf[2] = ReadInteger("Modem","TXBPF2",500); - bpf[1] = ReadInteger("Modem","BPF1",500); - bpf[2] = ReadInteger("Modem","BPF2",500); - lpf[1] = ReadInteger("Modem","LPF1",150); - lpf[2] = ReadInteger("Modem","LPF2",150); - BPF_tap[1] = ReadInteger("Modem","BPFTap1",256); - BPF_tap[2] = ReadInteger("Modem","BPFTap2",256); - LPF_tap[1] = ReadInteger("Modem","LPFTap1",128); - LPF_tap[2] = ReadInteger("Modem","LPFTap2",128); - DCD_threshold = ReadInteger("Modem","DCDThreshold",32); - rx_freq[1] = ReadFloat("Modem","RXFreq1",1700); - rx_freq[2] = ReadFloat("Modem","RXFreq2",1700); - CheckBox1.Checked = ReadBool("Modem","HoldPnt",FALSE); - BIT_AFC = ReadInteger("Modem","AFC",32); - txdelay[1] = ReadInteger("Modem","TxDelay1",250); - txdelay[2] = ReadInteger("Modem","TxDelay2",250); - txtail[1] = ReadInteger("Modem","TxTail1",50); - txtail[2] = ReadInteger("Modem","TxTail2",50); - diddles = ReadInteger("Modem","Diddles",0); - RCVR[1] = ReadInteger("Modem","NRRcvrPairs1",0); - RCVR[2] = ReadInteger("Modem","NRRcvrPairs2",0); - rcvr_offset[1] = ReadInteger("Modem","RcvrShift1",30); - rcvr_offset[2] = ReadInteger("Modem","RcvrShift2",30); - speed[1] = ReadInteger("Modem","ModemType1",SPEED_1200); - speed[2] = ReadInteger("Modem","ModemType2",SPEED_1200); - modem_def[1] = ReadBool("Modem","Default1",TRUE); - modem_def[2] = ReadBool("Modem","Default2",TRUE); - AGWServ = ReadBool("AGWHost","Server",TRUE); - AGWPort = ReadInteger("AGWHost","Port",8000); - KISSServ = ReadBool("KISS","Server",FALSE); - KISSPort = ReadInteger("KISS","Port",8100); - Form1.Top = ReadInteger("Window","Top",0); - Form1.Left = ReadInteger("Window","Left",0); - Form1.Height = ReadInteger("Window","Height",656); - Form1.Width = ReadInteger("Window","Width",764); - MinOnStart = ReadBool("Window","MinimizedOnStartup",FALSE); - Firstwaterfall1.checked = ReadBool("Window","Waterfall1",TRUE); - Secondwaterfall1.checked = ReadBool("Window","Waterfall2",FALSE); - Statustable1.checked = ReadBool("Window","StatTable",TRUE); - Monitor1.checked = ReadBool("Window","Monitor",TRUE); - RXRichEdit1.Font.Size = ReadInteger("Font","Size",RXRichEdit1.Font.Size); - RXRichEdit1.Font.Name = ReadString("Font","Name",RXRichEdit1.Font.Name); - end; - TelIni.Free; - newAGWPort = AGWPort; - newAGWServ = AGWServ; - newKISSPort = KISSPort; - newKISSServ = KISSServ; - - RX_SampleRate = RX_SR+RX_SR*0.000001*RX_PPM; - TX_SampleRate = TX_SR+TX_SR*0.000001*TX_PPM; - - panels[4] = Monitor1.Checked; - panels[3] = Statustable1.Checked; - panels[2] = Firstwaterfall1.Checked; - panels[1] = Secondwaterfall1.Checked; - - if tx_bufcount>255 then tx_bufcount = 255; - if tx_bufcount<2 then tx_bufcount = 2; - if rx_bufcount>255 then rx_bufcount = 255; - if rx_bufcount<2 then rx_bufcount = 2; - - if not (diddles in [0..2]) then diddles = 0; - - if nr_monitor_lines>65535 then nr_monitor_lines = 65535; - if nr_monitor_lines<10 then nr_monitor_lines = 10; - - if not (MainPriority in [0..3]) then MainPriority = 2; - - for snd_ch = 1 to 2 do - begin - - tx_hitoneraise[snd_ch] = power(10,-abs(tx_hitoneraisedb[snd_ch])/20); - - if IPOLL[snd_ch]<0 then IPOLL[snd_ch] = 0; - if IPOLL[snd_ch]>65535 then IPOLL[snd_ch] = 65535; - - if MEMRecovery[snd_ch]<1 then MEMRecovery[snd_ch] = 1; - if MEMRecovery[snd_ch]>65535 then MEMRecovery[snd_ch] = 65535; - - get_exclude_list(AnsiUpperCase(MyDigiCall[snd_ch]),list_digi_callsigns[snd_ch]); - get_exclude_list(AnsiUpperCase(exclude_callsigns[snd_ch]),list_exclude_callsigns[snd_ch]); - get_exclude_frm(exclude_APRS_frm[snd_ch],list_exclude_APRS_frm[snd_ch]); - - if resptime[snd_ch]<0 then resptime[snd_ch] = 0; - if resptime[snd_ch]>65535 then resptime[snd_ch] = 65535; - if persist[snd_ch]>255 then persist[snd_ch] = 255; - if persist[snd_ch]<32 then persist[snd_ch] = 32; - if fracks[snd_ch]<1 then fracks[snd_ch] = 1; - if frack_time[snd_ch]<1 then frack_time[snd_ch] = 1; - if idletime[snd_ch]0 then - for k = 0 to numdevs-1 do - begin - waveOutGetDevCaps(k,@DevOutCaps,sizeof(DevOutCaps)); - TXDevList.Add(DevOutCaps.szpname); - end; - numdevs = WaveInGetNumDevs; - if numdevs>0 then - for k = 0 to numdevs-1 do - begin - waveInGetDevCaps(k,@DevInCaps,sizeof(DevInCaps)); - RXDevList.Add(DevInCaps.szpname); - end; - // TX Dev - if (snd_tx_device<0) or (snd_tx_device> = TXDevList.Count) then snd_tx_device = 0; - if TXDevList.Count>0 then - if TXDevList.Strings[snd_tx_device]<>snd_tx_device_name then - begin - i = TXDevList.IndexOf(snd_tx_device_name); - if i> = 0 then snd_tx_device = i else snd_tx_device_name = TXDevList.Strings[snd_tx_device]; - end; - // RX Dev - if (snd_rx_device<0) or (snd_rx_device> = RXDevList.Count) then snd_rx_device = 0; - if RXDevList.Count>0 then - if RXDevList.Strings[snd_rx_device]<>snd_rx_device_name then - begin - i = RXDevList.IndexOf(snd_rx_device_name); - if i> = 0 then snd_rx_device = i else snd_rx_device_name = RXDevList.Strings[snd_rx_device]; - end; - RXDevList.Free; - TXDevList.Free; -end; - -procedure TForm1.startrx; -var - OpenResult MMRESULT; - Loop integer; - ErrorText string; -Begin - RX_device = TRUE; - RXBufferLength = rx_bufsize * Channels * (BitsPerSample div 8); - with WaveFormat do - begin - wFormatTag = WAVE_FORMAT_PCM; - nChannels = Channels; - nSamplesPerSec = RX_SR; - nAvgBytesPerSec = RX_SR * Channels * (BitsPerSample div 8); - nBlockAlign = Channels * (BitsPerSample div 8); - wBitsPerSample = BitsPerSample; - cbSize = 0; - end; - OpenResult = waveInOpen (@WaveInHandle,SND_RX_DEVICE,@WaveFormat,integer(Self.Handle),0,CALLBACK_WINDOW); - if OpenResult = MMSYSERR_NOERROR then - begin - for Loop = 1 to rx_bufcount do - begin - GetMem(RX_pbuf[Loop], RXBufferLength); - RX_header[Loop].lpData = RX_pbuf[Loop]; - RX_header[Loop].dwBufferLength = RXBufferLength; - RX_header[Loop].dwUser = Loop; - RX_header[Loop].dwFlags = 0; - RX_header[Loop].dwLoops = 0; - OpenResult = WaveInPrepareHeader(WaveInhandle, @RX_header[Loop], sizeof(TWaveHdr)); - if OpenResult = MMSYSERR_NOERROR then WaveInAddBuffer(WaveInHandle, @RX_header[Loop], sizeof(TWaveHdr)) - else - begin - case OpenResult of - MMSYSERR_INVALHANDLE ErrorText = "device handle is invalid"; - MMSYSERR_NODRIVER ErrorText = "no device driver present"; - MMSYSERR_NOMEM ErrorText = "memory allocation error, could be incorrect samplerate"; - else ErrorText = "unknown error"; - end; - MessageDlg(format("Error adding buffer %d device (%s)",[Loop, ErrorText]), mtError, [mbOk], 0); - end; - end; - WaveInStart(WaveInHandle); - end - else - begin - case OpenResult of - MMSYSERR_ERROR ErrorText = "unspecified error"; - MMSYSERR_BADDEVICEID ErrorText = "device ID out of range"; - MMSYSERR_NOTENABLED ErrorText = "driver failed enable"; - MMSYSERR_ALLOCATED ErrorText = "device already allocated"; - MMSYSERR_INVALHANDLE ErrorText = "device handle is invalid"; - MMSYSERR_NODRIVER ErrorText = "no device driver present"; - MMSYSERR_NOMEM ErrorText = "memory allocation error, could be incorrect samplerate"; - MMSYSERR_NOTSUPPORTED ErrorText = "function isn""t supported"; - MMSYSERR_BADERRNUM ErrorText = "error value out of range"; - MMSYSERR_INVALFLAG ErrorText = "invalid flag passed"; - MMSYSERR_INVALPARAM ErrorText = "invalid parameter passed"; - MMSYSERR_HANDLEBUSY ErrorText = "handle being used simultaneously on another thread (eg callback)"; - MMSYSERR_INVALIDALIAS ErrorText = "specified alias not found"; - MMSYSERR_BADDB ErrorText = "bad registry database"; - MMSYSERR_KEYNOTFOUND ErrorText = "registry key not found"; - MMSYSERR_READERROR ErrorText = "registry read error"; - MMSYSERR_WRITEERROR ErrorText = "registry write error"; - MMSYSERR_DELETEERROR ErrorText = "registry delete error"; - MMSYSERR_VALNOTFOUND ErrorText = "registry value not found"; - MMSYSERR_NODRIVERCB ErrorText = "driver does not call DriverCallback"; - else ErrorText = "unknown error"; - end; - MessageDlg(format("Error opening wave input device (%s)",[ErrorText]), mtError, [mbOk], 0); - RX_device = FALSE; - end; -end; - -procedure TForm1.stoprx; -var - Loop integer; -begin - if not RX_device then exit; - WaveInStop(WaveInHandle); - WaveInReset(WaveInHandle); - for Loop = 1 to rx_bufcount do - WaveInUnPrepareHeader(WaveInHandle, @RX_header[Loop], sizeof(TWaveHdr)); - WaveInClose(WaveInHandle); - for Loop = 1 to rx_bufcount do - begin - if RX_pbuf[Loop]<>nil then - begin - FreeMem(RX_pbuf[Loop]); - RX_pbuf[Loop] = nil; - end; - end; - RX_device = FALSE; -end; - -procedure TForm1.make_wave_buf(snd_ch byte; buf PChar); -const - amplitude = 22000; -var - i word; -begin - modulator(snd_ch,audio_buf[snd_ch],tx_bufsize); - if tx_status[snd_ch] = TX_NO_DATA then buf_status[snd_ch] = BUF_EMPTY; - for i = 0 to tx_bufsize-1 do - begin - case snd_ch of - 1 - begin - // left channel - PSmallInt(buf)^ = round(amplitude*audio_buf[snd_ch][i]); - Inc(PSmallInt(Buf)); - // right channel - if SCO then PSmallInt(buf)^ = round(amplitude*audio_buf[snd_ch][i]) else PSmallInt(buf)^ = 0; - Inc(PSmallInt(Buf)); - end; - 2 - begin - // left channel - if SCO then PSmallInt(buf)^ = round(amplitude*audio_buf[snd_ch][i]) else PSmallInt(buf)^ = 0; - Inc(PSmallInt(Buf)); - // right channel - PSmallInt(buf)^ = round(amplitude*audio_buf[snd_ch][i]); - Inc(PSmallInt(Buf)); - end; - end; - end; -end; - -procedure TForm1.starttx(snd_ch byte); -var - OpenResult MMRESULT; - Loop integer; - ErrorText string; - BufferLength longint; -Begin - if snd_status[snd_ch]<>SND_IDLE then exit; - BufferLength = tx_bufsize * Channels * (BitsPerSample div 8); - with WaveFormat do - begin - wFormatTag = WAVE_FORMAT_PCM; - nChannels = Channels; - nSamplesPerSec = TX_SR; - nAvgBytesPerSec = TX_SR * Channels * (BitsPerSample div 8); - nBlockAlign = Channels * (BitsPerSample div 8); - wBitsPerSample = BitsPerSample; - cbSize = 0; - end; - OpenResult = WaveOutOpen (@WaveOutHandle[snd_ch],SND_TX_DEVICE,@WaveFormat,integer(Self.Handle),0,CALLBACK_WINDOW); - if OpenResult = MMSYSERR_NOERROR then - begin - snd_status[snd_ch] = SND_TX; - buf_status[snd_ch] = BUF_FULL; - tx_status[snd_ch] = TX_SILENCE; - tx_buf_num[snd_ch] = 0; - tx_buf_num1[snd_ch] = 0; - for Loop = 1 to tx_bufcount do - begin - GetMem(TX_pbuf[snd_ch][Loop], BufferLength); - TX_header[snd_ch][Loop].lpData = TX_pbuf[snd_ch][Loop]; - TX_header[snd_ch][Loop].dwBufferLength = BufferLength; - TX_header[snd_ch][Loop].dwUser = 0; - TX_header[snd_ch][Loop].dwFlags = 0; - TX_header[snd_ch][Loop].dwLoops = 0; - OpenResult = WaveOutPrepareHeader(WaveOuthandle[snd_ch], @TX_header[snd_ch][Loop], sizeof(TWaveHdr)); - if OpenResult = MMSYSERR_NOERROR then - begin - // Заполнить буфер на передачу - if buf_status[snd_ch] = BUF_FULL then - begin - make_wave_buf(snd_ch,TX_pbuf[snd_ch][Loop]); - WaveOutWrite(WaveOutHandle[snd_ch],@TX_header[snd_ch][Loop],sizeof(TWaveHdr)); - inc(tx_buf_num1[snd_ch]); - end; - end - else - begin - case OpenResult of - MMSYSERR_INVALHANDLE ErrorText = "device handle is invalid"; - MMSYSERR_NODRIVER ErrorText = "no device driver present"; - MMSYSERR_NOMEM ErrorText = "memory allocation error, could be incorrect samplerate"; - else ErrorText = "unknown error"; - end; - MessageDlg(format("Error adding buffer %d device (%s)",[Loop, ErrorText]), mtError, [mbOk], 0); - end; - end; - end - else - begin - case OpenResult of - MMSYSERR_ERROR ErrorText = "unspecified error"; - MMSYSERR_BADDEVICEID ErrorText = "device ID out of range"; - MMSYSERR_NOTENABLED ErrorText = "driver failed enable"; - MMSYSERR_ALLOCATED ErrorText = "device already allocated"; - MMSYSERR_INVALHANDLE ErrorText = "device handle is invalid"; - MMSYSERR_NODRIVER ErrorText = "no device driver present"; - MMSYSERR_NOMEM ErrorText = "memory allocation error, could be incorrect samplerate"; - MMSYSERR_NOTSUPPORTED ErrorText = "function isn""t supported"; - MMSYSERR_BADERRNUM ErrorText = "error value out of range"; - MMSYSERR_INVALFLAG ErrorText = "invalid flag passed"; - MMSYSERR_INVALPARAM ErrorText = "invalid parameter passed"; - MMSYSERR_HANDLEBUSY ErrorText = "handle being used simultaneously on another thread (eg callback)"; - MMSYSERR_INVALIDALIAS ErrorText = "specified alias not found"; - MMSYSERR_BADDB ErrorText = "bad registry database"; - MMSYSERR_KEYNOTFOUND ErrorText = "registry key not found"; - MMSYSERR_READERROR ErrorText = "registry read error"; - MMSYSERR_WRITEERROR ErrorText = "registry write error"; - MMSYSERR_DELETEERROR ErrorText = "registry delete error"; - MMSYSERR_VALNOTFOUND ErrorText = "registry value not found"; - MMSYSERR_NODRIVERCB ErrorText = "driver does not call DriverCallback"; - else ErrorText = "unknown error"; - end; - MessageDlg(format("Error opening wave output device (%s)",[ErrorText]), mtError, [mbOk], 0); - end; -end; - -procedure TForm1.stoptx(snd_ch byte); -var - Loop integer; -begin - if snd_status[snd_ch]<>SND_TX then exit; - WaveOutReset(WaveOutHandle[snd_ch]); - for Loop = 1 to tx_bufcount do - WaveOutUnPrepareHeader(WaveOutHandle[snd_ch], @TX_header[snd_ch][Loop], sizeof(TWaveHdr)); - WaveOutClose(WaveOutHandle[snd_ch]); - for Loop = 1 to tx_bufcount do - begin - if TX_pbuf[snd_ch][Loop]<>nil then - begin - FreeMem(TX_pbuf[snd_ch][Loop]); - TX_pbuf[snd_ch][Loop] = nil; - end; - end; - WaveOutHandle[snd_ch] = 0; - snd_status[snd_ch] = SND_IDLE; -end; - -procedure show_grid_title; -const - title array [0..10] of string = ("MyCall","DestCall","Status","Sent pkts","Sent bytes","Rcvd pkts","Rcvd bytes","Rcvd FC","CPS TX","CPS RX","Direction"); -var - i byte; -begin - for i = 0 to 10 do Form1.StringGrid1.Cells[i,0] = title[i]; -end; -*/ -/* - -procedure disp1(src1,src2 array of single); -var - i,n word; - k,k1,amp1,amp2,amp3,amp4 single; - bm TBitMap; -begin - bm = TBitMap.Create; - bm.pixelformat = pf32bit; - //bm.pixelformat = pf24bit; - bm.Width = Form1.PaintBox2.Width; - bm.Height = Form1.PaintBox2.Height; - amp1 = 0; - amp3 = 0; - //k = 0.20; - k = 50000; - k1 = 0; - //k = 1000; - //k = 0.00001; - bm.Canvas.MoveTo(0,50); - bm.Canvas.LineTo(512,50); - n = 0; - for i = 0 to RX_Bufsize-1 do - begin - begin - amp2 = src1[i]; - amp4 = src2[i]; - bm.Canvas.Pen.Color = clRed; - bm.Canvas.MoveTo(n,50-round(amp1*k1)); - bm.Canvas.LineTo(n+1,50-round(amp2*k1)); - bm.Canvas.Pen.Color = clBlue; - bm.Canvas.MoveTo(n,50-round(amp3*k)); - bm.Canvas.LineTo(n+1,50-round(amp4*k)); - bm.Canvas.Pen.Color = clBlack; - inc(n); - amp1 = amp2; - amp3 = amp4; - end; - end; - Form1.PaintBox2.Canvas.Draw(0,0,bm); - bm.Free; -end; -*/ - -/* - -procedure TForm1.wf_pointer(snd_ch byte); -var - x single; - x1,x2,y,k,pos1,pos2,pos3 word; -begin - k = 24; - x = FFTSize/RX_SampleRate; - pos1 = round((rx_freq[snd_ch]-0.5*rx_shift[snd_ch])*x)-5; - pos2 = round((rx_freq[snd_ch]+0.5*rx_shift[snd_ch])*x)-5; - pos3 = round(rx_freq[snd_ch]*x); - x1 = pos1+5; - x2 = pos2+5; - y = k+5; - with bm3.Canvas do - begin - Draw(0,20,bm[snd_ch]); - Pen.Color = clWhite; - Brush.Color = clRed; - Polygon([Point(x1+3,y),Point(x1,y-7),Point(x1-3,y),Point(x2+3,y),Point(x2,y-7),Point(x2-3,y)]); - Brush.Color = clBlue; - Polygon([Point(x1+3,y),Point(x1,y+7),Point(x1-3,y),Point(x2+3,y),Point(x2,y+7),Point(x2-3,y)]); - Polyline([Point(pos3,k+1),Point(pos3,k+9)]); - Pen.Color = clBlack; - end; - case snd_ch of - 1 PaintBox1.Canvas.Draw(0,0,bm3); - 2 PaintBox3.Canvas.Draw(0,0,bm3); - end; -end; - -procedure TForm1.wf_Scale; -var - k single; - max_freq,x,i word; -begin - max_freq = round(RX_SampleRate*0.005); - k = 100*FFTSize/RX_SampleRate; - with bm1.Canvas do - begin - Brush.Color = clBlack; - FillRect(ClipRect); - Pen.Color = clWhite; - Font.Color = clWhite; - Font.Size = 8; - for i = 0 to max_freq do - begin - x = round(k*i); - if x<1025 then - begin - if (i mod 5) = 0 then - PolyLine([Point(x,20),Point(x,13)]) - else - PolyLine([Point(x,20),Point(x,16)]); - if (i mod 10) = 0 then TextOut(x-12,1,inttostr(i*100)); - end; - end; - Pen.Color = clBlack; - end; - bm3.Canvas.Draw(0,0,bm1); -end; -*/ void chk_snd_buf(float * buf, int len) { @@ -1693,8 +810,11 @@ void runModems() if (modem_mode[snd_ch] == MODE_ARDOP) continue; // Processed above - // do we need to do this again ?? -// make_core_BPF(snd_ch, rx_freq[snd_ch], bpf[snd_ch]); + if (modem_mode[snd_ch] == MODE_RUH) + continue; // Processed above + + // do we need to do this again ?? + // make_core_BPF(snd_ch, rx_freq[snd_ch], bpf[snd_ch]); if (multiCore) // Run modems in separate threads thread[snd_ch] = _beginthread(runModemthread, 0, (void *)(size_t)snd_ch); @@ -1745,7 +865,7 @@ void runModemthread(void * param) void BufferFull(short * Samples, int nSamples) // These are Stereo Samples { - word i, i1; + word i, i1, j; Byte snd_ch, rcvr_idx; int buf_offset; int Needed; @@ -1810,21 +930,72 @@ void BufferFull(short * Samples, int nSamples) // These are Stereo Samples short ardopbuff[1200]; i1 = 0; - for (i = 0; i < rx_bufsize; i++) + if (using48000) { - ardopbuff[i] = Samples[i1]; + i1 = 0; + j = 0; + + // Need to downsample 48K to 12K + // Try just skipping 3 samples + + nSamples /= 4; + + for (i = 0; i < nSamples; i++) + { + ardopbuff[i] = Samples[i1]; + i1 += 8; + } + } + else + { + for (i = 0; i < nSamples; i++) + { + ardopbuff[i] = Samples[i1]; + i1++; + i1++; + } + } + ARDOPProcessNewSamples(snd_ch, ardopbuff, nSamples); + } + + else if (modem_mode[snd_ch] == MODE_RUH) + { + i1 = 0; + if (modemtoSoundLR[snd_ch] == 1) // Using Right Chan + i1++; + + for (i = 0; i < nSamples; i++) + { + dw9600ProcessSample(snd_ch, Samples[i1]); i1++; i1++; } - - ARDOPProcessNewSamples(ardopbuff, nSamples); } + ProcessRXFrames(snd_ch); } // extract mono samples from data. data1 = Samples; + if (using48000) + { + i1 = 0; + j = 0; + + // Need to downsample 48K to 12K + // Try just skipping 3 samples + + nSamples /= 4; + + for (i = 0; i < nSamples; i++) + { + Samples[j++] = Samples[i1]; + Samples[j++] = Samples[i1 + 1]; + i1 += 8; + } + } + i1 = 0; // src_buf[0] is left data,. src_buf[1] right @@ -1833,7 +1004,7 @@ void BufferFull(short * Samples, int nSamples) // These are Stereo Samples if (UsingBothChannels) { - for (i = 0; i < rx_bufsize; i++) + for (i = 0; i < nSamples; i++) { src_buf[0][i] = data1[i1]; i1++; @@ -1847,7 +1018,7 @@ void BufferFull(short * Samples, int nSamples) // These are Stereo Samples i1 = 1; - for (i = 0; i < rx_bufsize; i++) + for (i = 0; i < nSamples; i++) { src_buf[1][i] = data1[i1]; i1 += 2; @@ -1857,7 +1028,7 @@ void BufferFull(short * Samples, int nSamples) // These are Stereo Samples { // Extract just left - for (i = 0; i < rx_bufsize; i++) + for (i = 0; i < nSamples; i++) { src_buf[0][i] = data1[i1]; i1 += 2; @@ -2185,8 +1356,18 @@ char * frame_monitor(string * frame, char * code, int tx_stat) case U_UI: frm = "UI"; + break; + + case U_XID: + + frm = "XID"; + break; + + case U_TEST: + + frm = "TEST"; } - + if (Digi[0]) sprintf(AGW_path, "Fm %s To %s Via %s <%s %c%s",CallFrom, CallTo, Digi, frm, c, p); else @@ -2229,624 +1410,3 @@ char * frame_monitor(string * frame, char * code, int tx_stat) return FrameData; } - -/* -procedure TForm1.RX2TX(snd_ch byte); -begin - if snd_status[snd_ch] = SND_IDLE then begin ptton(snd_ch); starttx(snd_ch); end; -end; - -function TForm1.frame_monitor(s,code string; tx_stat boolean) string; -var - len word; - s_tx_stat string; - time_now,s1,c,p string; - callfrom,callto,digi,path,data,frm string; - frm_body string; - pid,nr,ns,f_type,f_id byte; - rpt,cr,pf boolean; - i word; -begin - decode_frame(s,path,data,pid,nr,ns,f_type,f_id,rpt,pf,cr); - len = length(data); - // NETROM parsing - if pid = $CF then data = parse_NETROM(data,f_id); - // IP parsing - if pid = $CC then data = parse_IP(data); - // ARP parsing - if pid = $CD then data = parse_ARP(data); - // - get_monitor_path(path,CallTo,CallFrom,Digi); - if cr then - begin - c = "C"; - if pf then p = " P" else p = ""; - end - else - begin - c = "R"; - if pf then p = " F" else p = ""; - end; - frm = "UNKN"; - case f_id of - I_I frm = "I"; - S_RR frm = "RR"; - S_RNR frm = "RNR"; - S_REJ frm = "REJ"; - U_SABM frm = "SABM"; - U_DISC frm = "DISC"; - U_DM frm = "DM"; - U_UA frm = "UA"; - U_FRMR frm = "FRMR"; - U_UI frm = "UI"; - end; - case tx_stat of - TRUE s_tx_stat = "T"; - FALSE s_tx_stat = "R"; - end; - s1 = ""; - - if code<>"" then code = " ["+code+"]"; - if UTC_Time then time_now = " [UTC"+get_UTC_time+s_tx_stat+"]" - else time_now = " ["+FormatDateTime("hhmmss",now)+s_tx_stat+"]"; - - if digi = "" then frm_body = "Fm "+CallFrom+" To "+CallTo+" <"+frm+" "+c+p - else frm_body = "Fm "+CallFrom+" To "+CallTo+" Via "+Digi+" <"+frm+" "+c+p; - case f_type of - I_FRM frm_body = frm_body+" R"+inttostr(nr)+" S"+inttostr(ns)+" Pid = "+dec2hex(pid)+" Len = "+inttostr(len)+">"+time_now+code+#13+data; - U_FRM if f_id = U_UI then frm_body = frm_body+" Pid = "+dec2hex(pid)+" Len = "+inttostr(len)+">"+time_now+code+#13+data - else if f_id = U_FRMR then begin data = copy(data+#0#0#0,1,3); frm_body = frm_body+">"+time_now+code+#13+inttohex((byte(data[1]) shl 16) or (byte(data[2]) shl 8) or byte(data[3]),6) end - else frm_body = frm_body+">"+time_now+code; - S_FRM frm_body = frm_body+" R"+inttostr(nr)+">"+time_now+code; - end; - for i = 1 to length(frm_body) do - begin - if frm_body[i]>#31 then s1 = s1+frm_body[i]; - if frm_body[i] = #13 then s1 = s1+#13#10; - if frm_body[i] = #10 then s1 = s1+""; - if frm_body[i] = #9 then s1 = s1+#9; - end; - result = s1; -end; - -procedure TForm1.waterfall_init; -begin - bm[1] = TBitMap.Create; - bm[2] = TBitMap.Create; - bm1 = TBitMap.Create; - bm2 = TBitMap.Create; - bm3 = TBitMap.Create; - bm[1].pixelformat = pf32bit; - bm[2].pixelformat = pf32bit; - bm1.pixelformat = pf32bit; - bm2.pixelformat = pf32bit; - bm3.pixelformat = pf32bit; - bm[1].Height = PaintBox1.Height-20; - bm[1].Width = PaintBox1.width; - bm[2].Height = PaintBox1.Height-20; - bm[2].Width = PaintBox1.width; - bm1.Height = 20; - bm1.Width = PaintBox1.width; - bm3.Height = PaintBox1.Height; - bm3.Width = PaintBox1.width; -end; - -procedure TForm1.waterfall_free; -begin - bm[1].Free; - bm[2].Free; - bm1.Free; - bm2.Free; - bm3.Free; -end; - -procedure TForm1.StartAGW; -begin - try - ServerSocket1.Port = AGWPort; - ServerSocket1.Active = AGWServ; - except - ServerSocket1.Active = FALSE; - MessageDlg("AGW host port is busy!", mtWarning,[mbOk],0); - end; -end; - -procedure TForm1.StartKISS; -begin - try - ServerSocket2.Port = KISSPort; - ServerSocket2.Active = KISSServ; - except - ServerSocket2.Active = FALSE; - MessageDlg("KISS port is busy!", mtWarning,[mbOk],0); - end; -end; - -procedure fft_window_init; -var - mag single; - i word; -begin - mag = 2*pi/(FFTSize-1); - for i = 0 to FFTSize-1 do fft_window_arr[i] = 0.5-0.5*cos(i*mag); //hann -end; - -procedure TForm1.FormCreate(Sender TObject); -begin - if hPrevInst <> 0 then begin - MessageDlg("Программа уже запущена!", mtError, [mbOk], 0); - Application.Terminate; - end; - RS = TReedSolomon.Create(Self); - MainThreadHandle = GetCurrentThread; - form1.Caption = MODEM_CAPTION+" - Ver "+MODEM_VERSION; - cur_dir = ExtractFilePath(Application.ExeName); - fft_window_init; - detector_init; - kiss_init; - agw_init; - ax25_init; - init_raduga; - waterfall_init; - ReadIni; - show_combobox; - show_grid_title; - show_mode_panels; - show_panels; - wf_pointer(1); - wf_pointer(2); - wf_Scale; - ChangePriority; - Visible = TRUE; - StartAGW; - StartKISS; - PTTOpen; - startrx; - TimerEvent = TIMER_EVENT_OFF; - if (debugmode and DEBUG_TIMER) = 0 then create_timer1; - if MinOnStart then WindowState = wsMinimized; -end; - -procedure TForm1.TrackBar1Change(Sender TObject); -begin - dcd_threshold = TrackBar1.position; -end; -*/ - -void Timer_Event2() -{ - if (TimerStat2 == TIMER_BUSY || TimerStat2 == TIMER_OFF) - return; - - TimerStat2 = TIMER_BUSY; - -// show_grid(); - - /* - - if (mod_icon_status = MOD_WAIT) then inc(icon_timer); - if icon_timer = 10 then mod_icon_status = MOD_IDLE; - if (mod_icon_status<>MOD_WAIT) and (mod_icon_status<>last_mod_icon_status) then - begin - icon_timer = 0; - case mod_icon_status of - MOD_IDLE form1.CoolTrayIcon1.IconIndex = 0; - MOD_RX begin form1.CoolTrayIcon1.IconIndex = 1; mod_icon_status = MOD_WAIT; end; - MOD_TX form1.CoolTrayIcon1.IconIndex = 2; - end; - last_mod_icon_status = mod_icon_status; - end; - //*/ - - TimerStat2 = TIMER_FREE; -} - -/* - -procedure TimeProc1(uTimerId, uMesssage UINT; dwUser, dw1, dw2 DWORD); stdcall; -begin - TimerEvent = TIMER_EVENT_ON; -end; - -procedure TForm1.create_timer1; -var - TimeEpk cardinal; -begin - TimeEpk = 100; - TimerId1 = TimeSetEvent(TimeEpk,0,@TimeProc1,0,TIME_PERIODIC); -end; - -procedure TForm1.free_timer1; -begin - TimerStat1 = TIMER_OFF; - timeKillEvent(TimerId1); -end; - -*/ - -/* - - -procedure TForm1.PaintBox1MouseMove(Sender TObject; Shift TShiftState; X, - Y Integer); -var - low,high word; -begin - if CheckBox1.Checked then exit; - if not mouse_down[1] then Exit; - rx_freq[1] = round(x*RX_SampleRate/FFTSize); - low = round(rx_shift[1]/2+Rcvr[1]*rcvr_offset[1]+1); - high = round(rx_samplerate/2-(rx_shift[1]/2+Rcvr[1]*rcvr_offset[1])); - if (rx_freq[1]-low)<0 then rx_freq[1] = low; - if (high-rx_freq[1])<0 then rx_freq[1] = high; - tx_freq[1] = rx_freq[1]; - show_freq_a; -end; - -procedure TForm1.PaintBox3MouseMove(Sender TObject; Shift TShiftState; X, - Y Integer); -var - low,high word; -begin - if CheckBox1.Checked then exit; - if not mouse_down[2] then Exit; - rx_freq[2] = round(x*RX_SampleRate/FFTSize); - low = round(rx_shift[2]/2+Rcvr[2]*rcvr_offset[2]+1); - high = round(rx_samplerate/2-(rx_shift[2]/2+Rcvr[2]*rcvr_offset[2])); - if (rx_freq[2]-low)<0 then rx_freq[2] = low; - if (high-rx_freq[2])<0 then rx_freq[2] = high; - tx_freq[2] = rx_freq[2]; - show_freq_b; -end; - -procedure TForm1.PaintBox1MouseUp(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); -begin - mouse_down[1] = FALSE; -end; - -procedure TForm1.PaintBox3MouseUp(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); -begin - mouse_down[2] = FALSE; -end; - -procedure TForm1.PaintBox1MouseDown(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); -var - low,high word; -begin - if CheckBox1.Checked then exit; - if not (ssLeft in shift) then Exit; - mouse_down[1] = TRUE; - rx_freq[1] = round(x*RX_SampleRate/FFTSize); - low = round(rx_shift[1]/2+Rcvr[1]*rcvr_offset[1]+1); - high = round(rx_samplerate/2-(rx_shift[1]/2+Rcvr[1]*rcvr_offset[1])); - if (rx_freq[1]-low)<0 then rx_freq[1] = low; - if (high-rx_freq[1])<0 then rx_freq[1] = high; - tx_freq[1] = rx_freq[1]; - show_freq_a; -end; - -procedure TForm1.PaintBox3MouseDown(Sender TObject; Button TMouseButton; - Shift TShiftState; X, Y Integer); -var - low,high word; -begin - if CheckBox1.Checked then exit; - if not (ssLeft in shift) then Exit; - mouse_down[2] = TRUE; - rx_freq[2] = round(x*RX_SampleRate/FFTSize); - low = round(rx_shift[2]/2+Rcvr[2]*rcvr_offset[2]+1); - high = round(rx_samplerate/2-(rx_shift[2]/2+Rcvr[2]*rcvr_offset[2])); - if (rx_freq[2]-low)<0 then rx_freq[2] = low; - if (high-rx_freq[2])<0 then rx_freq[2] = high; - tx_freq[2] = rx_freq[2]; - show_freq_b; -end; - -procedure TForm1.ServerSocket1ClientRead(Sender TObject; - Socket TCustomWinSocket); -var - s string; -begin - s = Socket.ReceiveText; - AGW_explode_frame(Socket.sockethandle,s); -end; - -procedure TForm1.ServerSocket1ClientDisconnect(Sender TObject; - Socket TCustomWinSocket); -begin - del_incoming_mycalls_by_sock(socket.SocketHandle); - AGW_del_socket(socket.SocketHandle); -end; - -procedure TForm1.ServerSocket1ClientError(Sender TObject; - Socket TCustomWinSocket; ErrorEvent TErrorEvent; - var ErrorCode Integer); -begin - del_incoming_mycalls_by_sock(socket.SocketHandle); - AGW_del_socket(socket.SocketHandle); - ErrorCode = 0; -end; - -procedure TForm1.ServerSocket1ClientConnect(Sender TObject; - Socket TCustomWinSocket); -begin - agw_add_socket(Socket.sockethandle); -end; - -procedure TForm1.OutputVolume1Click(Sender TObject); -var - s string; -begin - s = "SndVol32.exe -D"+inttostr(SND_TX_DEVICE); - WinExec(pchar(s),SW_SHOWNORMAL); -end; - -procedure TForm1.InputVolume1Click(Sender TObject); -var - s string; -begin - s = "SndVol32.exe -R -D"+inttostr(SND_RX_DEVICE); - WinExec(pchar(s),SW_SHOWNORMAL); -end; - -procedure TForm1.CoolTrayIcon1Click(Sender TObject); -begin - CoolTrayIcon1.ShowMainForm; -end; - -procedure TForm1.CoolTrayIcon1Cycle(Sender TObject; NextIndex Integer); -begin - CoolTrayIcon1.IconIndex = 2; - CoolTrayIcon1.CycleIcons = FALSE; -end; - -procedure TForm1.ABout1Click(Sender TObject); -begin - Form2.ShowModal; -end; - -procedure TForm1.put_frame(snd_ch byte; frame,code string; tx_stat,excluded boolean); -var - s string; -begin - if RxRichedit1.Focused then Windows.SetFocus(0); - if code = "NON-AX25" then - s = inttostr(snd_ch)+" ["+FormatDateTime("hhmmss",now)+"R]" - else - s = inttostr(snd_ch)+""+frame_monitor(frame,code,tx_stat); - //RxRichedit1.Lines.BeginUpdate; - RxRichedit1.SelStart = length(RxRichedit1.text); - RxRichEdit1.SelLength = length(s); - case tx_stat of - TRUE RxRichEdit1.SelAttributes.Color = clMaroon; - FALSE RxRichEdit1.SelAttributes.Color = clBlack; - end; - if excluded then RxRichEdit1.SelAttributes.Color = clGreen; - RxRichedit1.SelText = s+#10; - if RxRichedit1.Lines.Count>nr_monitor_lines then - repeat - RxRichedit1.Lines.Delete(0); - until RxRichedit1.Lines.Count = nr_monitor_lines; - RxRichedit1.HideSelection = FALSE; - RxRichedit1.SelStart = length(RxRichedit1.text); - RxRichedit1.SelLength = 0; - RxRichedit1.HideSelection = TRUE; - //RxRichedit1.Lines.EndUpdate; -end; - -procedure TForm1.show_mode_panels; -begin - panel8.Align = alNone; - panel6.Align = alNone; - if dualchan then panel6.Visible = TRUE else panel6.Visible = FALSE; - panel8.Align = alLeft; - panel6.Align = alLeft; -end; - -procedure TForm1.show_panels; -var - i byte; -begin - panel1.Align = alNone; - panel2.Align = alNone; - panel3.Align = alNone; - panel4.Align = alNone; - panel5.Align = alNone; - for i = 1 to 5 do - case i of - 1 panel1.Visible = panels[i]; - 2 panel5.Visible = panels[i]; - 3 panel3.Visible = panels[i]; - 4 panel4.Visible = panels[i]; - 5 panel2.Visible = panels[i]; - end; - panel1.Align = alBottom; - panel5.Align = alBottom; - panel3.Align = alBottom; - panel2.Align = alTop; - panel4.Align = alClient; -end; - -procedure TForm1.Secondwaterfall1Click(Sender TObject); -begin - case Secondwaterfall1.Checked of - TRUE Secondwaterfall1.Checked = FALSE; - FALSE Secondwaterfall1.Checked = TRUE; - end; - panels[1] = Secondwaterfall1.Checked; - show_panels; -end; - - - -procedure TForm1.Firstwaterfall1Click(Sender TObject); -begin - case Firstwaterfall1.Checked of - TRUE Firstwaterfall1.Checked = FALSE; - FALSE Firstwaterfall1.Checked = TRUE; - end; - panels[2] = Firstwaterfall1.Checked; - show_panels; -end; - -procedure TForm1.Statustable1Click(Sender TObject); -begin - case Statustable1.Checked of - TRUE Statustable1.Checked = FALSE; - FALSE Statustable1.Checked = TRUE; - end; - panels[3] = Statustable1.Checked; - show_panels; -end; - -procedure TForm1.Monitor1Click(Sender TObject); -begin - case Monitor1.Checked of - TRUE Monitor1.Checked = FALSE; - FALSE Monitor1.Checked = TRUE; - end; - panels[4] = Monitor1.Checked; - show_panels; -end; - -procedure TForm1.Devices1Click(Sender TObject); -begin - if (ptt = "EXT") or (ptt = "CAT") then Form3.Button3.Enabled = TRUE else Form3.Button3.Enabled = FALSE; - Form3.GetDeviceInfo; - form3.ShowModal; -end; - -procedure TForm1.FormPaint(Sender TObject); -begin - RxRichedit1.HideSelection = FALSE; - RxRichedit1.SelStart = length(RxRichedit1.text); - RxRichedit1.SelLength = 0; - RxRichedit1.HideSelection = TRUE; -end; - -procedure TForm1.Filters1Click(Sender TObject); -begin - Form5.Show_modem_settings; -end; - -procedure TForm1.Clearmonitor1Click(Sender TObject); -begin - RxRichEdit1.Clear; - frame_count = 0; - single_frame_count = 0; -end; - -procedure TForm1.Copytext1Click(Sender TObject); -begin - RxRichEdit1.CopyToClipboard; -end; - -procedure TForm1.ApplicationEvents1Minimize(Sender TObject); -begin - if stop_wf then w_state = WIN_MINIMIZED; -end; - -procedure TForm1.ApplicationEvents1Restore(Sender TObject); -begin - w_state = WIN_MAXIMIZED; -end; - -procedure TForm1.ServerSocket2ClientConnect(Sender TObject; - Socket TCustomWinSocket); -begin - KISS_add_stream(socket.sockethandle); -end; - -procedure TForm1.ServerSocket2ClientDisconnect(Sender TObject; - Socket TCustomWinSocket); -begin - KISS_del_stream(socket.sockethandle); -end; - -procedure TForm1.ServerSocket2ClientError(Sender TObject; - Socket TCustomWinSocket; ErrorEvent TErrorEvent; - var ErrorCode Integer); -begin - KISS_del_stream(socket.sockethandle); - ErrorCode = 0; -end; - -procedure TForm1.ServerSocket2ClientRead(Sender TObject; - Socket TCustomWinSocket); -var - data string; -begin - data = socket.ReceiveText; - KISS_on_data_in(socket.sockethandle,data); -end; - -procedure TForm1.Font1Click(Sender TObject); -begin - FontDialog1.Font = RXRichEdit1.Font; - if FontDialog1.Execute then - begin - RXRichEdit1.SelStart = 0; - RXRichEdit1.SelLength = Length(RXRichEdit1.Text); - RXRichEdit1.SelAttributes.Size = FontDialog1.Font.Size; - RXRichEdit1.SelAttributes.Name = FontDialog1.Font.Name; - RXRichEdit1.Font.Size = FontDialog1.Font.Size; - RXRichEdit1.Font.Name = FontDialog1.Font.Name; - WriteIni; - end; -end; - -procedure TForm1.Calibration1Click(Sender TObject); -begin - Form6.ShowModal; -end; - -procedure TForm1.ComboBox1Change(Sender TObject); -begin - Speed[1] = get_idx_by_name(ComboBox1.Text); - init_speed(1); - windows.setfocus(0); -end; - -procedure TForm1.ComboBox1KeyDown(Sender TObject; var Key Word; - Shift TShiftState); -begin - key = 0; - windows.SetFocus(0); -end; - -procedure TForm1.ComboBox1KeyPress(Sender TObject; var Key Char); -begin - key = #0; - windows.SetFocus(0); -end; - -procedure TForm1.ComboBox2Change(Sender TObject); -begin - Speed[2] = get_idx_by_name(ComboBox2.Text); - init_speed(2); - windows.setfocus(0); -end; - -procedure TForm1.FormDestroy(Sender TObject); -var - snd_ch byte; -begin - stoprx; - for snd_ch = 1 to 2 do if snd_status[snd_ch] = SND_TX then stoptx(snd_ch); - if (debugmode and DEBUG_TIMER) = 0 then free_timer1; - TimerStat2 = TIMER_OFF; - PTTClose; - ax25_free; - agw_free; - kiss_free; - detector_free; - RS.Free; - waterfall_free; - WriteIni; -end; - -end. -*/ \ No newline at end of file -- cgit v1.2.3