void aw_calibtools(AWINDOWP parent){ //-- Set Mask CANVAS * tmpc = aw_muteparent(parent); on_dialog_window = 1; ag_rectopa(agc(),0,0,agw(),agh(),0x0000,220); ag_sync(); byte isvalid = 0; //-- Initializing Canvas CANVAS ccv; ag_canvas(&ccv,agw(),agh()); ag_blur(&ccv,agc(),agdp()*2); int xpos[5] = { agdp()*10, agw()-(agdp()*10), agdp()*10, agw()-(agdp()*10), agw()/2 }; int ypos[5] = { agdp()*10, agdp()*10, agh() - (agdp()*10), agh()-(agdp()*10), agh()/2 }; int xtch[5] = { 0,0,0,0,0 }; int ytch[5] = { 0,0,0,0,0 }; atouch_plaincalibrate(); char datx[256]; if (!aw_calibdraw(&ccv,0,xpos,ypos,xtch,ytch)) goto doneit; if (!aw_calibdraw(&ccv,1,xpos,ypos,xtch,ytch)) goto doneit; if (!aw_calibdraw(&ccv,2,xpos,ypos,xtch,ytch)) goto doneit; if (!aw_calibdraw(&ccv,3,xpos,ypos,xtch,ytch)) goto doneit; if (!aw_calibdraw(&ccv,4,xpos,ypos,xtch,ytch)) goto doneit; float padsz = agdp()*5; float leftx = ((xtch[0]+xtch[2])/2); float rightx = ((xtch[1]+xtch[3])/2); float topy = ((ytch[0]+ytch[1])/2); float bottomy = ((ytch[2]+ytch[3])/2); float centerx = xtch[4]; float centery = ytch[4]; float halfx = (agw()/2)-padsz; float halfy = (agh()/2)-padsz; float fullx = agw()-padsz; float fully = agh()-padsz; byte data_is_valid = 0; float cal_x = 0; float cal_y = 0; int add_x = 0; int add_y = 0; if ((halfx>0)&&(fullx>0)&&(halfy>0)&&(fully>0)){ cal_x = ((((centerx-leftx)/halfx) + ((rightx-leftx)/fullx))/2); cal_y = ((((centery-topy)/halfy) + ((bottomy-topy)/fully))/2); if ((cal_x>0)&&(cal_y>0)){ add_x = round((leftx / cal_x) - padsz); add_y = round((topy / cal_y) - padsz); data_is_valid = 1; } } if (data_is_valid){ atouch_set_calibrate(cal_x,add_x,cal_y,add_y); snprintf(datx,255, "Use/Replace this command in top of <#009>aroma-config</#>:\n\n" "<#060>calibrate(\"%01.4f\",\"%i\",\"%01.4f\",\"%i\");</#>\n\n", cal_x,add_x,cal_y,add_y); aw_calibdraw(&ccv,-1,xpos,ypos,xtch,ytch); isvalid = 1; } else{ aw_alert(parent, "Calibrated Data", "Calibrated Data not Valid, Please Try Again...", "icons/info", NULL); } doneit: ag_ccanvas(&ccv); on_dialog_window = 0; aw_unmuteparent(parent,tmpc); byte dont_restore_caldata = 0; if (isvalid){ aw_alert(parent, "Calibrated Data", datx, "icons/info", NULL); dont_restore_caldata = aw_confirm( parent, "Set Calibrated Data", "Do You Want to Use Current Calibrated Data in Current Process?\n\n<#080>NOTE:</#> It Will revert back when you restart the AROMA Installer...", "icons/alert", NULL, NULL ); } if (!dont_restore_caldata){ atouch_restorecalibrate(); } }
byte aw_calibdraw(CANVAS * c, int id,int * xpos,int * ypos,int * xtch,int * ytch){ ag_draw(agc(),c,0,0); usleep(500000); int sz = agdp()*10; if (id!=-1){ int x = xpos[id]; int y = ypos[id]; int rx = x-(sz/2); int ry = y-(sz/2); ag_roundgrad( agc(),rx,ry,sz,sz, 0xffff, ag_rgb(200,200,200), sz/2); } if (id!=-1){ char txt[128]; snprintf(txt,127,"Step %i: Tap The Circle To Calibrate",id+1); char * txt2 = "Press Back Key or Other Keys To Cancel"; int tw = ag_txtwidth(txt,0); int tw2 = ag_txtwidth(txt2,0); int tx = (agw()/2) - (tw/2); int tx2= (agw()/2) - (tw2/2); int ty = (agh()/2) + (sz*2); int ty2= (ty +ag_fontheight(0)+agdp()); ag_text(agc(),tw,tx+1,ty+1,txt,0x0000,0); ag_text(agc(),tw,tx,ty,txt,0xffff,0); ag_text(agc(),tw2,tx2+1,ty2+1,txt2,0x0000,0); ag_text(agc(),tw2,tx2,ty2,txt2,0xffff,0); } else{ char * txt = "Tap The Screen to Test Calibrated Data"; char * txt2 = "Press Back or Other Keys To Continue"; int tw = ag_txtwidth(txt,0); int tw2 = ag_txtwidth(txt2,0); int tx = (agw()/2) - (tw/2); int tx2= (agw()/2) - (tw2/2); int ty = (agh()/2) + (sz*2); int ty2= (ty +ag_fontheight(0)+agdp()); ag_text(agc(),tw,tx+1,ty+1,txt,0x0000,0); ag_text(agc(),tw,tx,ty,txt,0xffff,0); ag_text(agc(),tw2,tx2+1,ty2+1,txt2,0x0000,0); ag_text(agc(),tw2,tx2,ty2,txt2,0xffff,0); } CANVAS bg; ag_canvas(&bg,agw(),agh()); ag_draw(&bg,agc(),0,0); ag_sync(); byte res=1; byte ond=1; byte onp=0; ui_clear_key_queue(); while (ond){ ATEV atev; ui_clear_key_queue(); int action=atouch_wait_ex(&atev,1); switch (action){ case ATEV_MOUSEDN:{ onp=1; if (id==-1){ ag_draw(agc(),&bg,0,0); int vz = agdp()*40; int vx = atev.x-(vz/2); int vy = atev.y-(vz/2); ag_roundgrad(agc(),vx,vy,vz,vz,0xffff,ag_rgb(180,180,180),(vz/2)); ag_sync(); } } break; case ATEV_MOUSEMV:{ if (onp){ if (id!=-1){ xtch[id]=atev.x; ytch[id]=atev.y; } else{ ag_draw(agc(),&bg,0,0); int vz = agdp()*40; int vx = atev.x-(vz/2); int vy = atev.y-(vz/2); ag_roundgrad(agc(),vx,vy,vz,vz,0xffff,ag_rgb(180,180,180),(vz/2)); ag_sync(); } } } break; case ATEV_MOUSEUP:{ if (id!=-1){ if (onp){ if ((xtch[id]>0)&&(ytch[id]>0)){ ond=0; } onp=0; } } } break; case ATEV_SELECT: case ATEV_BACK: case ATEV_MENU:{ if (atev.d==0){ ond=0; res=0; } } break; } } ag_ccanvas(&bg); return res; }
byte aw_confirm(AWINDOWP parent, char * titlev,char * textv,char * img,char * yes_text,char * no_text){ CANVAS * tmpc = aw_muteparent(parent); //-- Set Mask on_dialog_window = 1; ag_rectopa(agc(),0,0,agw(),agh(),0x0000,180); ag_sync(); char title[32]; char text[513]; snprintf(title,31,"%s",titlev); snprintf(text,512,"%s",textv); int pad = agdp()*4; int winW = agw()-(pad*2); int txtW = winW-(pad*2); int txtX = pad*2; int btnH = agdp()*20; int titW = ag_txtwidth(title,1); int titH = ag_fontheight(1) + (pad*2); //-- Load Icon PNGCANVAS ap; byte imgE = 0; int imgW = 0; int imgH = 0; if (apng_load(&ap,img)){ imgE = 1; imgW = min(ap.w,agdp()*30); imgH = min(ap.h,agdp()*30); int imgA = pad + imgW; txtX += imgA; txtW -= imgA; } int txtH = ag_txtheight(txtW,text,0); int infH = ((imgE)&&(txtH<imgH))?imgH:txtH; //-- Calculate Window Size & Position int winH = titH + infH + btnH + (pad*3); int winX = pad; int winY = (agh()/2) - (winH/2); //-- Calculate Title Size & Position int titX = (agw()/2) - (titW/2); int titY = winY + pad; //-- Calculate Text Size & Position int infY = winY + titH + pad; int txtY = infY + ((infH - txtH) / 2); int imgY = infY; //-- Calculate Button Size & Position int btnW = (txtW / 2) - (pad/2); int btnY = infY+infH+pad; int btnX = txtX; int btnX2 = txtX+(txtW/2)+(pad/2); //-- Initializing Canvas CANVAS alertbg; ag_canvas(&alertbg,agw(),agh()); ag_draw(&alertbg,agc(),0,0); //-- Draw Window ag_roundgrad(&alertbg,winX-1,winY-1,winW+2,winH+2,acfg_var.border,acfg_var.border_g,(acfg_var.roundsz*agdp())+1); ag_roundgrad(&alertbg,winX,winY,winW,winH,acfg_var.winbg,acfg_var.winbg_g,acfg_var.roundsz*agdp()); //-- Draw Title ag_roundgrad_ex(&alertbg,winX,winY,winW,titH,acfg_var.titlebg,acfg_var.titlebg_g,acfg_var.roundsz*agdp(),1,1,0,0); ag_textf(&alertbg,titW,titX+1,titY+1,title,acfg_var.titlebg_g,1); ag_text(&alertbg,titW,titX,titY,title,acfg_var.titlefg,1); //-- Draw Image if (imgE){ apng_draw_ex(&alertbg,&ap,pad*2,imgY,0,0,imgW,imgH); apng_close(&ap); } //-- Draw Text ag_textf(&alertbg,txtW,txtX+1,txtY+1,text,acfg_var.textbg,0); ag_text(&alertbg,txtW,txtX,txtY,text,acfg_var.textfg,0); AWINDOWP hWin = aw(&alertbg); acbutton(hWin,btnX,btnY,btnW,btnH,(yes_text==NULL?"Yes":yes_text),0,6); acbutton(hWin,btnX2,btnY,btnW,btnH,(no_text==NULL?"No":no_text),0,5); aw_show(hWin); byte ondispatch = 1; byte res = 0; while(ondispatch){ dword msg=aw_dispatch(hWin); switch (aw_gm(msg)){ case 6: res=1; ondispatch = 0; break; case 5: ondispatch = 0; break; } } aw_destroy(hWin); ag_ccanvas(&alertbg); on_dialog_window = 0; aw_unmuteparent(parent,tmpc); return res; }
/* ************************************************************************** * Function: Post_Filter * Purpose: postfiltering of synthesis speech. * Description: * The postfiltering process is described as follows: * * - inverse filtering of syn[] through A(z/0.7) to get res2[] * - tilt compensation filtering; 1 - MU*k*z^-1 * - synthesis filtering through 1/A(z/0.75) * - adaptive gain control * ************************************************************************** */ int Post_Filter ( Post_FilterState *st, /* i/o : post filter states */ enum Mode mode, /* i : AMR mode */ Word16 *syn, /* i/o : synthesis speech (postfiltered is output) */ Word16 *Az_4 /* i : interpolated LPC parameters in all subfr. */ ) { /*-------------------------------------------------------------------* * Declaration of parameters * *-------------------------------------------------------------------*/ Word16 Ap3[MP1], Ap4[MP1]; /* bandwidth expanded LP parameters */ Word16 *Az; /* pointer to Az_4: */ /* LPC parameters in each subframe */ Word16 i_subfr; /* index for beginning of subframe */ Word16 h[L_H]; Word16 i; Word16 temp1, temp2; Word32 L_tmp; Word16 *syn_work = &st->synth_buf[M]; /*-----------------------------------------------------* * Post filtering * *-----------------------------------------------------*/ Copy (syn, syn_work , L_FRAME); Az = Az_4; for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { /* Find weighted filter coefficients Ap3[] and ap[4] */ if ((mode == MR122) || (mode == MR102)) { Weight_Ai (Az, gamma3_MR122, Ap3); Weight_Ai (Az, gamma4_MR122, Ap4); } else { Weight_Ai (Az, gamma3, Ap3); Weight_Ai (Az, gamma4, Ap4); } /* filtering of synthesis speech by A(z/0.7) to find res2[] */ Residu (Ap3, &syn_work[i_subfr], st->res2, L_SUBFR); /* tilt compensation filter */ /* impulse response of A(z/0.7)/A(z/0.75) */ Copy (Ap3, h, M + 1); Set_zero (&h[M + 1], L_H - M - 1); Syn_filt (Ap4, h, h, L_H, &h[M + 1], 0); /* 1st correlation of h[] */ L_tmp = L_mult (h[0], h[0]); for (i = 1; i < L_H; i++) { L_tmp = L_mac (L_tmp, h[i], h[i]); } temp1 = extract_h (L_tmp); L_tmp = L_mult (h[0], h[1]); for (i = 1; i < L_H - 1; i++) { L_tmp = L_mac (L_tmp, h[i], h[i + 1]); } temp2 = extract_h (L_tmp); if (temp2 <= 0) { temp2 = 0; } else { temp2 = mult (temp2, MU); temp2 = div_s (temp2, temp1); } preemphasis (st->preemph_state, st->res2, temp2, L_SUBFR); /* filtering through 1/A(z/0.75) */ Syn_filt (Ap4, st->res2, &syn[i_subfr], L_SUBFR, st->mem_syn_pst, 1); /* scale output to input */ agc (st->agc_state, &syn_work[i_subfr], &syn[i_subfr], AGC_FAC, L_SUBFR); Az += MP1; } /* update syn_work[] buffer */ Copy (&syn_work[L_FRAME - M], &syn_work[-M], M); return 0; }
void IQSSBDemodulator::process_block(Ipp32f* iq_block, Ipp32f* out_block) { static bool flip=false; // Deinterleave to real and imaginary (I and Q) buffers ippsDeinterleave_32f(iq_block, 2, BLKSIZE, _iq); ippsZero_32f(_in_re+BLKSIZE, NFFT-BLKSIZE); ippsZero_32f(_in_im+BLKSIZE, NFFT-BLKSIZE); // _in_re now contains the real/I part and // _in_im now contains the imaginary/Q part ippsFFTFwd_CToC_32f_I(_in_re, _in_im, _fft_specs, _fft_buf); ippsCartToPolar_32f(_in_re, _in_im, _in_m, _in_p, NFFT); // layout of frequency bins is // NFFT/2 to NFFT-1 and then continues from 0 to NFFT/2-1 // shift desired part to 0Hz int lo = _lo*NFFT; circshift(_in_m, NFFT, lo); circshift(_in_p, NFFT, lo); // zero out undesired sideband if(_sideband == USB) { // zero out LSB, that is NFFT/2 to NFFT-1 ippsZero_32f(_in_m+NFFT/2, NFFT/2); ippsZero_32f(_in_p+NFFT/2, NFFT/2); } else // _sideband must be LSB { // zero out USB, that is 0 to NFFT/2-1 ippsZero_32f(_in_m, NFFT/2); ippsZero_32f(_in_p, NFFT/2); } // filter the passband ippsMul_32f_I(_fir_taps_m, _in_m, NFFT); ippsAdd_32f_I(_fir_taps_p, _in_p, NFFT); // return to time domain ippsPolarToCart_32f(_in_m, _in_p, _in_re, _in_im, NFFT); ippsFFTInv_CToC_32f_I(_in_re, _in_im, _fft_specs, _fft_buf); // do overlap/add // // 1) add the residual from last round ippsAdd_32f_I(_residual_re, _in_re, _residual_length); ippsAdd_32f_I(_residual_im, _in_im, _residual_length); // 2) Store the new residual if(flip) { ippsMulC_32f_I(-1.0, _in_re, NFFT); ippsMulC_32f_I(-1.0, _in_im, NFFT); flip=!flip; } ippsCopy_32f(_in_re+BLKSIZE, _residual_re, _residual_length); ippsCopy_32f(_in_im+BLKSIZE, _residual_im, _residual_length); // agc agc(_in_re, BLKSIZE); // deliver the result ippsCopy_32f(_in_re, out_block, BLKSIZE); }
void auido_show_del(byte * copy_status, char **source_path, int number_files) { //-- Init Dialog Window CANVAS *tmpc = aw_muteparent(NULL); aw_set_on_dialog(2); //ag_rectopa(agc(), 0, 0, agw(), agh(), 0x0000, 180); CANVAS * maskc = aw_maskparent(); ag_sync(); //-- Initializing Canvas CANVAS bg; ag_canvas(&bg, agw(), agh()); ag_draw(&bg, agc(), 0, 0); //-- Size & Position /* [PAD] mainInfo extraInfo [*************perProg*************] perInfo [PAD] [ CANCEL BUTTON ] [PAD] */ int pad = agdp() * 4; int padB = pad; int padT = pad; int padL = pad; int padR = pad; PNGCANVASP winp = atheme("img.dialog"); APNG9 winv; if (winp != NULL) { if (apng9_calc(winp, &winv, 1)) { padL = winv.l; padR = winv.r; padB = winv.b; padT = winv.t; } } int hpad = agdp() * 2; int winW = agw() - (pad * 2); //-- Window int winX = pad; int cliW = winW - (padL + padR); //-- Window Client int cliX = pad + padL; int titH = ag_fontheight(1) + (agdp() * 2); //-- Title Height int txtH = ag_fontheight(0) + agdp(); //-- Text Interface Height int prgH = agdp() * 12; //-- Progress Height int btnH = agdp() * 24; int btnW = winW / 2; int btnX = agw() / 2 - btnW / 2; int winH = (pad * 2) + titH + (txtH * 2) + (prgH) + btnH + padB + padT; int winY = (agh() / 2) - (winH / 2); int titY = winY + padT; int curY = titY + titH + pad; int defW = cliW - pad; int txtW1 = (int)(defW * 0.8); int txtW2 = defW - txtW1; int txtX1 = cliX + hpad; int txtX2 = txtX1 + txtW1; //-- Draw Canvas if (!atheme_draw("img.dialog", &bg, winX, winY, winW, winH)) { ag_roundgrad(&bg, winX - 1, winY - 1, winW + 2, winH + 2, acfg()->border, acfg()->border_g, (acfg()->roundsz * agdp()) + 1); ag_roundgrad(&bg, winX, winY, winW, winH, acfg()->dialogbg, acfg()->dialogbg_g, acfg()->roundsz * agdp()); } //-- Init Window & Controls AWINDOWP hWin = aw(&bg); ACONTROLP mainInfo = aclabel(hWin, cliX, titY, cliW, titH, alang_get("delete.prepare"), 1, 1, 2, acfg()->winfg); ACONTROLP extraInfo = aclabel(hWin, cliX, curY, cliW, txtH, alang_get("calculating"), 0, 1, 2, acfg()->winfg); curY += txtH; ACONTROLP perProg = acprog(hWin, cliX, curY + agdp(), cliW, prgH - (agdp() * 2), 0); curY += prgH; ACONTROLP perInfo = aclabel(hWin, cliX, curY, cliW, txtH, "", 0, 1, 2, acfg()->textfg_gray); curY += txtH + pad; imgbtn(hWin, btnX, curY, btnW, btnH, aui_icons(0), alang_get("cancel"), 3, 55); //-- Show Window //aw_show(hWin); aw_show_ex2(hWin, 5, winX - 1, winY - 1, winW + 2, winH + 2, NULL); byte ondispatch = 1; acprog_setonwait(perProg, 1); //-- Start Delete Proc AFSDT dt; memset(&dt, 0, sizeof(AFSDT)); int curr_id = 0; byte proc_state = 0; long kbps_tick = 0; if (auido_next_del_size (&dt, &curr_id, copy_status, source_path, number_files)) { //-- Dispatch do { dword msg = aw_dispatch(hWin); switch (aw_gm(msg)) { //-- CALCULATING case 10: { //-- Discovery Tick if (proc_state == 0) { char info[256]; char strfl[64]; char format[256]; snprintf(strfl, 64, "%i", dt.n); snprintf(format, 256, "%s ( %s )", alang_get("deleting"), "\%0.1f"); snprintf(info, 256, format, strfl, ((float)dt.k) / 1024); aclabel_settext(perInfo, dt.curr, 0); aclabel_settext(extraInfo, info, 1); } } break; case 11: { //-- Discovery Finish if (proc_state == 0) { curr_id++; if (!auido_next_del_size (&dt, &curr_id, copy_status, source_path, number_files)) { ondispatch = 0; aclabel_settext (mainInfo, alang_get ("finishing"), 1); } } else if (proc_state == 2) { ondispatch = 0; aclabel_settext(mainInfo, alang_get ("finishing"), 1); } } break; case 55: { if (proc_state == 0) { aclabel_settext(mainInfo, alang_get ("canceling"), 1); proc_state = 2; dt.status = 0; } } break; } } while (ondispatch); } //-- Release Resources aw_destroy(hWin); ag_ccanvas(&bg); aw_set_on_dialog(0); //aw_unmuteparent(NULL, tmpc); aw_unmaskparent(NULL, tmpc, maskc, winX - 1, winY - 1, winW + 2, winH + 2); }