| | |
| | | #include <string.h> |
| | | #include <stdlib.h> |
| | | #include <stdio.h> |
| | | #include <vector> |
| | | #include "tg_scene.h" |
| | | #include "../protocol_internal.h" |
| | | #include "../ModuleExport.h" |
| | | |
| | | |
| | | |
| | | tgScene::~tgScene() |
| | | { |
| | | for (s32 i = 0; i < input_num; i++) |
| | | delete chin_mid[i]; |
| | | for (s32 i = 0; i < output_num; i++) |
| | | delete chout_mid[i]; |
| | | delete chin_mid; |
| | | delete chout_mid; |
| | | paramPtr.clear(); |
| | | } |
| | | |
| | | tgScene::tgScene(hw_adapter_t* adapter):Scene(adapter) |
| | | { |
| | | s32 i; |
| | | s8 inport_str[16],outport_str[16]; |
| | | s8 ana_input_num, ana_output_num, loc_input_num, loc_output_num, dante_input_num, dante_output_num ; |
| | | s8 usb_input_num, usb_output_num; |
| | | s16 input_num, output_num ; |
| | | // s16 input_num, output_num ; |
| | | s32 n, new_idx = 300; //ID of the USB channel starts from 300. |
| | | |
| | | s16 dual_dsp = adapter->get_system_is_dual_dsp(); |
| | |
| | | //物理输入共16+16+2 |
| | | input_num = ana_input_num + dante_input_num + usb_input_num; //2 USB |
| | | output_num = ana_output_num + dante_output_num + usb_output_num; |
| | | chin_mid = new s32*[input_num]; |
| | | chout_mid = new s32*[output_num]; |
| | | for (i = 0; i < input_num; i++) { |
| | | chin_mid[i] = new s32[6]; |
| | | } |
| | | for (i = 0; i < output_num; i++) { |
| | | chout_mid[i] = new s32[5]; |
| | | } |
| | | paramPtr.resize(new_idx + usb_input_num * 5 + usb_output_num * 4, nullptr); |
| | | |
| | | tgScene_param_default(¶meters); |
| | | |
| | | sprintf(inport_str, "1-%d", input_num); |
| | | __MADD(299,PROC_INPUT,inport_str,inport_str,0, 1 ,¶meters.input, 0, ModuleInterfaceType::PHY_INPUT); |
| | | __MADD(299, PROC_INPUT,inport_str,inport_str,0, 1 ,¶meters.input, 0, ModuleInterfaceType::PHY_INPUT); |
| | | for (i = 0; i < input_num; i++) |
| | | chin_mid[i][0] = 299; |
| | | |
| | | |
| | | sprintf(inport_str, "1-%d", input_num); |
| | | __MADD(298,PROC_METER,inport_str,"",0,1 ,NULL,0, ModuleInterfaceType::SOFT_MODULE); //tag:0-peak,1-rms |
| | | __MADD(298, PROC_METER,inport_str,"",0,1 ,NULL,0, ModuleInterfaceType::SOFT_MODULE); //tag:0-peak,1-rms |
| | | |
| | | //The number of DSPs is 1, but the number of input and output channels is greater than 16. |
| | | //It only processes analog input and output. |
| | | //However, for the channels that do not need to be processed, the level offset needs to be calculated. |
| | | // if(!dual_dsp && input_num >16) { |
| | | // n = ana_input_num; |
| | | // } |
| | | // else { |
| | | // n= input_num; |
| | | // } |
| | | |
| | | |
| | | //expander |
| | | for(s32 i =0 ;i < input_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+1); |
| | | if(i < input_num - usb_input_num) |
| | | __MADD(1+i,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < input_num - usb_input_num) { |
| | | __MADD(1+i, PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][1] = 1+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][1] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //compresser |
| | | for(s32 i =0 ;i < input_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+1); |
| | | if(i < input_num - usb_input_num) |
| | | __MADD(33+i,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < input_num - usb_input_num) { |
| | | __MADD(33+i, PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][2] = 33+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][2] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //agc |
| | | for(s32 i =0 ;i < input_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+1); |
| | | if(i < input_num - usb_input_num) |
| | | __MADD(65+i,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < input_num - usb_input_num) { |
| | | __MADD(65+i, PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][3] = 65+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][3] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //eq |
| | | for(s32 i =0 ;i < input_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+1); |
| | | if(i < input_num - usb_input_num) |
| | | __MADD(97+i,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < input_num - usb_input_num) { |
| | | __MADD(97+i, PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][4] = 97+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][4] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //nhs |
| | | for(s32 i =0 ;i < input_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+1); |
| | | if(i < input_num - usb_input_num) |
| | | __MADD(129+i,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < input_num - usb_input_num) { |
| | | __MADD(129+i, PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][5] = 129+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chin_mid[i][5] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //am |
| | |
| | | //mixer |
| | | sprintf(inport_str, "1-%d", input_num+ 3); |
| | | sprintf(outport_str, "%d-%d",input_num+4, input_num+output_num+4); |
| | | __MADD(166,PROC_MIXER,inport_str,outport_str,1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE); // .begin()+48 |
| | | __MADD(166,PROC_MIXER,inport_str,outport_str,1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE); |
| | | |
| | | //crossover |
| | | //dummy |
| | | for(s32 i =0 ;i < output_num ; i++) { |
| | | sprintf(inport_str, "%d|", i+input_num+4); |
| | | sprintf(outport_str, "%d|", i+1); |
| | | if(i < output_num - usb_output_num) |
| | | __MADD(167+i,PROC_CROSSOVER,inport_str,outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_CROSSOVER,inport_str,outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE); |
| | | __MADD(500+i, PROC_NONE, inport_str, outport_str, 1, 0, ¶meters.out1[i], 2, ModuleInterfaceType::SOFT_MODULE); //预防删除了第一个输出模块时硬件无声音输出 |
| | | } |
| | | |
| | | //crossover |
| | | for(s32 i =0 ;i < output_num ; i++) { |
| | | sprintf(outport_str, "%d|", i+1); |
| | | if(i < output_num - usb_output_num) { |
| | | __MADD(167+i, PROC_CROSSOVER, outport_str, outport_str, 1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][1] = 167+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_CROSSOVER, outport_str, outport_str, 1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][1] = new_idx++; |
| | | } |
| | | } |
| | | // printf("ou_adr ou1[2]:0x%x, ou1[3]:0x%x\n", ¶meters.out1[2], ¶meters.out1[3]); |
| | | |
| | | //eq |
| | | for(s32 i =0 ;i < output_num ; i++) { |
| | | sprintf(outport_str, "%d|", i+1); |
| | | if(i < output_num - usb_output_num) |
| | | __MADD(199+i,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < output_num - usb_output_num) { |
| | | __MADD(199+i, PROC_EQ, outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][2] = 199+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_EQ, outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][2] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //delay |
| | | for(s32 i =0 ;i < output_num ; i++) { |
| | | sprintf(outport_str, "%d|", i+1); |
| | | if(i < output_num - usb_output_num) |
| | | __MADD(231+i,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < output_num - usb_output_num) { |
| | | __MADD(231+i,PROC_DELAY, outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][3] = 231+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx,PROC_DELAY, outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][3] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //limit |
| | | for(s32 i =0 ;i < output_num ; i++) { |
| | | sprintf(outport_str, "%d|", i+1); |
| | | if(i < output_num - usb_output_num) |
| | | __MADD(263+i,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE); |
| | | else |
| | | __MADD(new_idx++,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE); |
| | | if(i < output_num - usb_output_num) { |
| | | __MADD(263+i, PROC_LIMIT, outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][4] = 263+i; |
| | | } |
| | | else { |
| | | __MADD(new_idx, PROC_LIMIT, outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE); |
| | | chout_mid[i][4] = new_idx++; |
| | | } |
| | | } |
| | | |
| | | //output |
| | | sprintf(outport_str, "1-%d", output_num); |
| | | __MADD(295,PROC_OUTPUT,outport_str,outport_str,1, 1, ¶meters.output,0, ModuleInterfaceType::SOFT_MODULE); |
| | | for (i = 0; i < output_num; i++) |
| | | chout_mid[i][0] = 295; |
| | | |
| | | //sysctrl |
| | | __MADD(296,PROC_SYSCTL,outport_str,outport_str,1, 1, ¶meters.sysctl,0, ModuleInterfaceType::SOFT_MODULE); |
| | | //meter |
| | | __MADD(297,PROC_METER,outport_str,outport_str,1, 1, NULL, 0, ModuleInterfaceType::PHY_OUTPUT); |
| | | |
| | | __MADD(297,PROC_METER,outport_str,outport_str,1, 1, ¶meters.output, 0, ModuleInterfaceType::PHY_OUTPUT); |
| | | |
| | | }; |
| | | |
| | |
| | | { |
| | | int j; |
| | | int allbypass = 1; |
| | | ptag_module pmodu = (ptag_module)param_ptr; |
| | | switch(proc_type) { |
| | | |
| | | case PROC_INPUT: |
| | |
| | | break; |
| | | |
| | | case PROC_METER: |
| | | ptag_Meter pMeter = (ptag_Meter)param_ptr; |
| | | pmodu->proc_type = PROC_METER; |
| | | ptag_Meter pMeter = (ptag_Meter)pmodu->proc_ins; |
| | | pMeter->input_num = 8; |
| | | break; |
| | | |
| | | case PROC_SHELF: |
| | | ptag_shelf pshelf = (ptag_shelf)param_ptr; |
| | | pmodu->proc_type = PROC_SHELF; |
| | | ptag_shelf pshelf = (ptag_shelf)pmodu->proc_ins; |
| | | pshelf->highshelf.bypass = allbypass; |
| | | pshelf->highshelf.freq = 500; |
| | | pshelf->highshelf.gain = -4500; |
| | |
| | | |
| | | case PROC_GEQ: |
| | | int j; |
| | | ptag_geq pGEQ = (ptag_geq)param_ptr; |
| | | pmodu->proc_type = PROC_GEQ; |
| | | ptag_geq pGEQ = (ptag_geq)pmodu->proc_ins; |
| | | pGEQ->bypass = allbypass; |
| | | pGEQ->q_index = 2; |
| | | pGEQ->nsections = 31; |
| | |
| | | } |
| | | break; |
| | | case PROC_EQ: |
| | | ptag_eq pEQ = (ptag_eq)param_ptr; |
| | | pmodu->proc_type = PROC_EQ; |
| | | ptag_eq pEQ = (ptag_eq)pmodu->proc_ins; |
| | | u16 freq[]={40,80,200,500,1000,2000,4000,8000,10000,12500,16000,20000}; |
| | | pEQ->bypass = allbypass; |
| | | pEQ->nsection = MAX_EQ_SECTION; |
| | |
| | | break; |
| | | |
| | | case PROC_EXPANDER: |
| | | ptag_expander pExpander = (ptag_expander)param_ptr; |
| | | pmodu->proc_type = PROC_EXPANDER; |
| | | ptag_expander pExpander = (ptag_expander)pmodu->proc_ins; |
| | | pExpander->bypass = allbypass; |
| | | pExpander->threshold = -6000; |
| | | pExpander->ratio = 100; |
| | |
| | | break; |
| | | |
| | | case PROC_COMPRESS: |
| | | ptag_compress pcompress = (ptag_compress)param_ptr; |
| | | pmodu->proc_type = PROC_COMPRESS; |
| | | ptag_compress pcompress = (ptag_compress)pmodu->proc_ins; |
| | | pcompress->bypass = allbypass; |
| | | pcompress->threshold = -4800; |
| | | pcompress->ratio = 100; |
| | |
| | | break; |
| | | |
| | | case PROC_LIMIT: |
| | | ptag_compress limiter = (ptag_compress)param_ptr; |
| | | pmodu->proc_type = PROC_LIMIT; |
| | | ptag_compress limiter = (ptag_compress)pmodu->proc_ins; |
| | | limiter->bypass = allbypass; |
| | | limiter->threshold = 0; |
| | | limiter->ratio = 10000; |
| | |
| | | break; |
| | | |
| | | case PROC_DELAY: |
| | | ptag_delay pDelay = (ptag_delay)param_ptr; |
| | | pmodu->proc_type = PROC_DELAY; |
| | | ptag_delay pDelay = (ptag_delay)pmodu->proc_ins; |
| | | pDelay->bypass = allbypass; |
| | | pDelay->ms = 1; |
| | | break; |
| | | |
| | | case PROC_CROSSOVER: |
| | | ptag_crossover pCross = (ptag_crossover)param_ptr; |
| | | pmodu->proc_type = PROC_CROSSOVER; |
| | | ptag_crossover pCross = (ptag_crossover)pmodu->proc_ins; |
| | | pCross->highpass.bypass = allbypass; |
| | | pCross->highpass.freq = 500;//454; |
| | | pCross->highpass.taps = 18;//48; |
| | |
| | | break; |
| | | |
| | | case PROC_FEEDBACK: |
| | | ptag_feedback pfb = (ptag_feedback)param_ptr; |
| | | pmodu->proc_type = PROC_FEEDBACK; |
| | | ptag_feedback pfb = (ptag_feedback)pmodu->proc_ins; |
| | | pfb->bypass = allbypass; |
| | | pfb->panic_threshold = 0; |
| | | pfb->flt_depth = 1800; |
| | |
| | | break; |
| | | |
| | | case PROC_ANS: |
| | | ptag_ans pans = (ptag_ans)param_ptr; |
| | | pmodu->proc_type = PROC_ANS; |
| | | ptag_ans pans = (ptag_ans)pmodu->proc_ins; |
| | | pans->bypass = allbypass; |
| | | pans->mode = 0; |
| | | break; |
| | |
| | | break; |
| | | |
| | | case PROC_DUCKER: |
| | | ptag_ducker pducker = (ptag_ducker)param_ptr; |
| | | pmodu->proc_type = PROC_DUCKER; |
| | | ptag_ducker pducker = (ptag_ducker)pmodu->proc_ins; |
| | | pducker->bypass = allbypass; |
| | | pducker->threshold = -4500; |
| | | pducker->depth = -2000; |
| | |
| | | break; |
| | | |
| | | case PROC_FIR: |
| | | ptag_fir pfir = (ptag_fir)param_ptr; |
| | | pmodu->proc_type = PROC_FIR; |
| | | ptag_fir pfir = (ptag_fir)pmodu->proc_ins; |
| | | pfir->bypass = allbypass; |
| | | pfir->taps = 1024; |
| | | memset((void*)pfir->coeffs, 0, sizeof(pfir->coeffs)); |