Hi
I´m trying to create a dll based on interporlatedHRTF function. Inside audioTestBench enviroment runs perfect, but when I try to compile it , the following error appears:
"Cannot compute constant value for argument #2 for this System object constructor. All arguments to the constructor of this System object must be constants for code generation….."
Seem is related to dsp.FIRFilter constructor, but I don´t know how to solve the situation. Coeficient must change during the process because location of the source must be able to change according to inputs parameter.
classdef HRTF_test < audioPlugin properties Sx=5; Sy=8; Rx=5; Ry=5; end properties (Access = private) azimuthelevationTdata=load('S005_marl_NYU_DATA.mat');Tposition=load ('S005_marl_NYU_POS.mat');leftIR=zeros(1,512)rightIR=zeros(1,512)leftfilter rightfilter end properties (Constant) PluginInterface = audioPluginInterface(... audioPluginParameter('Sx',... 'DisplayName','Position Source X',... 'Mapping',{'lin',0,10},... 'Label','meters'),... audioPluginParameter('Sy',... 'DisplayName','Position Source Y',... 'Mapping',{'lin',0,10},... 'Label','meters')); end methods function plugin=HRTF_test needtocalculateAzimuth(plugin); end function out = process(plugin, in) out=[step(plugin.leftfilter,in(:,1)),step(plugin.rightfilter,in(:,2))]; end function set.Sx(plugin, val) plugin.Sx = val; needtocalculateAzimuth(plugin); end function set.Sy(plugin,val) plugin.Sy=val; needtocalculateAzimuth(plugin); end function needtocalculateAzimuth(plugin) % Filter Calculation
if plugin.Sy==5 plugin.azimuth=0; else plugin.azimuth=rad2deg(atan((plugin.Sx-plugin.Rx)/(plugin.Sy-plugin.Ry))); end plugin.elevation=0; sourcePosition1 = [plugin.Tposition.dposition(:,1),plugin.Tposition.dposition(:,2)]; desiredPosition = [plugin.azimuth plugin.elevation]; interpolatedIR = interpolateHRTF(plugin.Tdata.Tdata,sourcePosition1,desiredPosition); plugin.leftIR = squeeze(interpolatedIR(:,1,:))'; plugin.rightIR = squeeze(interpolatedIR(:,2,:))'; plugin.leftfilter=dsp.FIRFilter('Numerator',plugin.leftIR); plugin.rightfilter=dsp.FIRFilter('Numerator',plugin.rightIR); end function reset(plugin) end end end
Best Answer