HRTF plugin Filter error
Mostrar comentarios más antiguos
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)
azimuth
elevation
Tdata=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
2 comentarios
Brian Hemmat
el 25 de Mayo de 2020
Editada: Brian Hemmat
el 25 de Mayo de 2020
Hello Pablo,
I can't reproduce your plugin because I don't have access to those mat files.
In general, don't construct the dsp.FIRFilter objects in the loop. Contruct and assign the left filter and right filter in the plugin constructor:
function plugin = HRTF_test
needtocalculateAzimuth(plugin);
plugin.leftfilter = dsp.FIRFilter;
plugin.rightfilter = dsp.FIRFilter;
end
In needtocalculateAzimuth, just update the filter numerators. The numerators property is tunable for exactly this use case.
function needtocalculateAzimuth(plugin) % Filter Calculation
...
plugin.leftfilter.Numerator = leftIR;
plugin.rightfilter.Numerator = rightIR;
end
For tips on plugin authoring, including implementing composition, see Tips and Tricks for Plugin Authoring.
HTH,
Brian
Pablo Panitta
el 26 de Mayo de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Audio Plugin Creation and Hosting en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!