Matlab Coder: Fail to call phased.FrostBeamformer().
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Ji Lee
le 12 Déc 2022
Would you be able to provide the project (PRJ) file associated with this code and error?
Réponses (1)
Areej Varamban Kallan
le 19 Jan 2023
Modifié(e) : Areej Varamban Kallan
le 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
0 commentaires
Voir également
Catégories
En savoir plus sur Communications Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!