フィルターのクリア

Error in a testbench generated file using validateAudioPlugin

1 回表示 (過去 30 日間)
DARIO BENVEGNÙ
DARIO BENVEGNÙ 2024 年 2 月 7 日
コメント済み: DARIO BENVEGNÙ 2024 年 2 月 9 日
While validating an audio plugin, I get the following error
Generating mex file 'testbench_HeadPhoneSimulator_ver2_mex.mexmaci64'... Cannot allocate this handle object. For code generation, a handle object
allocated inside a loop cannot be referenced outside of the loop.
More information
Error in ==> testbench_HeadPhoneSimulator_ver2 Line: 58 Column: 9
Warning: Failed to save report information.
Code generation failed: View Error Report
Error using coder.internal.generateAudioPlugin
Error in validateAudioPlugin
the thing that I don't understand is the fact that the error is in a file that's not written by me, but in a file made by the testbench itself.
I think that the function that provokes the error is the following:
function updateFilters(plugin,n,flag)
if ~flag
plugin.Filter_L = dsp.FrequencyDomainFIRFilter('Numerator', plugin.IR_bank(:,1,n).', ...
'PartitionForReducedLatency', true, 'PartitionLength', 1024);
plugin.Filter_R = dsp.FrequencyDomainFIRFilter('Numerator', plugin.IR_bank(:,2,n).', ...
'PartitionForReducedLatency', true, 'PartitionLength', 1024);
else
num = zeros(1,1024);
num(1) = 1;
plugin.Filter_L = dsp.FrequencyDomainFIRFilter('Numerator', num, ...
'PartitionForReducedLatency', true, 'PartitionLength', 1024);
plugin.Filter_R = dsp.FrequencyDomainFIRFilter('Numerator', num, ...
PartitionForReducedLatency', true, 'PartitionLength', 1024);
end
end
if needed I will provide the complete code
  6 件のコメント
jibrahim
jibrahim 2024 年 2 月 8 日
Yes, please also attach ImpulseResponseLoader or equivalent code
DARIO BENVEGNÙ
DARIO BENVEGNÙ 2024 年 2 月 8 日
編集済み: DARIO BENVEGNÙ 2024 年 2 月 8 日
this should be enough. thank you.

サインインしてコメントする。

採用された回答

jibrahim
jibrahim 2024 年 2 月 8 日
編集済み: jibrahim 2024 年 2 月 8 日
Hi Dario,
Thanks for the reproduction steps. This helps.
The problem is in the method updateFilters. The method recreates the frequency-domain filters every time it is called. This is not supported in this context in codegen (those are the objects validation is complaining are created in a loop).
You probably want to tune these objects instead of recreating them, i.e.
function updateFilters(plugin,n,flag)
if ~flag
plugin.Filter_L.Numerator = plugin.IR_bank(:,1,n).';
plugin.Filter_R.Numerator = plugin.IR_bank(:,2,n).';
else
num = zeros(1,1024);
num(1) = 1;
plugin.Filter_L.Numerator = num;
plugin.Filter_R.Numerator = num;
end
end
There is another issue in process, where output was first set to empty, and then its size is changed to the size of input. Code generation does not like this size change. This code fixes the issue:
function output = process(plugin,input) % funzione di elaborazione
output = input;
if ~plugin.bypass
output(:,1) = step(plugin.Filter_L,input(:,1));
output(:,2) = step(plugin.Filter_R,input(:,2));
end
end
With those two changes, you should be able to validate and generate your plugin.
  1 件のコメント
DARIO BENVEGNÙ
DARIO BENVEGNÙ 2024 年 2 月 9 日
Thank you Jibrahim, this has solved my issue

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by