pCompiledNumChannels error in audio plugin generation
6 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio Plugin Creation and Hosting 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!