/* * scene.c * Description: * * Created on: 2014-10-28 * Author: Graydon * Modify: */ #include #include #include #include #include #include "drv/global.h" #include "drv/hmem.h" #include "scene.h" #include "create.h" #include "ctrl.h" #include "execute.h" #include "protocol.h" #include "drv/fft.h" //#define PROC_NUM 152 void* usbExpander =0; extern int input_num_channels ; extern int output_num_channels; extern int dual_dsp ; extern int dsp_index; #define MAX_MODULE_NUM 300 static short g_procID_table[MAX_MODULE_NUM]; int str_delim(const char* str, unsigned int number[]); static struct tag_proc{ eproc_type proc_type; void* proc_handle; }g_proc[MAX_MODULE_NUM]; static int proc_count =0; //void *Expander[MAX_MIXER_INPUT]; #pragma section("scene_mem") static tag_parameters parameters; #pragma section("scene_mem") static struct proc_field{ int proc_id; eproc_type proc_type; char inportstr[MAX_DELIM_LEN/4]; char outportstr[MAX_DELIM_LEN/4]; int dsp_index; int fixed; void * const parameters; } proc_list[]={ {299,PROC_INPUT,"0-31","0-31",0, 1 ,¶meters.input} ,{298,PROC_METER,"0-31","",0,1 ,0} //0 ,{1,PROC_EXPANDER,"0|","0|",0, 0, ¶meters.in1[0]},{2,PROC_EXPANDER,"1|","1|",0, 0, ¶meters.in1[1]} ,{3,PROC_EXPANDER,"2|","2|",0, 0, ¶meters.in1[2]},{4,PROC_EXPANDER,"3|","3|",0, 0, ¶meters.in1[3]} ,{5,PROC_EXPANDER,"4|","4|",0, 0, ¶meters.in1[4]},{6,PROC_EXPANDER,"5|","5|",0, 0, ¶meters.in1[5]} ,{7,PROC_EXPANDER,"6|","6|",0, 0, ¶meters.in1[6]},{8,PROC_EXPANDER,"7|","7|",0, 0, ¶meters.in1[7]} ,{9,PROC_EXPANDER,"8|","8|",0, 0, ¶meters.in1[8]},{10,PROC_EXPANDER,"9|","9|",0, 0, ¶meters.in1[9]} ,{11,PROC_EXPANDER,"10|","10|",0, 0, ¶meters.in1[10]},{12,PROC_EXPANDER,"11|","11|",0, 0, ¶meters.in1[11]} ,{13,PROC_EXPANDER,"12|","12|",0, 0, ¶meters.in1[12]},{14,PROC_EXPANDER,"13|","13|",0, 0, ¶meters.in1[13]} ,{15,PROC_EXPANDER,"14|","14|",0, 0, ¶meters.in1[14]},{16,PROC_EXPANDER,"15|","15|",0, 0, ¶meters.in1[15]} ,{33,PROC_COMPRESS,"0|","0|",0, 0, ¶meters.in2[0]},{34,PROC_COMPRESS,"1|","1|",0, 0, ¶meters.in2[1]} ,{35,PROC_COMPRESS,"2|","2|",0, 0, ¶meters.in2[2]},{36,PROC_COMPRESS,"3|","3|",0, 0, ¶meters.in2[3]} ,{37,PROC_COMPRESS,"4|","4|",0, 0, ¶meters.in2[4]},{38,PROC_COMPRESS,"5|","5|",0, 0, ¶meters.in2[5]} ,{39,PROC_COMPRESS,"6|","6|",0, 0, ¶meters.in2[6]},{40,PROC_COMPRESS,"7|","7|",0, 0, ¶meters.in2[7]} ,{41,PROC_COMPRESS,"8|","8|",0, 0, ¶meters.in2[8]},{42,PROC_COMPRESS,"9|","9|",0, 0, ¶meters.in2[9]} ,{43,PROC_COMPRESS,"10|","10|",0, 0, ¶meters.in2[10]},{44,PROC_COMPRESS,"11|","11|",0, 0, ¶meters.in2[11]} ,{45,PROC_COMPRESS,"12|","12|",0, 0, ¶meters.in2[12]},{46,PROC_COMPRESS,"13|","13|",0, 0, ¶meters.in2[13]} ,{47,PROC_COMPRESS,"14|","14|",0, 0, ¶meters.in2[14]},{48,PROC_COMPRESS,"15|","15|",0, 0, ¶meters.in2[15]} ,{65,PROC_AGC,"0|","0|",0, 0, ¶meters.in3[0]} ,{66,PROC_AGC,"1|","1|",0, 0, ¶meters.in3[1]} ,{67,PROC_AGC,"2|","2|",0, 0, ¶meters.in3[2]},{68,PROC_AGC,"3|","3|",0, 0, ¶meters.in3[3]} ,{69,PROC_AGC,"4|","4|",0, 0, ¶meters.in3[4]},{70,PROC_AGC,"5|","5|",0, 0, ¶meters.in3[5]} ,{71,PROC_AGC,"6|","6|",0, 0, ¶meters.in3[6]},{72,PROC_AGC,"7|","7|",0, 0, ¶meters.in3[7]} ,{73,PROC_AGC,"8|","8|",0, 0, ¶meters.in3[8]},{74,PROC_AGC,"9|","9|",0, 0, ¶meters.in3[9]} ,{75,PROC_AGC,"10|","10|",0, 0, ¶meters.in3[10]},{76,PROC_AGC,"11|","11|",0, 0, ¶meters.in3[11]} ,{77,PROC_AGC,"12|","12|",0, 0, ¶meters.in3[12]},{78,PROC_AGC,"13|","13|",0, 0, ¶meters.in3[13]} ,{79,PROC_AGC,"14|","14|",0, 0, ¶meters.in3[14]},{80,PROC_AGC,"15|","15|",0, 0, ¶meters.in3[15]} ,{97,PROC_EQ,"0|","0|",0, 0, ¶meters.in4[0]},{98,PROC_EQ,"1|","1|",0, 0, ¶meters.in4[1]} ,{99,PROC_EQ,"2|","2|",0, 0, ¶meters.in4[2]},{100,PROC_EQ,"3|","3|",0, 0, ¶meters.in4[3]} ,{101,PROC_EQ,"4|","4|",0, 0, ¶meters.in4[4]},{102,PROC_EQ,"5|","5|",0, 0, ¶meters.in4[5]} ,{103,PROC_EQ,"6|","6|",0, 0, ¶meters.in4[6]},{104,PROC_EQ,"7|","7|",0, 0, ¶meters.in4[7]} ,{105,PROC_EQ,"8|","8|",0, 0, ¶meters.in4[8]},{106,PROC_EQ,"9|","9|",0, 0, ¶meters.in4[9]} ,{107,PROC_EQ,"10|","10|",0, 0, ¶meters.in4[10]},{108,PROC_EQ,"11|","11|",0, 0, ¶meters.in4[11]} ,{109,PROC_EQ,"12|","12|",0, 0, ¶meters.in4[12]},{110,PROC_EQ,"13|","13|",0, 0, ¶meters.in4[13]} ,{111,PROC_EQ,"14|","14|",0, 0, ¶meters.in4[14]},{112,PROC_EQ,"15|","15|",0, 0, ¶meters.in4[15]} ,{129,PROC_NHS,"0|","0|",0, 0, ¶meters.in5[0]},{130,PROC_NHS,"1|","1|",0, 0, ¶meters.in5[1]} ,{131,PROC_NHS,"2|","2|",0, 0, ¶meters.in5[2]},{132,PROC_NHS,"3|","3|",0, 0, ¶meters.in5[3]} ,{133,PROC_NHS,"4|","4|",0, 0, ¶meters.in5[4]},{134,PROC_NHS,"5|","5|",0, 0, ¶meters.in5[5]} ,{135,PROC_NHS,"6|","6|",0, 0, ¶meters.in5[6]},{136,PROC_NHS,"7|","7|",0, 0, ¶meters.in5[7]} ,{137,PROC_NHS,"8|","8|",0, 0, ¶meters.in5[8]},{138,PROC_NHS,"9|","9|",0, 0, ¶meters.in5[9]} ,{139,PROC_NHS,"10|","10|",0, 0, ¶meters.in5[10]},{140,PROC_NHS,"11|","11|",0, 0, ¶meters.in5[11]} ,{141,PROC_NHS,"12|","12|",0, 0, ¶meters.in5[12]},{142,PROC_NHS,"13|","13|",0, 0, ¶meters.in5[13]} ,{143,PROC_NHS,"14|","14|",0, 0, ¶meters.in5[14]},{144,PROC_NHS,"15|","15|",0, 0, ¶meters.in5[15]} ,{161,PROC_AUTOMIXER,"0-31","0-32",0, 1, ¶meters.automixer} //¿ÉÌæ»» ,{162,PROC_SELECTOR, "0-33","34|35|", 0, 1, ¶meters.aec_selector} //add usb ,{163,PROC_AEC, "34|35|","34|",0, 1, ¶meters.aec} ,{164,PROC_SELECTOR,"0-34","35|", 0, 1 ,¶meters.ans_selector} ,{165,PROC_ANS,"35|","35|", 0, 1 ,¶meters.ans} ,{166,PROC_MIXER,"0-35","0-32",1, 1 ,¶meters.mixer} //32 am,33-usb, 34 aec 35 ans,--output 32 usb ,{167,PROC_CROSSOVER,"0|","0|",1, 0, ¶meters.out1[0]},{168,PROC_CROSSOVER,"1|","1|",1, 0, ¶meters.out1[1]} ,{169,PROC_CROSSOVER,"2|","2|",1, 0, ¶meters.out1[2]},{170,PROC_CROSSOVER,"3|","3|",1, 0, ¶meters.out1[3]} ,{171,PROC_CROSSOVER,"4|","4|",1, 0, ¶meters.out1[4]},{172,PROC_CROSSOVER,"5|","5|",1, 0, ¶meters.out1[5]} ,{173,PROC_CROSSOVER,"6|","6|",1, 0, ¶meters.out1[6]},{174,PROC_CROSSOVER,"7|","7|",1, 0, ¶meters.out1[7]} ,{175,PROC_CROSSOVER,"8|","8|",1, 0, ¶meters.out1[8]},{176,PROC_CROSSOVER,"9|","9|",1, 0, ¶meters.out1[9]} ,{177,PROC_CROSSOVER,"10|","10|",1, 0, ¶meters.out1[10]},{178,PROC_CROSSOVER,"11|","11|",1, 0, ¶meters.out1[11]} ,{179,PROC_CROSSOVER,"12|","12|",1, 0, ¶meters.out1[12]},{180,PROC_CROSSOVER,"13|","13|",1, 0, ¶meters.out1[13]} ,{181,PROC_CROSSOVER,"14|","14|",1, 0, ¶meters.out1[14]},{182,PROC_CROSSOVER,"15|","15|",1, 0, ¶meters.out1[15]} ,{199,PROC_EQ,"0|","0|",1, 0, ¶meters.out2[0]},{200,PROC_EQ,"1|","1|",1, 0, ¶meters.out2[1]} ,{201,PROC_EQ,"2|","2|",1, 0, ¶meters.out2[2]},{202,PROC_EQ,"3|","3|",1, 0, ¶meters.out2[3]} ,{203,PROC_EQ,"4|","4|",1, 0, ¶meters.out2[4]},{204,PROC_EQ,"5|","5|",1, 0, ¶meters.out2[5]} ,{205,PROC_EQ,"6|","6|",1, 0, ¶meters.out2[6]},{206,PROC_EQ,"7|","7|",1, 0, ¶meters.out2[7]} ,{207,PROC_EQ,"8|","8|",1, 0, ¶meters.out2[8]},{208,PROC_EQ,"9|","9|",1, 0, ¶meters.out2[9]} ,{209,PROC_EQ,"10|","10|",1, 0, ¶meters.out2[10]},{210,PROC_EQ,"11|","11|",1, 0, ¶meters.out2[11]} ,{211,PROC_EQ,"12|","12|",1, 0, ¶meters.out2[12]},{212,PROC_EQ,"13|","13|",1, 0, ¶meters.out2[13]} ,{213,PROC_EQ,"14|","14|",1, 0, ¶meters.out2[14]},{214,PROC_EQ,"15|","15|",1, 0, ¶meters.out2[15]} ,{231,PROC_DELAY,"0|","0|",1, 0, ¶meters.out3[0]},{232,PROC_DELAY,"1|","1|",1, 0, ¶meters.out3[1]} ,{233,PROC_DELAY,"2|","2|",1, 0, ¶meters.out3[2]},{234,PROC_DELAY,"3|","3|",1, 0, ¶meters.out3[3]} ,{235,PROC_DELAY,"4|","4|",1, 0, ¶meters.out3[4]},{236,PROC_DELAY,"5|","5|",1, 0, ¶meters.out3[5]} ,{237,PROC_DELAY,"6|","6|",1, 0, ¶meters.out3[6]},{238,PROC_DELAY,"7|","7|",1, 0, ¶meters.out3[7]} ,{239,PROC_DELAY,"8|","8|",1, 0, ¶meters.out3[8]},{240,PROC_DELAY,"9|","9|",1, 0, ¶meters.out3[9]} ,{241,PROC_DELAY,"10|","10|",1, 0, ¶meters.out3[10]},{242,PROC_DELAY,"11|","11|",1, 0, ¶meters.out3[11]} ,{243,PROC_DELAY,"12|","12|",1, 0, ¶meters.out3[12]},{244,PROC_DELAY,"13|","13|",1, 0, ¶meters.out3[13]} ,{245,PROC_DELAY,"14|","14|",1, 0, ¶meters.out3[14]},{246,PROC_DELAY,"15|","15|",1, 0, ¶meters.out3[15]} ,{263,PROC_LIMIT,"0|","0|",1, 0, ¶meters.out4[0]},{264,PROC_LIMIT,"1|","1|",1, 0, ¶meters.out4[1]} ,{265,PROC_LIMIT,"2|","2|",1, 0, ¶meters.out4[2]},{266,PROC_LIMIT,"3|","3|",1, 0, ¶meters.out4[3]} ,{267,PROC_LIMIT,"4|","4|",1, 0, ¶meters.out4[4]},{268,PROC_LIMIT,"5|","5|",1, 0, ¶meters.out4[5]} ,{269,PROC_LIMIT,"6|","6|",1, 0, ¶meters.out4[6]},{270,PROC_LIMIT,"7|","7|",1, 0, ¶meters.out4[7]} ,{271,PROC_LIMIT,"8|","8|",1, 0, ¶meters.out4[8]},{272,PROC_LIMIT,"9|","9|",1, 0, ¶meters.out4[9]} ,{273,PROC_LIMIT,"10|","10|",1, 0, ¶meters.out4[10]},{274,PROC_LIMIT,"11|","11|",1, 0, ¶meters.out4[11]} ,{275,PROC_LIMIT,"12|","12|",1, 0, ¶meters.out4[12]},{276,PROC_LIMIT,"13|","13|",1, 0, ¶meters.out4[13]} ,{277,PROC_LIMIT,"14|","14|",1, 0, ¶meters.out4[14]},{278,PROC_LIMIT,"15|","15|",1, 0, ¶meters.out4[15]} ,{295,PROC_OUTPUT,"0-31","0-31",1, 1, ¶meters.output} ,{296,PROC_SYSCTL,"0-31","0-31",1, 1, ¶meters.sysctl} ,{297,PROC_METER,"0-31","",1, 1, 0} //151 }; typedef void* create_fn(void*, char*, char*); typedef int execute_fn(void* proc); typedef int ctrl_fn(void* proc,int cmd,int* val,int num); static const struct{ create_fn *create; ctrl_fn * ctrl; execute_fn *execute; }g_opt_ptr[PROC_COUNT]={ {(create_fn*)input_create, (ctrl_fn*)input_ctrl, (execute_fn*)input_execute } ,{(create_fn*)meter_create, (ctrl_fn*)meter_ctrl, (execute_fn*)meter_execute } ,{(create_fn*)eq_create, (ctrl_fn*)eq_ctrl, (execute_fn*)eq_execute } ,{(create_fn*)expander_create, (ctrl_fn*)expander_ctrl, (execute_fn*)expander_execute } ,{(create_fn*)compressor_create, (ctrl_fn*)compressor_ctrl, (execute_fn*)compressor_execute } ,{(create_fn*)compressor_create, (ctrl_fn*)compressor_ctrl, (execute_fn*)compressor_execute } ,{(create_fn*)mixer_create, (ctrl_fn*)mixer_ctrl, (execute_fn*)mixer_execute } ,{(create_fn*)delay_create, (ctrl_fn*)delay_ctrl, (execute_fn*)delay_execute } ,{(create_fn*)crossover_create, (ctrl_fn*)crossover_ctrl, (execute_fn*)crossover_execute } ,{(create_fn*)output_create, (ctrl_fn*)output_ctrl, (execute_fn*)output_execute } ,{(create_fn*)gain_create, (ctrl_fn*)gain_ctrl, (execute_fn*)gain_execute } ,{(create_fn*)feedback_create, (ctrl_fn*)feedback_ctrl, (execute_fn*)feedback_execute } ,{(create_fn*)automixer_create, (ctrl_fn*)automixer_ctrl, (execute_fn*)automixer_execute } ,{(create_fn*)agc_create, (ctrl_fn*)agc_ctrl , (execute_fn*)agc_execute } ,{(create_fn*)aec_create, (ctrl_fn*)aec_ctrl , (execute_fn*)aec_execute } ,{(create_fn*)ans_create, (ctrl_fn*)ans_ctrl , (execute_fn*)ans_execute } ,{(create_fn*)sysctl_create, (ctrl_fn*)sysctl_ctrl , (execute_fn*)sysctl_execute } ,{(create_fn*)shelf_create, (ctrl_fn*)shelf_ctrl , (execute_fn*)eq_execute } ,{(create_fn*)selector_create, (ctrl_fn*)selector_ctrl , (execute_fn*)selector_execute } }; void proc_delete(void* proc,eproc_type proc_type) { int i; switch(proc_type){ case PROC_LIMIT: case PROC_COMPRESS:{ pcompressor_handle p = proc; alg_compress_destroy(p->halg); } break; case PROC_EXPANDER:{ pexpander_handle p = proc; alg_expander_destroy(p->halg); } break; case PROC_DELAY:{ pdelay_handle p = proc; alg_delay_destroy(p->halg); } break; case PROC_INPUT:{ pinput_handle handle = proc; for(i=0;iinput_num;i++){ if(handle->input[i].hgen){ alg_sg_destroy(handle->input[i].hgen); } } } break; case PROC_SHELF: case PROC_EQ:{ peq_handle p = proc; alg_eq_destroy(p->halg); } break; case PROC_CROSSOVER: { pcrossover_handle p = proc; alg_filter_destroy(p->hHighalg); alg_filter_destroy(p->hLowalg); } break; case PROC_AUTOMIXER:{ pautomixer_handle p = proc; alg_automixer_destroy(p->halg); } case PROC_NHS:{ pfeedback_handle p = proc; alg_nhs_destroy(p->halg); } break; case PROC_AEC:{ paec_handle p = proc; alg_aec_destroy(p->halg); } break; case PROC_ANS:{ pans_handle p = proc; alg_ans_destroy(p->halg); } break; case PROC_AGC:{ pagc_handle p = proc; alg_agc_destroy(p->halg); } case PROC_MIXER:{ pmixer_handle p = proc; myfree(SRAM_AUTO ,p->gain); } break; default: break; } myfree(SRAM_AUTO, proc); } static int find_proc_by_paramaddr(int addr) { int i; int paramaddr; int proc_cnt = sizeof(proc_list)/sizeof(struct proc_field); for(i=0;i>8)&0xff; ptag_module pmodule = ¶meters.in1[0]; int proc_cnt = sizeof(proc_list)/sizeof(struct proc_field); unsigned int inport_number[36] ; int ninports; for(i=0;i= 0 ){ proc_list[id].proc_type = (eproc_type)pmodule->proc_type; } pmodule++; } pmodule = ¶meters.out1[0]; for(i=0;i= 0 ){ proc_list[id].proc_type = (eproc_type)pmodule->proc_type; } pmodule++; } /* input_num_channels :automier +1:usb audio +2: aec: +3: ans */ for(i=0;i=1 && proc_list[i].proc_id<=160){ ninports = str_delim(proc_list[i].inportstr,inport_number); if(ninports==1 && inport_number[0] >= input_num_channels){ proc_list[i].dsp_index = -1; //±ãÓÚ½âÎö³¡¾°¹ýÂË } else{ proc_list[i].dsp_index = 0; } } if(proc_list[i].proc_id >=167 && proc_list[i].proc_id<=294){ ninports = str_delim(proc_list[i].inportstr,inport_number); if(ninports==1 && inport_number[0] >= output_num_channels){ proc_list[i].dsp_index = -1; //±ãÓÚ½âÎö³¡¾°¹ýÂË } else{ proc_list[i].dsp_index = 1; } } break; } } } void module_def(eproc_type proc_type, void* param_ptr) { int j; int allbypass = 1; switch(proc_type){ case PROC_INPUT:{ ptag_input pInput = (ptag_input)param_ptr; pInput->input_num = MAX_INPUT_NUM; for(j=0;jinput_num;j++){ pInput->input[j].freq = 1000; pInput->input[j].level = -4800; pInput->input[j].phant = 0; pInput->input[j].sensitivity = 0; pInput->input[j].channelID = j; pInput->input[j].gain =0; pInput->input[j].mute = 0; pInput->input[j].type=0; pInput->input[j].phase =0 ; pInput->input[j].mingain = -8000; pInput->input[j].maxgain = 1200; } } break; case PROC_METER:{ // ptag_Meter pMeter = (ptag_Meter)proc_list[i].parameters; // pMeter->input_num = 8; } break; case PROC_SHELF:{ ptag_shelf pshelf = (ptag_shelf)param_ptr; pshelf->highshelf.bypass = 1; pshelf->highshelf.freq = 500; pshelf->highshelf.gain = -4500; pshelf->highshelf.q = 71; pshelf->lowshelf.bypass = 1; pshelf->lowshelf.freq = 500; pshelf->lowshelf.gain =-4500; pshelf->lowshelf.q = 71; } break; case PROC_EQ:{ int j; ptag_eq pEQ = (ptag_eq)param_ptr; uint16_t freq[]={40,80,200,500,1000,2000,4000,8000,10000,12500,16000,20000}; pEQ->bypass = allbypass; pEQ->nsection = MAX_EQ_SECTION; for(j=0;jnsection;j++){ pEQ->eq_attr[j].bypass = allbypass; pEQ->eq_attr[j].freq = freq[j]; pEQ->eq_attr[j].gain = 0; pEQ->eq_attr[j].q = 250; //pEQ->eq_attr[j].type = } } break; case PROC_EXPANDER:{ ptag_expander pExpander = (ptag_expander)param_ptr; pExpander->bypass = allbypass; pExpander->threshold = -6000; pExpander->ratio = 100; pExpander->attack = 1; pExpander->release = 1; } break; case PROC_COMPRESS:{ ptag_compress pcompress = (ptag_compress)param_ptr; pcompress->bypass = allbypass; pcompress->threshold = -4800; pcompress->ratio = 100; pcompress->attack = 1; pcompress->release = 1; pcompress->gain = 0; pcompress->soft = 0; } break; case PROC_LIMIT:{ ptag_compress pcompress = (ptag_compress)param_ptr; pcompress->bypass = allbypass; pcompress->threshold = 0; pcompress->ratio = 10000; pcompress->attack = 1; pcompress->release = 1; pcompress->gain = 0; pcompress->soft = 0; } break; case PROC_MIXER:{ int j,m; ptag_mixer pMixer = (ptag_mixer)param_ptr; pMixer->input_num = MAX_MIXER_INPUT; pMixer->output_num = MAX_MIXER_OUTPUT; memset(pMixer->input_mask,0,sizeof(pMixer->input_mask)); for (m=0;moutput_num ;m ++){ for(j=0;jinput_num;j++){ pMixer->input_gain[m][j]=0; } pMixer->input_mask[m][m/16]=1<<(m&15); } } break; case PROC_DELAY:{ ptag_delay pDelay = (ptag_delay)param_ptr; pDelay->bypass = allbypass; pDelay->ms = 1; } break; case PROC_CROSSOVER:{ ptag_crossover pCross = (ptag_crossover)param_ptr; pCross->highpass.bypass = allbypass; pCross->highpass.freq = 500;//454; pCross->highpass.taps = 18;//48; pCross->highpass.type = bessel; pCross->highpass.gain =0 ; pCross->lowpass.bypass = allbypass; pCross->lowpass.freq = 500; pCross->lowpass.taps = 18; pCross->lowpass.type = bessel; pCross->lowpass.gain =0; } break; case PROC_OUTPUT:{ ptag_output pOutput= (ptag_output)param_ptr; pOutput->output_num = MAX_OUTPUT_NUM; for(j=0;joutput_num;j++){ pOutput->output[j].gain = 0; pOutput->output[j].mute = 0; pOutput->output[j].channelID = j; pOutput->output[j].phase = 0; pOutput->output[j].mingain = -8000; pOutput->output[j].maxgain = 1200; } } break; case PROC_GAIN:{ ptag_gain pgain = (ptag_gain)param_ptr; pgain->gain = 0; pgain->mute = 0; } break; case PROC_AUTOMIXER:{ int j; ptag_automixer pautomixer = (ptag_automixer)param_ptr; pautomixer->bypass = allbypass; pautomixer->master_mute =0; pautomixer->master_gain =0; pautomixer->response = 5; pautomixer->slope = 200; for(j=0;jchannels[j].automatic = 0; pautomixer->channels[j].master = 0; pautomixer->channels[j].gain = 0; pautomixer->channels[j].threshold = -4800; } } break; case PROC_NHS:{ ptag_feedback pfb = (ptag_feedback)param_ptr; pfb->bypass = allbypass; pfb->panic_threshold = 0; pfb->flt_depth = 1800; } break; case PROC_SYSCTL:{ ptag_sysctl psysctl = (ptag_sysctl)param_ptr; psysctl->gain = 0; psysctl->mute = 0; } break; case PROC_AEC:{ ptag_aec paec = (ptag_aec)param_ptr; paec->bypass = allbypass; paec->mode = 0; } break; case PROC_ANS:{ ptag_ans pans = (ptag_ans)param_ptr; pans->bypass = allbypass; pans->mode = 0; } break; case PROC_SELECTOR:{ ptag_selector pselector = (ptag_selector)param_ptr; pselector->input_num = MAX_MIXER_INPUT; pselector->output_num = MAX_MIXER_OUTPUT; memset(pselector->input_mask,0,sizeof(pselector->input_mask)); } break; default: break; } } //ÉèÖÃĬÈϲÎÊý void scene_default() { int i,j,module_cnt=0; int proc_cnt = sizeof(proc_list)/sizeof(struct proc_field); parameters.nmds = 5|(4<<8); for(i=0;iproc_type = proc_list[i].proc_type; module_def(proc_list[i].proc_type,pmod->proc_ins); } } } void scene_running(void) { int i; struct tag_proc* pfiled = g_proc; /*for(i = 0; i < input_num_channels; i++){ BuiltIn_Expander(Expander[i], i); }*/ for(i=0 ;iproc_type].execute(pfiled->proc_handle); pfiled++; } } static int find_str(const char* str, char delim) { int i=0; while (str[i] !=0 ) { if (str[i] == delim) { return i; } i++; } return -1; } void scene_analyze() { int i; int proc_cnt = sizeof(proc_list)/sizeof(struct proc_field); //fft_reset(); //ÖØÐ¼ÓÔØ³¡¾°Ö®Ç°Çå¿ÕµçƽBUF LevelEmpty(); scene_update(); proc_count =0; // usbExpander = alg_expander_create(RATE_SAMPLES,NUM_SAMPLES); // alg_expander_set_param(usbExpander, -60.0, 3, 20,20); // for(i=0; iproc_ins ,proc_list[i].inportstr ,proc_list[i].outportstr); } g_proc[proc_count].proc_type = proc_list[i].proc_type; g_procID_table[proc_list[i].proc_id-1] = proc_count; proc_count ++; } } void scene_destroy() { int i; for(i=0;iMAX_MODULE_NUM){ return -1; } return g_opt_ptr[g_proc[id].proc_type].ctrl(g_proc[id].proc_handle,cmd,val,num); } int scene_cpy(int npkt,const void* param,int size) { int max_len = SPI_DATA_LEN; int max_pkts = (sizeof(parameters)+SPI_DATA_LEN-1)/SPI_DATA_LEN; int i; if(size>max_len){ return -1; } if(npkt>=max_pkts){ return -1; } if(npkt==max_pkts-1){ size = sizeof(parameters)-npkt*SPI_DATA_LEN; } memcpy((short*)¶meters+npkt*max_len,param,size); return 0; } static int scene_can_copy(ptag_module psrc, ptag_module pdst, int input) { int i; int number = input?5:4; int channels_delim = input?MAX_INPUT_NUM:MAX_OUTPUT_NUM; for(i=0;iproc_type != pdst->proc_type){ return 0; } psrc+=channels_delim; pdst+=channels_delim; } return 1; } static void scene_copy(ptag_module psrc, ptag_module pdst, int input) { int i; int number = input?5:4; int channels_delim = input?MAX_INPUT_NUM:MAX_OUTPUT_NUM; for(i=0;iparam_ptr; alg_expander_set_param(handle->halg, pExpander->threshold/100.0f , pExpander->ratio/100.0f, pExpander->attack,pExpander->release); handle->bypass = pExpander->bypass; } break; case PROC_EQ:{ peq_handle handle = g_proc[index].proc_handle; ptag_eq pEQ = handle->param_ptr; int j; for(j=0;jnsection;j++){ alg_eq_set_param(handle->halg,j,(eq_type_t)pEQ->eq_attr[j].type, pEQ->eq_attr[j].bypass,pEQ->eq_attr[j].freq ,pEQ->eq_attr[j].gain/100.0f,pEQ->eq_attr[j].q/100.0f); } handle->bypass = pEQ->bypass; } break; case PROC_COMPRESS: case PROC_LIMIT:{ pcompressor_handle handle = g_proc[index].proc_handle; ptag_compress pcompress = handle->param_ptr; alg_compress_set_param(handle->halg, pcompress->threshold/100.0f , pcompress->ratio/100.0f,pcompress->attack,pcompress->release,pcompress->gain/100.0f,0 ); handle->bypass = pcompress->bypass; } break; case PROC_DELAY:{ pdelay_handle handle = g_proc[index].proc_handle; ptag_delay pDelay = handle->param_ptr; alg_delay_set_msec(handle->halg,pDelay->ms*1.0f); handle->bypass = pDelay->bypass; } break; case PROC_CROSSOVER:{ pcrossover_handle handle = g_proc[index].proc_handle; ptag_crossover pCross = handle->param_ptr; alg_filter_set_param(handle->hLowalg,pCross->lowpass.freq,pCross->lowpass.taps,(eFilterType)pCross->lowpass.type, pCross->lowpass.gain/100.0f); alg_filter_set_param(handle->hHighalg,pCross->highpass.freq,pCross->highpass.taps,(eFilterType)pCross->highpass.type,pCross->highpass.gain/100.0f); handle->lowbypass = pCross->lowpass.bypass&0x1; handle->highbypass = pCross->highpass.bypass&0x1; } break; case PROC_GAIN:{ pgain_handle handle = g_proc[index].proc_handle; ptag_gain pgain = handle->param_ptr; handle->gain = pgain->gain/100.0f; handle->old_gain=-100.0f; } break; case PROC_NHS:{ int j; pfeedback_handle handle = g_proc[index].proc_handle; ptag_feedback pfeedback = handle->param_ptr; alg_nhs_set_threshold(handle->halg,pfeedback->fb_threshold*0.01); alg_nhs_set_panic(handle->halg,pfeedback->panic_threshold*0.01); alg_nhs_set_parameters(handle->halg, 2.5, pfeedback->flt_depth*0.01,pfeedback->bw*0.01 ); /*for(j=0;jhalg , j ,pfeedback->flt_group[j].type , pfeedback->flt_group[j].fc,pfeedback->flt_group[j].gain/100.0); }*/ handle->bypass = pfeedback->bypass; } break; case PROC_AGC:{ pagc_handle handle = g_proc[index].proc_handle; ptag_agc pagc = handle->param_ptr; alg_agc_set_param(handle->halg ,pagc->threshold/100.0f , pagc->tar_threshold/100.0f, pagc->ratio/100.0f ,pagc->attacktime , pagc->releasetime); handle->bypass = pagc->bypass; } break; default: break; } } static void update_copy(int output , int channel) { int i,index; ptag_module pmodule ; int nmoudles =0; int ndelims =0; if(output ){ pmodule = ¶meters.out1[channel]; nmoudles = 4; ndelims = MAX_OUTPUT_NUM; index = find_proc_by_paramaddr((int)¶meters.output); index = g_procID_table[proc_list[index].proc_id - 1]; { poutput_handle handle = g_proc[index].proc_handle; ptag_output pOutput = handle->param_ptr; handle->output[channel].mute = pOutput->output[channel].mute; handle->output[channel].gain = pOutput->output[channel].gain/100.0f; handle->output[channel].old_gain = -48 ; handle->output[channel].time = FADE_OUT_TIME; handle->output[channel].step_gain = (handle->output[channel].gain - handle->output[channel].old_gain)/FADE_OUT_TIME; } } else{ pmodule = ¶meters.in1[channel]; nmoudles =5; ndelims = MAX_INPUT_NUM; //update input index = find_proc_by_paramaddr((int)¶meters.input); index = g_procID_table[proc_list[index].proc_id - 1]; { pinput_handle handle = g_proc[index].proc_handle; ptag_input pInput = handle->param_ptr; handle->input[channel].gain= pInput->input[channel].gain/100.0f; handle->input[channel].old_gain = -48 ; handle->input[channel].time = FADE_OUT_TIME; handle->input[channel].step_gain = (handle->input[channel].gain - handle->input[channel].old_gain)/FADE_OUT_TIME; handle->input[channel].mute = pInput->input[channel].mute&0x1; handle->input[channel].type = pInput->input[channel].type&0x3; alg_sg_set_param(handle->input[channel].hgen,pInput->input[channel].freq ,handle->input[channel].type,pInput->input[channel].level/100.0f); } } for(i=0;i=0){ index = g_procID_table[proc_list[index].proc_id - 1]; update_module_algorithm_parameters((eproc_type)pmodule->proc_type ,index); } pmodule += ndelims; } } int scene_channel_copy(ptag_channel_copy pchannels) { ptag_module psrc; ptag_module pdst ; if(pchannels->output == 0){ if(pchannels->source_channel_index>= MAX_INPUT_NUM || pchannels->dest_channel_index>= MAX_INPUT_NUM ){ return 0; } psrc = ¶meters.in1[pchannels->source_channel_index]; pdst = ¶meters.in1[pchannels->dest_channel_index]; if(scene_can_copy(psrc ,pdst , 1)){ scene_copy(psrc ,pdst , 1); memcpy(¶meters.input.input[pchannels->dest_channel_index] , ¶meters.input.input[pchannels->source_channel_index] , sizeof(parameters.input.input[0])); update_copy(0 , pchannels->dest_channel_index); } else{ return 0; } } else{ if(pchannels->source_channel_index>= MAX_OUTPUT_NUM || pchannels->dest_channel_index>= MAX_OUTPUT_NUM ){ return 0; } psrc = ¶meters.out1[pchannels->source_channel_index]; pdst = ¶meters.out1[pchannels->dest_channel_index]; if(scene_can_copy(psrc ,pdst , 0)){ scene_copy(psrc ,pdst , 0); memcpy(¶meters.output.output[pchannels->dest_channel_index] , ¶meters.output.output[pchannels->source_channel_index] , sizeof(parameters.output.output[0])); update_copy(1 , pchannels->dest_channel_index); } else{ return 0; } } return 1; }