/* Generated by XDS Modula-2 to ANSI C v4.20 translator */ #define X2C_int32 #define X2C_index32 #ifndef X2C_H_ #include "X2C.h" #endif #define sdrtx_C_ #ifndef osi_H_ #include "osi.h" #endif #include #include #ifndef aprsstr_H_ #include "aprsstr.h" #endif #ifndef soundctl_H_ #include "soundctl.h" #endif /* audio to iq modulator am, fm, usb, lsb, wfm-stereo by oe5dxl */ #define sdrtx_SAMPLES 2048 #define sdrtx_OSSSAMP 48000 #define sdrtx_LEVEL 2.925625E+4 /* RADIOPREEM=0.88; */ #define sdrtx_RADIOFG 18000 #define sdrtx_RADIOFIRLEN 64 #define sdrtx_LF "\012" #define sdrtx_PI 3.1415926535 #define sdrtx_INTPOLS 64 #define sdrtx_REOPEN 1 #define sdrtx_EXITPRG 0 #define sdrtx_SENDNULL 2 struct LPCONTEXT24; struct LPCONTEXT24 { float uc1; float uc2; float il; float LPR; float OLPR; float LPL; }; struct LPCONTEXT12; struct LPCONTEXT12 { float uc; float il; float K1; float K2; }; enum MODS {sdrtx_mFM, sdrtx_mUSB, sdrtx_mLSB, sdrtx_mAM, sdrtx_mSTEREO, sdrtx_mUPSAMP}; struct STEREOCONTEXT; struct STEREOCONTEXT { float lastl; float lastr; float wpilot; }; static short buf[4096]; static int32_t adc; static int32_t i; static int32_t tmpi; static int32_t bi; static int32_t bq; static int32_t si; static int32_t sq; static int32_t shift; static int32_t of; static uint32_t wshift; static uint32_t is; static uint32_t p; static uint32_t adcrate; static uint32_t oform; static uint32_t pilotu; static uint32_t wpilotu; static uint32_t loops; static uint32_t firsteps; static uint32_t fs; static uint32_t fh; static float asamp; static float limlev; static float ohp; static float ohd; static float levmul; static float wsub; static float ssbwinc; static float pilot; static float clipplev; static float upsamplef; static float offset; static float bbi; static float bbq; static float sampmul; static float sampcnt; static float fmdeviation; static float wtone; static float devi; static float miclowpass; static float preemfilter; static float bassfilter; static float limlim; static float sample; static float outlev; static float floatlev; static float sinlev; static float subtonhz; static float subtonlev; static double limmul; static struct LPCONTEXT12 upsamplelpi; static struct LPCONTEXT12 upsamplelpq; static struct LPCONTEXT24 miclp; static struct LPCONTEXT24 ssblpi; static struct LPCONTEXT24 ssblpq; static struct LPCONTEXT24 ssblpic; static struct LPCONTEXT24 ssblpqc; static char exit0; static char exitpipe; static short abuf[1024]; static char ifn[1024]; static char ofn[1024]; static uint32_t pabuf; static uint32_t abuflen; static uint8_t mod; static struct STEREOCONTEXT cstereo; static short sintab[32768]; static float radiofirtab[64][64]; static float radiofirl[64]; static float radiofirr[64]; static void Error(char text[], uint32_t text_len) { X2C_PCOPY((void **)&text,text_len); osi_Werr(text, text_len); osi_Werr(" error abort\012", 14ul); X2C_ABORT(); X2C_PFREE(text); } /* end Error() */ static void Parms(void) { char err; char h[1024]; err = 0; for (;;) { osi_NextArg(h, 1024ul); if (h[0U]==0) break; if ((h[0U]=='-' && h[1U]) && h[2U]==0) { if (h[1U]=='m') { osi_NextArg(h, 1024ul); if (h[0U]=='u') mod = sdrtx_mUSB; else if (h[0U]=='l') mod = sdrtx_mLSB; else if (h[0U]=='a') mod = sdrtx_mAM; else if (h[0U]=='f') mod = sdrtx_mFM; else if (h[0U]=='s') mod = sdrtx_mSTEREO; else Error("-m a|f|u|l|s", 13ul); } else if (h[1U]=='o') { osi_NextArg(ofn, 1024ul); if (ofn[0U]==0 || ofn[0U]=='-') Error("-o ", 17ul); } else if (h[1U]=='O') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&outlev, h, 1024ul)) { Error("-O ", 23ul); } } else if (h[1U]=='i') { osi_NextArg(ifn, 1024ul); if (ifn[0U]==0 || ifn[0U]=='-') { Error("-i ", 20ul); } } else if (h[1U]=='s') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&offset, h, 1024ul)) { Error("-s ", 15ul); } } else if (h[1U]=='d') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&devi, h, 1024ul)) { Error("-d ", 13ul); } } else if (h[1U]=='g') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&levmul, h, 1024ul)) { Error("-g ", 16ul); } } else if (h[1U]=='e') exitpipe = 1; else if (h[1U]=='c') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&clipplev, h, 1024ul)) { Error("-c ", 15ul); } } else if (h[1U]=='u') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&upsamplef, h, 1024ul)) { Error("-u ", 20ul); } } else if (h[1U]=='l') { /* ELSIF h[1]="a" THEN NextArg(h); IF NOT StrToFix(limlim, h) OR (limlim<0.0) THEN Error("-u ") END; limlim:=1.0/(limlim+1.0); */ osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&miclowpass, h, 1024ul)) { Error("-l ", 16ul); } } else if (h[1U]=='p') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&preemfilter, h, 1024ul) || preemfilter>1.0f) { Error("-p ", 21ul); } } else if (h[1U]=='b') { /* IF preemfilter<>0.0 THEN preemfilter:=1.0/preemfilter END; */ osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&bassfilter, h, 1024ul)) { Error("-b ", 16ul); } } else if (h[1U]=='T') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&subtonhz, h, 1024ul)) { Error("-T ", 24ul); } osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&subtonlev, h, 1024ul)) { Error("-T ", 24ul); } } else if (h[1U]=='f') { osi_NextArg(h, 1024ul); if ((h[0U]=='i' && h[1U]=='1') && h[2U]=='6') oform = 2UL; else if ((h[0U]=='f' && h[1U]=='3') && h[2U]=='2') oform = 4UL; else if (h[0U]=='u' && h[1U]=='8') oform = 1UL; else Error("-f u8|i16|f32", 14ul); } else if (h[1U]=='r') { osi_NextArg(h, 1024ul); if (!aprsstr_StrToFix(&sampmul, h, 1024ul) || sampmul<2.0f) { Error("-r ", 22ul); } } else { if (h[1U]=='h') { osi_WrStrLn(" Modulate audio to IQ-File", 27ul); osi_WrStrLn(" -b <0..1> filter bass of modulation (n\ ot stereo) (0.05)", 67ul); osi_WrStrLn(" -c ssb rf-clipper level after A\ LC 1=off (1.0)", 64ul); osi_WrStrLn(" -d fm deviation (3000) (stereo \ 40000)", 56ul); osi_WrStrLn(" -e not exit on broken pipe", 45ul); osi_WrStrLn(" -f u8 i16 f32 (u8)", 37ul); osi_WrStrLn(" -g input loudness (not stereo) \ more for more ALC (50.0)", 74ul); osi_WrStrLn(" -h this", 26ul); osi_WrStrLn(" -i input file/pipe/oss-device (\ stereo 2 channel) (/dev/dsp)", 78ul); osi_WrStrLn(" all frequency parameters b\ ased on 48kHz input rate", 74ul); osi_WrStrLn(" -l modulation lowpass (not ster\ eo) 0=off (3000)", 66ul); osi_WrStrLn(" -m u(sb) l(sb) a(m) f(m) s(ster\ eo) (f)", 57ul); osi_WrStrLn(" -O output level (1.0)", 40ul); osi_WrStrLn(" -o output iq file/pipe", 41ul); osi_WrStrLn(" -p <0..1> preemphase of modulation (no\ t stereo) 0=off (0.8)", 71ul); osi_WrStrLn(" -r output/input samplerate (21.\ 33333)", 56ul); osi_WrStrLn(" -s shift signal from iq band ce\ nter (ssb:center of band!) (0)", 80ul); osi_WrStrLn(" -T (sub)Tone eg. 1\ 00.0 0.15", 59ul); osi_WrStrLn(" -u upsampler aliasing filter (f\ m deviation+modlowpass, ssb 1500, stereo 110000)", 98ul); osi_WrStrLn(" all -values based on 48kHz input samplerate \ and stereo pilot tone", 71ul); osi_WrStrLn(" filters 4th order IIR, stereo preemphase+17kHz l\ owpass 64 tap FIR", 67ul); osi_WrStrLn("", 1ul); X2C_ABORT(); } err = 1; } } else err = 1; if (err) break; } if (err) { osi_Werr(">", 2ul); osi_Werr(h, 1024ul); osi_Werr("< use -h\012", 10ul); X2C_ABORT(); } } /* end Parms() */ static void OpenSound(uint32_t adcrate0, const char fn[], uint32_t fn_len) { int32_t i0; adc = osi_OpenRead(fn, fn_len); if (adc>=0L) { i0 = samplesize(adc, 16UL); /* 8, 16 */ i0 = channels(adc, 1UL+(uint32_t)(mod==sdrtx_mSTEREO)); /* 1, 2 */ i0 = sampelrate(adc, adcrate0); /* 8000..48000 */ } else Error("sound device open", 18ul); } /* end OpenSound() */ static void reopensound(void) { osic_Close(adc); OpenSound(48000UL, ifn, 1024ul); } /* end reopensound() */ static float audiosamp(void) { int32_t i0; if (pabuf>=abuflen) { i0 = osi_RdBin(adc, (char *)abuf, 2048u/1u, 2048UL); if (i0<=0L) { i0 = 0L; if (exitpipe) reopensound(); else exit0 = 1; } abuflen = (uint32_t)(i0/2L); pabuf = 0UL; } i0 = (int32_t)abuf[pabuf]; ++pabuf; return (float)i0; } /* end audiosamp() */ /* PROCEDURE audioout(o:REAL); VAR i:INTEGER; BEGIN IF pobuf>HIGH(about) THEN WrBin(adc, about, SIZE(about)); pobuf:=0; END; i:=VAL(INTEGER, o); IF i>32767 THEN i:=32767 ELSIF i<-32767 THEN i:=-32767 END; about[pobuf]:=i; INC(pobuf); END audioout; */ static void mkfir(float gain, float interp, uint32_t flen, float fir[], uint32_t fir_len) { uint32_t m; uint32_t f; uint32_t i0; float g; float w; float u; uint32_t tmp; uint32_t tmp0; m = flen/2UL; tmp = flen-1UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { fir[i0] = 0.0f; if (i0==tmp) break; } /* end for */ tmp = (uint32_t)X2C_TRUNCC(0.75f*(float)m,0UL,X2C_max_longcard)-1UL; f = 1UL; if (f<=tmp) for (;; f++) { g = X2C_DIVR((float)f,(float)m)+0.25f; /* preemphase */ w = X2C_DIVR((float)f*2.0f*3.1415926535f,(float)flen); tmp0 = flen-1UL; i0 = 0UL; if (i0<=tmp0) for (;; i0++) { fir[i0] = fir[i0]+g*osic_cos((((float)i0-(float)m)+interp)*w); if (i0==tmp0) break; } /* end for */ if (f==tmp) break; } /* end for */ u = X2C_DIVR(2.0f,(float)flen); /*WrStrLn(""); */ tmp = flen-1UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { /* hamming */ fir[i0] = gain*fir[i0]*(0.54f+0.46f*osic_cos(3.1415926535f*((float) i0*u-1.0f))); if (i0==tmp) break; } /* end for */ /*WrFixed(fir[i], 3,1);WrStr(" "); */ /*WrStrLn(""); */ } /* end mkfir() */ static float dofir(float u, float f[], uint32_t f_len, const float tab[], uint32_t tab_len, uint32_t flen) { uint32_t i0; float s; uint32_t tmp; s = f[0UL]*tab[0UL]; f[flen-1UL] = u; tmp = flen-2UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { f[i0] = f[i0+1UL]; s = s+f[i0]*tab[i0]; if (i0==tmp) break; } /* end for */ return s; } /* end dofir() */ static float dofiri(float f[], uint32_t f_len, const float tab[], uint32_t tab_len, uint32_t flen) { uint32_t i0; float s; uint32_t tmp; s = 0.0f; tmp = flen-2UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { s = s+f[i0]*tab[i0]; if (i0==tmp) break; } /* end for */ return s; } /* end dofiri() */ static float lp(float in, struct LPCONTEXT24 * c) /* lowpass 24db/oct 6dB loss */ { struct LPCONTEXT24 * anonym; { /* with */ struct LPCONTEXT24 * anonym = c; anonym->uc1 = (anonym->uc1+(in-anonym->uc1)*anonym->LPR)-anonym->il; anonym->uc2 = anonym->uc2*anonym->OLPR+anonym->il; anonym->il = anonym->il+(anonym->uc1-anonym->uc2)*anonym->LPL; return anonym->uc2; } } /* end lp() */ static float audioproc(float in) /* lowpass, limiter, clipper ... */ { float ll; float o; o = in*levmul; if (miclowpass!=0.0f) o = lp(o, &miclp); if (bassfilter!=0.0f) { ohd = ohd+(o-ohd)*bassfilter; /* remove bass */ o = o-ohd; } if (preemfilter!=0.0f) { ll = ohp; /* preemphase */ ohp = o; /* o:=o*preemfilter-ll; */ o = o-ll*preemfilter; } o = (float)((double)o*(1.0-limmul)); ll = (float)fabs(o)-limlev; if (ll>0.0f) { /* too loud */ limmul = limmul+(1.0-limmul)*(double)ll*0.00002; /* 0.00002 */ if (limmul>1.0) limmul = 1.0; } else limmul = limmul*9.99995E-1; if (subtonlev!=0.0f) { o = o+subtonlev*osic_sin(wtone); wtone = wtone+subtonhz; if (wtone>6.2831853071796f) wtone = wtone-6.2831853071796f; } if (o>2.925625E+4f) o = 2.925625E+4f; else if (o<(-2.925625E+4f)) o = (-2.925625E+4f); return o; } /* end audioproc() */ #define sdrtx_L 58512.5 static void ssbtx(float u, float * i0, float * q) { float v; u = u*8.0f; /* lp's have 6db loss, mixer 50% for each sideband */ *i0 = lp(u*osic_sin(wsub), &ssblpi); *q = lp(u*osic_cos(wsub), &ssblpq); v = *i0* *i0+ *q* *q; if (v>3.42371265625E+9f) { /* rf clipper */ v = X2C_DIVR(58512.5f,osic_sqrt(v)); *i0 = *i0*v; *q = *q*v; } *i0 = lp(*i0, &ssblpic); *q = lp(*q, &ssblpqc); wsub = wsub+ssbwinc; if (wsub>6.2831853071796f) wsub = wsub-6.2831853071796f; } /* end ssbtx() */ static float encstereo(float l, float r, struct STEREOCONTEXT * stereocontext) { float s; struct STEREOCONTEXT * anonym; { /* with */ struct STEREOCONTEXT * anonym = stereocontext; wpilotu += pilotu; s = 3.0517578125E-5f*(float)sintab[(uint32_t)X2C_LSH((uint32_t) wpilotu,32,-17)]; return (r-l)*s*s+l+s*3276.8f; } } /* end encstereo() */ static void makelp24(float fg, float samp, struct LPCONTEXT24 * c) { struct LPCONTEXT24 * anonym; { /* with */ struct LPCONTEXT24 * anonym = c; anonym->LPR = (X2C_DIVR(fg,samp))*2.33363f; anonym->LPL = anonym->LPR*anonym->LPR*2.888f*(1.0f-9.0f*osic_power(X2C_DIVR(fg, samp), 2.0f)); anonym->OLPR = 1.0f-anonym->LPR; } } /* end makelp24() */ static void makelp12(float fg, float samp, struct LPCONTEXT12 * c) { struct LPCONTEXT12 * anonym; { /* with */ struct LPCONTEXT12 * anonym = c; anonym->K1 = osic_power((X2C_DIVR(fg,samp))*5.2f, 2.0f)-osic_power((X2C_DIVR(fg,samp))*5.2f, 3.0f)*0.5f; if (anonym->K1<=0.0f) Error("modulation bandwith > samplerate", 33ul); anonym->K2 = 1.0f-osic_power(anonym->K1*1.0f, 0.48f); /* 0.85 10% ripple, 1.0 11% overshoot */ } } /* end makelp12() */ static void upsample(float u, struct LPCONTEXT12 * c) { struct LPCONTEXT12 * anonym; { /* with */ struct LPCONTEXT12 * anonym = c; anonym->uc = anonym->uc+anonym->il; anonym->il = anonym->il*anonym->K2+(u-anonym->uc)*anonym->K1; } } /* end upsample() */ static void SendSamps(short buf0[], uint32_t buf_len, uint32_t * p0) { uint32_t i0; uint8_t b[4096]; float f[4096]; uint32_t tmp; if (oform==2UL) osi_WrBin(of, (char *)buf0, (buf_len*2u)/1u, *p0*2UL); else if (oform==1UL) { tmp = *p0-1UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { b[i0] = (uint8_t)((buf0[i0]>>8)+128); if (i0==tmp) break; } /* end for */ osi_WrBin(of, (char *)b, 4096u/1u, *p0); } else { tmp = *p0-1UL; i0 = 0UL; if (i0<=tmp) for (;; i0++) { f[i0] = ((float)buf0[i0]+0.5f)*floatlev; if (i0==tmp) break; } /* end for */ osi_WrBin(of, (char *)f, sizeof(float [4096])/1u, *p0*sizeof(float)); } *p0 = 0UL; } /* end SendSamps() */ static void sat(int32_t * u) { if (*u>32767L) *u = 32767L; else if (*u<-32767L) *u = -32767L; } /* end sat() */ static void exitprog(int32_t); static void exitprog(int32_t signum) { osi_WrStr("got signum ", 12ul); osic_WrINT32((uint32_t)signum, 0UL); osi_WrStrLn("!", 2ul); if (exitpipe) reopensound(); else exit0 = 1; } /* end exitprog() */ X2C_STACK_LIMIT(100000l) extern int main(int argc, char **argv) { uint32_t tmp; X2C_BEGIN(&argc,argv,1,4000000l,8000000l); aprsstr_BEGIN(); osi_BEGIN(); /* signal(SIGTERM, exitprog); signal(SIGINT, exitprog); */ of = -1L; adcrate = 48000UL; sampmul = 2.1333333333333E+1f; mod = sdrtx_mFM; strncpy(ifn,"/dev/dsp",1024u); ofn[0] = 0; wshift = 0UL; offset = 0.0f; devi = 0.0f; levmul = 50.0f; miclowpass = 3000.0f; bassfilter = 0.05f; preemfilter = 0.8f; clipplev = 1.0f; upsamplef = 0.0f; limlim = 0.0f; oform = 1UL; outlev = 1.0f; subtonlev = 0.0f; subtonhz = 0.0f; wtone = 0.0f; exitpipe = 0; Parms(); if (exitpipe) signal(SIGPIPE, exitprog); subtonhz = subtonhz*1.3089969389957E-4f; subtonlev = subtonlev*2.925625E+4f; floatlev = X2C_DIVR(outlev,32768.0f); /* ALLOCATE(buf, SIZE(buf^)); */ /* IF buf=NIL THEN Werr("out of memory") END; */ if (devi==0.0f) { if (mod==sdrtx_mSTEREO) devi = 40000.0f; else devi = 3000.0f; } if (upsamplef==0.0f) { if (mod==sdrtx_mSTEREO) upsamplef = 1.1E+5f; else if (mod==sdrtx_mUSB || mod==sdrtx_mLSB) upsamplef = 1600.0f; else if (mod==sdrtx_mAM) upsamplef = 4500.0f; else upsamplef = devi+miclowpass; } sample = (float)adcrate*sampmul; if (ofn[0U]==0) osi_Werr("output file?", 13ul); of = osi_OpenWrite(ofn, 1024ul); if (of<0L) osi_Werr("file write", 11ul); OpenSound(48000UL, ifn, 1024ul); makelp12(upsamplef, sample, &upsamplelpi); upsamplelpq = upsamplelpi; if (miclowpass!=0.0f) makelp24(miclowpass, (float)adcrate, &miclp); makelp24(1200.0f, (float)adcrate, &ssblpi); ssblpq = ssblpi; makelp24(1200.0f, (float)adcrate, &ssblpic); ssblpqc = ssblpi; if (mod==sdrtx_mSTEREO) { for (i = 0L; i<=63L; i++) { mkfir(0.1f, X2C_DIVR((float)i+0.5f,64.0f), 64UL, radiofirtab[63L-i], 64ul); } /* end for */ } sinlev = 32766.0f; if (outlev<=1.0f && oform!=4UL) sinlev = sinlev*outlev; for (i = 0L; i<=32767L; i++) { sintab[i] = (short)X2C_TRUNCI(sinlev*osic_sin((float) i*1.9174759848571E-4f),-32768,32767); } /* end for */ ssbwinc = X2C_DIVR(9.4247779607694E+3f,(float)adcrate); fmdeviation = X2C_DIVR(X2C_DIVR(devi*4.294967295E+9f,sample), 2.925625E+4f); pilot = X2C_DIVR(1.1938052083641E+5f,sample); pilotu = (uint32_t)X2C_TRUNCC(X2C_DIVL(8.1604378624E+13, (double)sample),0UL,X2C_max_longcard); limlev = 2.6330625E+4f-subtonlev; if (limlev<=0.0f) osi_Werr("subtone level too high\012", 24ul); shift = (int32_t)X2C_TRUNCI(-(X2C_DIVR(offset*4.294967295E+9f,sample)), X2C_min_longint,X2C_max_longint); pabuf = 2147483647UL; p = 0UL; sampcnt = 0.0f; firsteps = (uint32_t)X2C_TRUNCC(sampmul,0UL,X2C_max_longcard)/2UL; /* make fir interpolation steps */ /*WrStrLn(""); */ do { sampcnt = sampcnt+sampmul; loops = (uint32_t)X2C_TRUNCC(sampcnt,0UL,X2C_max_longcard); if (mod>1; if (si<0L) si = 0L; else if (si>32767L) si = 32767L; buf[p] = (short)(si*(int32_t)sintab[(uint32_t) X2C_LSH((uint32_t)wshift,32,-17)]>>15); ++p; buf[p] = (short)(si*(int32_t)sintab[(uint32_t) X2C_LSH((uint32_t)(wshift+1073741824UL),32,-17)]>>15); ++p; wshift += (uint32_t)shift; } else if (mod==sdrtx_mSTEREO) { /* IF is+is=TRUNC(sampmul) THEN (* double audio samplerate *) */ /* bbi:=dofiri(radiofirl, radiofirtab[INTPOLS DIV 2], RADIOFIRLEN); */ /* bbq:=dofiri(radiofirr, radiofirtab[INTPOLS DIV 2], RADIOFIRLEN); */ /* END; */ if (fs>=firsteps) { fh = (is*64UL)/loops; bbi = dofiri(radiofirl, 64ul, radiofirtab[fh], 64ul, 64UL); bbq = dofiri(radiofirr, 64ul, radiofirtab[fh], 64ul, 64UL); fs = 0UL; } ++fs; upsample(bbi, &upsamplelpi); upsample(bbq, &upsamplelpq); buf[p] = sintab[(uint32_t)X2C_LSH((uint32_t)wshift,32,-17)]; ++p; buf[p] = sintab[(uint32_t)X2C_LSH((uint32_t) (wshift+1073741824UL),32,-17)]; ++p; wshift += (uint32_t)(shift+(int32_t) X2C_TRUNCI(fmdeviation*encstereo(upsamplelpi.uc, upsamplelpq.uc, &cstereo),X2C_min_longint,X2C_max_longint)); } else { /* iq baseband upsample */ upsample(bbi, &upsamplelpi); upsample(bbq, &upsamplelpq); si = (int32_t)sintab[(uint32_t)X2C_LSH((uint32_t)wshift,32, -17)]; sq = (int32_t)sintab[(uint32_t)X2C_LSH((uint32_t) (wshift+1073741824UL),32,-17)]; bi = (int32_t)X2C_TRUNCI(upsamplelpi.uc,X2C_min_longint, X2C_max_longint); bq = (int32_t)X2C_TRUNCI(upsamplelpq.uc,X2C_min_longint, X2C_max_longint); tmpi = bi*si-bq*sq>>15; /*IF ABS(tmpi)>vu THEN vu:=ABS(tmpi) END; */ if (labs(tmpi)>32767L) sat(&tmpi); buf[p] = (short)tmpi; ++p; tmpi = bi*sq+bq*si>>15; /*IF ABS(tmpi)>vu THEN vu:=ABS(tmpi) END; */ if (labs(tmpi)>32767L) sat(&tmpi); buf[p] = (short)tmpi; ++p; wshift += (uint32_t)shift; } if (p>4095UL) SendSamps(buf, 4096ul, &p); if (is==tmp) break; } /* end for */ sampcnt = sampcnt-(float)loops; } while (!exit0); if (p>0UL) SendSamps(buf, 4096ul, &p); osic_Close(of); /*WrInt(vu, 1); WrStrLn("vu"); */ X2C_EXIT(); return 0; } X2C_MAIN_DEFINITION