Matlab Coder: Fail to call phased.Fro​stBeamform​er().

1 次查看(过去 30 天)
I use phased.FrostBeamformer() in my matlab code, and I want to transfer this code into c++ code through matlab coder.
The matlab coder construct phased.FrostBeamformer successfully, but fail to call this callable object.
Here are the error message and my codes:
function EnhancedAudio = AudioEnhance(OriginalAudio, BFAngle)
% OriginalAudio: samples * channels
InputSize = size(OriginalAudio);
DataLength = InputSize(1);
NumOfChannels = 5;
Angle = [BFAngle ; 0];
microphone = phased.OmnidirectionalMicrophoneElement('FrequencyRange',[20 20e3]);
ula = phased.ULA(NumOfChannels, 0.024, 'Element', microphone);
c = 340;
Beamformer = phased.FrostBeamformer(...
'SensorArray',ula,...
'SampleRate',16000,...
'PropagationSpeed',c,...
'FilterLength',30,...
'DirectionSource','Input port'...
);
FrameLength = 2000;
EnhancedAudio = zeros(DataLength, 1);
for i = 1:FrameLength:DataLength
InvolvedAudio = OriginalAudio(i: i + FrameLength - 1, :);
EnhancedAudio(i: i + FrameLength - 1, :) = Beamformer(InvolvedAudio, Angle);
end
end
  2 个评论
Ji Lee
Ji Lee 2022-12-12
Would you be able to provide the project (PRJ) file associated with this code and error?
亚杰 颜
亚杰 颜 2022-12-18
Sorry for replying so lately, I tried to solve it by myself but failed.

请先登录,再进行评论。

回答(1 个)

Areej Varamban Kallan
编辑:Areej Varamban Kallan 2023-1-19
Hi,
This is an internal error from phased.FrostBeamformer. We have made an internal note for more investigation.
Meanwhile with some changes to your function AudioEnahance.m, we can successfully generate code. Please find the modified code below.
function EnhancedAudio = AudioEnhance(OriginalAudio, BFAngle)
%#codegen
% OriginalAudio: samples * channels
InputSize = size(OriginalAudio);
DataLength = InputSize(1);
NumOfChannels = 5;
Angle = [BFAngle ; 0];
microphone = phased.OmnidirectionalMicrophoneElement('FrequencyRange',[20 20e3]);
ula = phased.ULA(NumOfChannels, 0.024, 'Element', microphone);
c = 340;
Beamformer = phased.FrostBeamformer(...
'SensorArray',ula,...
'SampleRate',16000,...
'PropagationSpeed',c,...
'FilterLength',30,...
'DirectionSource','Input port'...
);
FrameLength = 2000;
EnhancedAudio = zeros(DataLength, 1);
InvolvedAudio = coder.nullcopy(zeros(FrameLength,size(OriginalAudio,2),'like',OriginalAudio));
for i = 1:FrameLength:DataLength
if coder.target('MATLAB')
InvolvedAudio = OriginalAudio(i: i + FrameLength - 1, :);
else
for ch = 1:FrameLength
InvolvedAudio(ch,:) = OriginalAudio(i+ch-1,:);
end
end
EnhancedAudio(i: i + FrameLength - 1, :) = Beamformer(InvolvedAudio, Angle);
end
end
Thanks,
Areej

类别

Help CenterFile Exchange 中查找有关 Communications Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by