Clear Filters
Clear Filters

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

2 views (last 30 days)
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 Comments
Ji Lee
Ji Lee on 12 Dec 2022
Would you be able to provide the project (PRJ) file associated with this code and error?
亚杰 颜
亚杰 颜 on 18 Dec 2022
Sorry for replying so lately, I tried to solve it by myself but failed.

Sign in to comment.

Answers (1)

Areej Varamban Kallan
Areej Varamban Kallan on 19 Jan 2023
Edited: Areej Varamban Kallan on 19 Jan 2023
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

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!