Matlab Coder: Fail to call phased.FrostBeamformer().
2 ビュー (過去 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!