Home AMX User Forum AMX Technical Discussion

Recursive subscription function question.

Hello, Im a new programmer and I recently inherited a system with an NX4200.

I found this function handling the feedback polling of the audio DSP. It appears to be calling itself over and over again. Is this dangerous for the processor?

define_call 'DSP feedback registration'
{
if(length_string(cDSP_subscriptions[nDSP_param_polled]))
{
wait 10
{
if(VolumeCurrent[nDSP_param_polled])
{
SEND_LEVEL dvTP_Main,Volume_BTN_LVL_UP[nDSP_param_polled],VolumeCurrent[nDSP_param_polled]
}
send_string dvBiamp,"cDSP_subscriptions[nDSP_param_polled]"
nDSP_param_polled = nDSP_param_polled + 1
call 'DSP feedback registration'
}
}
else
{
if(nDSP_param_polled < 101)
{
nDSP_param_polled = nDSP_param_polled + 1
call 'DSP feedback registration'
}
}
}

Thank you!

Comments

  • HARMAN_icraigieHARMAN_icraigie Technical Trainer II, Harman Professional University Posts: 610

    Looks like a call that was inherited from way back in the ancient 1990's Axcess programming days. Think it only runs 100 times at pop iterating over itself 1/second - must be called repeatedly from somewhere else in code.

    Better (read modern, efficient, portable, scalable, maintainable... ) way would probably be through a timeline.

    DEFINE_VARIABLE
    volatile long lDspPolling[] = {250}; // 1/4 second interval - muy rapido!
    
    DEFINE_EVENT
    someevent[someventTrigger]
    {
      timeline_create(DSPFeedbackRegistration, lDspPolling, length_array(lDspPolling), TIMELINE_ABSOLUTE, TIMELINE_REPEAT);
    }
    
    timeline_event[DSPFeedbackRegistration]
    {
      local_var volatile integer iPolledParameter;
    
      iPolledParameter++;
      if(iPolledParameter > 100) // Max 100 parameters?
      {  
        timeline_kill(timeline.id);
      }
      if(length_string(cDSP_subscriptions[iPolledParameter ]))
      {
        if(VolumeCurrent[iPolledParameter ])
        {
          SEND_LEVEL dvTP_Main, Volume_BTN_LVL_UP[iPolledParameter ], VolumeCurrent[iPolledParameter ]
        }
        send_string dvBiamp, cDSP_subscriptions[iPolledParameter ] 
      }
    }
    
Sign In or Register to comment.