Matlab Coder: Fail to call phased.FrostBeamformer().
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
2022-12-12
Would you be able to provide the project (PRJ) file associated with this code and error?
回答(1 个)
Areej Varamban Kallan
2023-1-19
编辑: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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Communications Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!