pCompiledNumChannels error in audio plugin generation

조회 수: 6 (최근 30일)
Pablo Panitta
Pablo Panitta 2020년 10월 18일
댓글: Pablo Panitta 2020년 10월 20일
Hi
I´m trying to use crossoverFilter function as part of a more elaborated signal process plugin, but I find the following error message when I try to generate the audio plugin:
"Failed to compute constant value for nontunable property 'pCompiledNumChannels'. In code generation,nontunable properties can only be assigned constant values".
No issues at all when I run it through audioTestBench, but it does when I try to compile.
The code is really long, but as an example, I reproduce the same with a basic code attached. So, even when this one is not useful at all, I think help to reproduce the error easily.
classdef (StrictDefaults)CrossTest < matlab.System & audioPlugin
% CrossOver plugin test
properties
FCross=100;
end
properties (Constant, Hidden)
% Define the plugin interface
PluginInterface = audioPluginInterface( ...
'InputChannels',2,...
'OutputChannels',2,...
'PluginName','CrossOver Test',...
audioPluginParameter('FCross', ...
'DisplayName', 'Frequency Cutoff', ...
'Mapping', { 'int', 20, 18000}, ...
'Style', 'rotaryknob'))
end
properties (Access = private)
xFilt;
NumCrossovers = 1;
hpf;
pSR;
end
methods
% Constructor
function plugin = CrossTest
fs = getSampleRate(plugin);
plugin.xFilt=crossoverFilter("SampleRate",fs,"NumCrossovers",1,"CrossoverFrequencies",100,"CrossoverSlopes",6);
plugin.hpf=dsp.HighpassFilter('FilterType','IIR','PassbandFrequency',300,'StopbandFrequency',100,'StopbandAttenuation',40); % <<--- Agregado
end
function set.FCross (plugin,val)
plugin.FCross=val;
plugin.crossdesign;
end
end
methods(Access = protected)
%% OUT
function out = stepImpl(plugin, in)
infilt=plugin.hpf(in); % Filter the input signal
[O1,O2]=plugin.xFilt(infilt); % CrossOver the filtered Signal
out=O1+O2;
end
function resetImpl(plugin)
reset(plugin.xFilt);
end
end
methods (Access = private)
function crossdesign(plugin)
plugin.xFilt.CrossoverFrequencies=plugin.FCross;
end
end
end
I would really appreciate if someone give me a hint about how to overcome this.
Thanks
Pablo

채택된 답변

jibrahim
jibrahim 2020년 10월 20일
Hi Pablo,
The corssover filter object is complaining that the number of channels is unknown. This is because the code generation compiler interprets the input to the crossover as having a varying 2nd dimension.
Modify the call to your crossover in stepImpl to this:
[O1,O2]=plugin.xFilt(infilt(:,1:2)); % CrossOver the filtered Signal
  댓글 수: 3
jibrahim
jibrahim 2020년 10월 20일
Hi Pablo,
This is indeed related to the way inputs are defined in the plugin.
When the plugin is generated, the input is set to have variable-size frame length (the number of rows). This is to enable the genenrated plugin for any frame size selected by the user. The number of channels (columns) is fixed, but dsp.HighpassFilter's output will be variable-sized in both dimensions, even though only the first dimension of the input is varsize. This is a limitation of the object.
This can be illustrated by an example.
Consider this function:
function [O1,O2] = foo(x)
fs = 16e3;
xFilt=crossoverFilter("SampleRate",fs,"NumCrossovers",1,"CrossoverFrequencies",100,"CrossoverSlopes",6);
hpf=dsp.HighpassFilter('FilterType','IIR','PassbandFrequency',300,'StopbandFrequency',100,'StopbandAttenuation',40); % <<--- Agregado
infilt=hpf(x); % Filter the input signal
[O1,O2]=xFilt(infilt(:,1:2)); % CrossOver the filtered Signal
Generate code with a varsize input (frame length varies):
x = coder.typeof(0,[1024 2],[1 0]);
codegen foo -args x -report
Hover over the infilt variable, and you will see that it is now varsize in both dimensions (the ':' before the dimension means it is not constant-size):
We can look into seeing if the output of the highpass filter (and other objects) is :1024x2 instead of :1024x:2, but this is why you are seeing this behavior.
Pablo Panitta
Pablo Panitta 2020년 10월 20일
Hi jibrahim
Outsanding explanation! Now I see why pre placing the hpf caused the issue. I didn´t know about the bahaviour of this object, but now is clear!
Thanks a lot!
br
Pablo

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by