/*
|
* scene.c
|
*
|
* Created on: 2025Äê7ÔÂ18ÈÕ
|
* Author: 86189
|
*/
|
#include <string.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include "tg_scene.h"
|
#include "../protocol_internal.h"
|
#include "../ModuleExport.h"
|
|
tgScene::tgScene(hw_adapter_t* adapter):Scene(adapter)
|
{
|
s8 inport_str[8],outport_str[8];
|
s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num ;
|
s16 input_num, output_num ;
|
s32 n;
|
|
s16 dual_dsp = adapter->get_system_is_dual_dsp();
|
s16 dsp_index = adapter->get_dsp_index();
|
|
adapter->get_channel_num(&ana_input_num, &ana_output_num, &dante_input_num, &dante_output_num);
|
input_num = ana_input_num + dante_input_num;
|
output_num = dante_input_num + dante_output_num;
|
|
//port from 1 start.
|
sprintf(inport_str, "1-%d", input_num);
|
__MADD(299,PROC_INPUT,inport_str,inport_str,0, 1 ,¶meters.input, 0, ModuleInterfaceType::PHY_INPUT);
|
__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);
|
__MADD(1+i,PROC_EXPANDER, inport_str, inport_str, 0, 0, ¶meters.in1[i], 0, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//compresser
|
for(s32 i =0 ;i < input_num ; i++) {
|
sprintf(inport_str, "%d|", i+1);
|
__MADD(33+i,PROC_COMPRESS, inport_str, inport_str, 0, 0, ¶meters.in2[i], 0, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//agc
|
for(s32 i =0 ;i < input_num ; i++) {
|
sprintf(inport_str, "%d|", i+1);
|
__MADD(65+i,PROC_AGC, inport_str, inport_str, 0, 0, ¶meters.in3[i], 0, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//eq
|
for(s32 i =0 ;i < input_num ; i++) {
|
sprintf(inport_str, "%d|", i+1);
|
__MADD(97+i,PROC_EQ, inport_str, inport_str, 0, 0, ¶meters.in4[i], 8, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//nhs
|
for(s32 i =0 ;i < input_num ; i++) {
|
sprintf(inport_str, "%d|", i+1);
|
__MADD(129+i,PROC_FEEDBACK, inport_str, inport_str, 0, 0, ¶meters.in5[i], 8, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//am
|
sprintf(inport_str, "1-%d", input_num);
|
sprintf(outport_str, "1-%d", input_num+1);
|
__MADD(161,PROC_AUTOMIXER,inport_str, outport_str,0, 0, ¶meters.automixer, 0, ModuleInterfaceType::SOFT_MODULE); //¿ÉÌæ»»
|
|
//aec selector
|
sprintf(inport_str, "1-%d", input_num+ 2);//+1 add usb
|
sprintf(outport_str, "%d|%d|", input_num+ 3, input_num+ 4);
|
__MADD(162,PROC_SELECTOR, inport_str,outport_str, 0, 1, ¶meters.aec_selector, 0, ModuleInterfaceType::SOFT_MODULE); //add usb
|
|
//aec
|
sprintf(inport_str, "%d|%d", input_num+ 3, input_num+ 4);
|
sprintf(outport_str, "%d|", input_num+ 3);
|
__MADD(163,PROC_AEC,inport_str, outport_str ,0, 1, ¶meters.aec, 256, ModuleInterfaceType::SOFT_MODULE);
|
|
//ans selector
|
sprintf(inport_str, "0-%d", input_num+ 3);
|
sprintf(outport_str, "%d|", input_num+ 4);
|
__MADD(164,PROC_SELECTOR,inport_str,outport_str, 1, 1 ,¶meters.ans_selector, 0, ModuleInterfaceType::SOFT_MODULE);
|
|
//ans
|
sprintf(inport_str, "%d|", input_num+ 4);
|
sprintf(outport_str, "%d|", input_num+ 4);
|
__MADD(165,PROC_ANS,inport_str,outport_str, 1, 0 ,¶meters.afc_ns,0, ModuleInterfaceType::SOFT_MODULE);
|
|
//mixer
|
sprintf(inport_str, "1-%d", input_num+ 4);
|
sprintf(outport_str, "1-%d", output_num+1);
|
__MADD(166,PROC_MIXER,"0-35","0-32",1, 1 ,¶meters.mixer, 0, ModuleInterfaceType::SOFT_MODULE);
|
|
//crossover
|
for(s32 i =0 ;i < output_num ; i++) {
|
sprintf(outport_str, "%d|", i+1);
|
__MADD(167,PROC_CROSSOVER,outport_str, outport_str,1, 0, ¶meters.out1[i],2, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//eq
|
for(s32 i =0 ;i < output_num ; i++) {
|
sprintf(outport_str, "%d|", i+1);
|
__MADD(199,PROC_EQ,outport_str, outport_str,1, 0, ¶meters.out2[i], 8, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//delay
|
for(s32 i =0 ;i < output_num ; i++) {
|
sprintf(outport_str, "%d|", i+1);
|
__MADD(231,PROC_DELAY,outport_str, outport_str,1, 0, ¶meters.out3[i], 1200, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//limit
|
for(s32 i =0 ;i < output_num ; i++) {
|
sprintf(outport_str, "%d|", i+1);
|
__MADD(263,PROC_LIMIT,outport_str, outport_str,1, 0, ¶meters.out4[i],0, ModuleInterfaceType::SOFT_MODULE);
|
}
|
|
//output
|
sprintf(outport_str, "0-%d", output_num);
|
__MADD(295,PROC_OUTPUT,outport_str,outport_str,1, 1, ¶meters.output,0, ModuleInterfaceType::SOFT_MODULE);
|
//sysctrl
|
__MADD(296,PROC_SYSCTL,outport_str,outport_str,1, 1, ¶meters.sysctl,0, ModuleInterfaceType::PHY_OUTPUT);
|
//meter
|
__MADD(297,PROC_METER,outport_str,"",1, 1, NULL, 0, ModuleInterfaceType::SOFT_MODULE);
|
};
|
|
|
s32 tgScene::set_parameters_content(uvoid* param, s32 size)
|
{
|
tag_parameters* pp = (tag_parameters*)param;
|
if(pp->magic != 0xb34c && size != sizeof(tag_parameters)) {
|
//basic check.
|
return -1;
|
}
|
memcpy(¶meters, param, sizeof(tag_parameters));
|
|
return 0;
|
}
|
|
s32 tgScene::update_dynmodule_tag(s32 proc_type,struct proc_field* proc)
|
{
|
switch(proc_type) {
|
case ModuleType::PROC_EQ:{
|
ptag_module pmodule = (ptag_module)proc->parameters;
|
ptag_geq geq = (ptag_geq)pmodule->proc_ins;
|
|
proc->tag = geq->nsections;
|
}
|
break;
|
case ModuleType::PROC_GEQ:{
|
ptag_module pmodule = (ptag_module)proc->parameters;
|
ptag_eq eq = (ptag_eq)pmodule->proc_ins;
|
|
proc->tag = eq->nsection;
|
}
|
break;
|
case ModuleType::PROC_GATING:
|
case ModuleType::PROC_EXPANDER:
|
proc->tag =0;
|
break;
|
case ModuleType::PROC_COMPRESS:
|
case ModuleType::PROC_LIMIT:
|
proc->tag =0;
|
break;
|
case ModuleType::PROC_DELAY:
|
proc->tag =1200;
|
break;
|
case ModuleType::PROC_CROSSOVER:
|
proc->tag =2;
|
break;
|
case ModuleType::PROC_FEEDBACK:{
|
ptag_module pmodule = (ptag_module)proc->parameters;
|
ptag_feedback nhs = (ptag_feedback)pmodule->proc_ins;
|
|
proc->tag = nhs->fbc_num;
|
}
|
break;
|
case ModuleType::PROC_AGC:
|
proc->tag =0;
|
break;
|
case ModuleType::PROC_CONTINUNOUS_SPL:
|
proc->tag =0;
|
break;
|
case ModuleType::PROC_DUCKER:
|
proc->tag =0;
|
break;
|
case ModuleType::PROC_FIR:
|
proc->tag = 1024;
|
break;
|
default:
|
proc->tag =0 ;
|
break;
|
}
|
proc->proc_type = proc_type;
|
return 0;
|
}
|
|
s32 tgScene::update_module()
|
{
|
u8 port_number[16];
|
s8 ana_input_num, ana_output_num,dante_input_num,dante_output_num ;
|
s16 input_num, output_num ;
|
s16 dual_dsp = hw_adapter->get_system_is_dual_dsp();
|
s16 dsp_index = hw_adapter->get_dsp_index();
|
|
hw_adapter->get_channel_num(&ana_input_num, &ana_output_num, &dante_input_num, &dante_output_num);
|
input_num = ana_input_num + dante_input_num;
|
output_num = dante_input_num + dante_output_num;
|
|
for(auto& iter: proc_list){
|
//update dynamic module info.
|
if(iter.fixed == 0) {
|
ptag_module pmodule = (ptag_module)iter.parameters;
|
if(pmodule->proc_type >= ModuleType::PROC_COUNT || pmodule->proc_type < ModuleType::PROC_NONE) {
|
pmodule->proc_type = ModuleType::PROC_NONE;
|
}
|
update_dynmodule_tag(pmodule->proc_type, &iter);
|
|
// if(iter.dsp_index == 0) {
|
// s32 n = input_num;
|
// s32 ninports = str_delim((const s8*)iter.inportstr, port_number);
|
//
|
// //Consider PCM model&& PCM channel don't process.
|
// if(dual_dsp == 0 && input_num >16){
|
// n = ana_input_num;
|
// }
|
//
|
// if(ninports == 1 && port_number[0] >= n){
|
// iter.proc_type = ModuleType::PROC_NONE;//±ãÓÚ½âÎö³¡¾°¹ýÂË
|
// //even though module not to process, but the pc has level offset.
|
// if(port_number[0] >= input_num) {
|
//
|
// }
|
// }
|
// }
|
// else {
|
// s32 n = output_num;
|
// s32 ninports = str_delim(iter.inportstr, port_number);
|
//
|
// if(dual_dsp == 0 && output_num >16){
|
// n = ana_output_num;
|
// }
|
//
|
// if(ninports==1 && port_number[0] >= n){
|
// iter.proc_type = ModuleType::PROC_NONE; //±ãÓÚ½âÎö³¡¾°¹ýÂË
|
// //even though module not to process, but the pc has level offset.
|
// if(port_number[0] >= output_num) {
|
//
|
// }
|
// }
|
// }
|
}
|
}
|
|
return 0;
|
}
|
|
uvoid* tgScene::get_module_param_ptr(uvoid *param, s32 fixed)
|
{
|
uvoid *ptr = param;
|
|
if(fixed == 0){
|
ptag_module pmod = (ptag_module)param;
|
ptr = (void*)pmod->proc_ins;
|
}
|
return ptr;
|
}
|
|
|
u32 tgScene::get_module_id(u32 mid, s32 mtype , u32 pid)
|
{
|
if(mtype == PROC_INPUT && (pid == INPUT_TYPE || pid == INPUT_FREQ || pid == INPUT_LEVEL)){
|
mid = 300;
|
}
|
else if(mtype == PROC_DUCKER && pid == DUCKER_MIX){
|
mid = mid + 320;
|
}
|
|
return mid;
|
}
|