#include #include #include #include #include #include "wdef.h" #include "globdef.h" #include "uidef.h" #include "fft1def.h" #include "conf.h" #include "txdef.h" #include "vernr.h" #include "screendef.h" #include "sigdef.h" #include "thrdef.h" #include "sdrdef.h" // allocate 16 megabytes for phonetics (float format). #define PHONETICS_SIZE (1024*4096) #define VOICELAB_AMPLITUDE (0.2*0x7fff) #define LEVEL_METER_X 65 extern void win_query_warning(int *line); void close_tx_output(void) { } int lir_tx_output_samples(void) { return 0; } int lir_tx_input_samples(void) { return 0; } VOID CALLBACK tx_daout(HWAVEOUT hwi, UINT iMsg, DWORD dwInst, DWORD dwParam1, DWORD dwParam2) { DWORD i; i=(DWORD)hwi; i=dwInst; i=dwParam2; i=iMsg; i=dwParam1; if(iMsg == WIM_DATA) { } else { if(iMsg == WIM_CLOSE) { i=(DWORD)hwi; i=dwInst; i=dwParam2; tx_audio_out=-1; } else { if(iMsg == WIM_OPEN) { tx_audio_out=0; } } } } void open_tx_output(void) { int errcod; WAVEFORMATEXTENSIBLE wfmt; MMRESULT mmrs; int i, k; if(tx_audio_out != -1)return; wfmt.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfmt.Format.nSamplesPerSec=ui.tx_da_speed; if(ui.tx_da_bytes == 2) { wfmt.Samples.wValidBitsPerSample=16; wfmt.Format.wBitsPerSample=16; } else { wfmt.Samples.wValidBitsPerSample=24; wfmt.Format.wBitsPerSample=32; } wfmt.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; wfmt.dwChannelMask = 7; wfmt.Format.nChannels=ui.tx_da_channels; wfmt.Format.nBlockAlign=(unsigned int)((wfmt.Format.nChannels * wfmt.Format.wBitsPerSample) / 8.0); wfmt.Format.nAvgBytesPerSec=wfmt.Format.nBlockAlign*wfmt.Format.nSamplesPerSec; wfmt.Format.cbSize=sizeof(WAVEFORMATEXTENSIBLE);; mmrs=waveOutOpen(&hwav_txdaout, ui.tx_dadev_no, (WAVEFORMATEX*)&wfmt, (DWORD)tx_daout, 0, CALLBACK_FUNCTION); if(mmrs != MMSYSERR_NOERROR) { lirerr(1234); return; } errcod=1237; tx_waveout_buf=malloc(NO_OF_TX_WAVEOUT*tx_daout_block+wfmt.Format.nBlockAlign); if(tx_waveout_buf==NULL)goto wave_close; tx_wave_outhdr=malloc(NO_OF_TX_WAVEOUT*sizeof(WAVEHDR)); if(tx_wave_outhdr==NULL)goto free_waveout; tx_da_wrbuf=malloc(tx_daout_block); if(tx_da_wrbuf==NULL)goto free_outhdr; txdaout_newbuf_ptr=0; for(i=0; i>1; while(i>0) { i>>=1; frag++; } if(frag < 4)frag=4; frag=frag|0x7fff0000; if(ioctl(tx_audio_in, SNDCTL_DSP_SETFRAGMENT, &frag) == -1) { lirerr(1262); return; } i=AFMT_S16_LE; #ifdef AFMT_S32_LE if(txssb.input_bytes==4)i=AFMT_S32_LE; #else txssb.input_bytes=2; #endif j=i; if(ioctl(tx_audio_in, SNDCTL_DSP_SETFMT, &i) == -1) { lirerr(231013); return; } if(i!=j) { lirerr(231014); return; } // Set number of channels j=txssb.input_channels; i=j; if(ioctl(tx_audio_in, SNDCTL_DSP_CHANNELS, &i) == -1) { lirerr(231009); return; } if(i != j) { lirerr(231010); return; } i=ui.tx_ad_speed; if(ioctl(tx_audio_in, SNDCTL_DSP_SPEED, &i)==-1) { lirerr(231011); return; } t1=(float)(i)/ui.tx_ad_speed; if(t1 > 1.05 || t1 < 0.95) { lirerr(231012); return; } ui.tx_ad_speed=i; */ } void close_tx_input(void) { if(close(tx_audio_in)==-1)lirerr(231037); tx_audio_in=-1; } int tx_setup(void) { /* int dev_flag[MAX_DEVNAMES]; int dev_max_speed[MAX_DEVNAMES]; int dev_min_speed[MAX_DEVNAMES]; int rdwr_channels; int rdwr_speed; int line, column; int device_no; audio_buf_info ad_info; int rdwr_fmt; int nn, m; unsigned int device_id, no_of_dadev; */ unsigned int device_id; char s[256]; int line; unsigned no_of_txda; int maxline, maxcolumn; int i; char *testbuff; MMRESULT mmrs; WAVEOUTCAPS pwoc; testbuff = malloc(4096); if(testbuff == NULL) { lirerr(1044); goto tx_errexit; } rx_daout_channels=ui.rx_min_da_channels; genparm[DA_OUTPUT_SPEED]=ui.rx_min_da_speed; genparm[SECOND_FFT_ENABLE]=0; fft1_size=32768; tx_daout_block=256; rx_daout_block=256; timf1_sampling_speed=11025; i=read_txpar_file(); if(i == FALSE)goto do_tx_setup; // ******************************************************* // *** The A/D and A/D setup is already done. // *** Ask the user what he wants. // *** The transmit functions of Linrad are in a very early stage // *** and there is not much to choose from yet............ // ****************************************************** clear_screen(); lir_text(5,6,"B=Soundcard setup for Tx."); lir_text(5,7,"C=Speech processor setup."); lir_text(5,8,"X=Return to main menu"); kbd_sel:; await_processed_keyboard(); if(kill_all_flag) goto txend; switch (lir_inkey) { case 'B': goto do_tx_setup; case 'C': spproc_setup(); goto txend; case 'X': goto txend; default: goto kbd_sel; } do_tx_setup:; clear_screen(); settextcolor(15); lir_text(25,2,"TX mode set-up"); rx_daout_bytes=ui.rx_max_da_bytes; rx_daout_channels=ui.rx_max_da_channels; if(ui.rx_addev_no < SPECIFIC_DEVICE_CODES)open_rx_sndin(); if(kill_all_flag) goto txend; open_rx_sndout(); if(kill_all_flag) goto txend; if(ui.rx_addev_no < SPECIFIC_DEVICE_CODES) { read(rx_audio_in, testbuff, 1024); if(ui.rx_addev_no > 255) read(rx_audio_in2, testbuff, 1024); } for(i=0;i<1024;i++)testbuff[i]=0; write(rx_audio_out, testbuff, 1024); // First step through all devices and check which ones // we can open in write mode while the rx devices are open. maxline=screen_last_line-1; maxcolumn=screen_last_col; settextcolor(14); lir_text(10,4,"Available soundcards for tx output"); settextcolor(7); no_of_txda=waveInGetNumDevs(); if(no_of_txda == 0) { lir_text(5,2,"No soundcard detected (while rx active)."); lir_text(5,3,press_any_key); await_keyboard(); goto tx_errexit; } line=5; if(no_of_txda > MAX_WAV_DEVICES)no_of_txda=MAX_WAV_DEVICES; for(device_id=0; device_id"); ui.tx_da_channels=lir_get_integer(13,line, 1, 1, 2); clear_screen(); // Look for a device for microphone input. if(ui.rx_addev_no < SPECIFIC_DEVICE_CODES)open_rx_sndin(); if(kill_all_flag) goto txend; open_rx_sndout(); if(kill_all_flag) goto txend; open_tx_output(); if(kill_all_flag) goto txend; if(ui.rx_addev_no < SPECIFIC_DEVICE_CODES) { read(rx_audio_in, testbuff, 1024); if(ui.rx_addev_no > 255) read(rx_audio_in2, testbuff, 1024); } for(i=0;i<1024;i++)testbuff[i]=0; /* write(audio_out, testbuff, 1024); write(tx_audio_out, testbuff, 1024); // First step through all devices and check which ones // we can open in read mode while the rx devices and tx output are open. settextcolor(14); lir_text(10,4,"Checking device drivers for microphone input"); settextcolor(7); nn=0; line=5; for(device_no=0; device_no 1024) { read(rx_audio_in, testbuff, 1024); if(ioctl(rx_audio_in, SNDCTL_DSP_GETISPACE, &ad_info) == -1) { lirerr(291028); goto tx_errexit; } } if(ui.rx_addev_no > 255) { if(ioctl(rx_audio_in2, SNDCTL_DSP_GETISPACE, &ad_info) == -1) { lirerr(311028); goto tx_errexit; } while(ad_info.bytes > 1024) { read(rx_audio_in2, testbuff, 1024); if(ioctl(rx_audio_in2, SNDCTL_DSP_GETISPACE, &ad_info) == -1) { lirerr(321028); goto tx_errexit; } } } } for(i=0;i<1024;i++)testbuff[i]=0; if(ioctl(audio_out,SNDCTL_DSP_GETOSPACE, &ad_info) == -1) { lirerr(331028); goto tx_errexit; } while(ad_info.bytes > 1024) { write(audio_out, testbuff, 1024); if(ioctl(audio_out,SNDCTL_DSP_GETOSPACE, &ad_info) == -1) { lirerr(341028); goto tx_errexit; } } if(ioctl(tx_audio_out,SNDCTL_DSP_GETOSPACE, &ad_info) == -1) { lirerr(351028); goto tx_errexit; } while(ad_info.bytes > 1024) { write(tx_audio_out, testbuff, 1024); if(ioctl(audio_out,SNDCTL_DSP_GETOSPACE, &ad_info) == -1) { lirerr(361028); goto tx_errexit; } } rdwr_channels=0; rdwr_fmt=0; if(device_no != rx_audio_in) { make_devname(device_no); { sprintf(s,"Trying to open %s %s. Device defective if system hangs here.", dev_name, devmode_txt[0]); settextcolor(12); lir_text(0,line+1,s); settextcolor(7); tx_audio_in=open( dev_name, O_RDONLY|O_NONBLOCK, 0); if(tx_audio_in != -1) { line++; if(line >= maxline) { for(column=0; column>=3; } if(dev_min_speed[ui.tx_addev_no] != dev_max_speed[ui.tx_addev_no]) { clear_screen(); sprintf(s,"Select microphone A/D speed %d to %d", dev_min_speed[ui.tx_addev_no], dev_max_speed[ui.tx_addev_no]); lir_text(5,11,s); i=0; while(s[i] != 0)i++; ui.tx_ad_speed=lir_get_integer(i+7, 11, 6, dev_min_speed[ui.tx_addev_no], dev_max_speed[ui.tx_addev_no]); } else { ui.tx_ad_speed=dev_min_speed[ui.tx_addev_no]; } clear_screen(); make_devname(ui.tx_addev_no); sprintf(s,"Microphone input: %s, %d channel(s), %d bits, %d Hz",dev_name, txssb.input_channels,txssb.input_bytes<<3,ui.tx_ad_speed); settextcolor(14); lir_text(15,0,s); txpar_file=fopen("par_tx","w"); if(txpar_file == NULL) { lirerr(381164); goto tx_errexit; } txssb.check=TXPAR_VERNR; for(i=0; i