Acoustic Beamforming Using a Rectangular Microphone Array

Using the Mathworks example:
I am reproducing this code using a rectangular 4x4 array rather than the linear array. I am in the header: Simulate the Received Signals
i am only using one audio signal x1 how do i use the step function?
i tried
temp=step(hCollector, x1,ang_dft+sqrt(noisePwr)*rand(rs,NSamPerFrame,[4
4]));
The error I received is:
Warning: Input arguments must be scalar.
Error using +
Matrix dimensions must agree.
Error in file (line 47)
temp=step(hCollector, x1,ang_dft+sqrt(noisePwr)*rand(rs,NSamPerFrame,[4
4]));
how do i correctly execute this?
here is my code:
H = phased.OmnidirectionalMicrophoneElement('BackBaffled',true)
fc=[200 300 400]
ang = [0;0];
resp=step(H,fc,ang);
plotResponse(H,200,'RespCut','Az','Format','Polar')
ha = phased.URA([4 4],[0.00635 0.00635],'Element',H)
figure;
plotResponse(ha,200,340,'RespCut','3D','Format','Polar')
%---------------------
ang_dft = [-10,10]
fs= 8000
hCollector = phased.WidebandCollector('Sensor',ha,'PropagationSpeed',340,'SampleRate',fs,'ModulatedInput',false);
t_duration = 3;
t=0:1/fs:t_duration/fs;
rs= RandStream.create('mt19937ar','Seed',2008)
noisePwr = 1e-4
%preallocate
NSamPerFrame =1000
NTSample = t_duration*fs
sigArray = zeros(NTSample,[4 4])
voice_dft= zeros(NTSample,1)
%set audio player
isAudioSupported = audiodevinfo(0)
if isAudioSupported
hap = dsp.AudioPlayer('SampleRate',fs)
end
%simulate
for m=1:NSamPerFrame:NTSample
sig_idx=m:m+NSamPerFrame-1
x1=wavread('dft_voice_8kHz',[sig_idx(1) sig_idx(end)])
temp=step(hCollector, x1,ang_dft+sqrt(noisePwr)*rand(rs,NSamPerFrame,[4 4]));
if isAudioSupported
step(hap,temp(:,3));
end
sigArray(sig_idx,:)=temp;
voice_dft(sig_idx)=x1;
end
plot(t,sigArrary(:,3));

1 件のコメント

Nick Yiw
Nick Yiw 2019 年 3 月 18 日
Hi, I am a student currently working on a project that involves distance speech recognition for controlling output. I really want to know what are the best recommendations of microphone arrays/chips that I can use which are compatible with MATLAB. Thank you.

サインインしてコメントする。

 採用された回答

Honglei Chen
Honglei Chen 2013 年 3 月 7 日

1 投票

The error is because you are adding noise to the angle. I believe it's a typo. That line should just reads like this
temp=step(hCollector, x1,ang_dft)+sqrt(noisePwr)*rand(rs,NSamPerFrame,16);
Also, in the earlier part of the script, where you instantiate sigArray, it should be
sigArray = zeros(NTSample,16);
HTH

3 件のコメント

Osheen
Osheen 2013 年 3 月 10 日
Hello Honglei, Thank you for your response. I am wondering is it possible use a frost beamformer on a signal that has been Time Delay beamformed? I am still using the following Mathworks example:
Below is my code and you can see I have made some adjustments based on the tutorial. This is error I received:
Error using phased.TimeDelayBeamformer/step
Too many input arguments; expected 1 (in
addition to the object handle), got 3.
Error in timefrost (line 83)
temp =
step(hbf,hbf2,step(hsig),ang_dft);
----------------------------------------------------------------
H = phased.OmnidirectionalMicrophoneElement('BackBaffled',false)
fc=[200 300 400]
ang = [0;0];
resp=step(H,fc,ang);
plotResponse(H,200,'RespCut','Az','Format','Polar')
ha = phased.URA([4 4],[0.00635 0.00635],'Element',H)
c = 340;
figure;
plotResponse(ha,200,340,'RespCut','3D','Format','Polar')
%---------------------
ang_dft = [-30;0]
ang_cleanspeech = [-10;10]
ang_laughter = [20;0]
fs= 8000
hCollector = phased.WidebandCollector('Sensor',ha,'PropagationSpeed',340,'SampleRate',fs,'ModulatedInput',false);
t_duration = 3;
t=0:1/fs:t_duration-1/fs;
rs= RandStream.create('mt19937ar','Seed',2008)
noisePwr = 1e-4
%preallocate
NSamPerFrame =1000
NTSample = t_duration*fs
sigArray = zeros(NTSample,16);
voice_dft= zeros(NTSample,1);
voice_cleanspeech = zeros(NTSample,1);
voice_laugh = zeros(NTSample,1);
%set audio player
isAudioSupported = audiodevinfo(0);
if isAudioSupported
hap = dsp.AudioPlayer('SampleRate',fs)
end
%simulate
for m=1:NSamPerFrame:NTSample
sig_idx=m:m+NSamPerFrame-1
x1 = wavread('dft_voice_8kHz',[sig_idx(1) sig_idx(end)]);
x2 = wavread('cleanspeech_voice_8kHz',[sig_idx(1) sig_idx(end)]);
x3 = 2*wavread('laughter_8kHz',[sig_idx(1) sig_idx(end)])
temp=step(hCollector,[x1 x2 x3],[ang_dft ang_cleanspeech ang_laughter])+sqrt(noisePwr)*rand(rs,NSamPerFrame,16);
if isAudioSupported
step(hap,temp(:,1));
end
sigArray(sig_idx,:)=temp;
voice_dft(sig_idx)=x1;
voice_cleanspeech(sig_idx) = x2;
voice_laugh(sig_idx) = x3;
end
figure;
plot(t,sigArray(:,3));
xlabel('Time (sec)'); ylabel('Amplitude (v)');
title('Signal Received at Channel 3'); ylim([-3 3]);
%Process with a time Delay Beamformer
angSteer = ang_dft;
hbf = phased.TimeDelayBeamformer('SensorArray',ha,'SampleRate',fs,'Direction',angSteer,'PropagationSpeed',c)
hbf2 = phased.FrostBeamformer('SensorArray',ha,'SampleRate',fs,'PropagationSpeed',c,'FilterLength',20,'DirectionSource','Input port');
hsig = dsp.SignalReader('Signal',sigArray,'SamplesPerFrame',NSamPerFrame);
cbfOut = zeros(NTSample,1);
for m= 1:NSamPerFrame:NTSample
temp = step(hbf,hbf2,step(hsig),ang_dft);
if isAudioSupported
step(hap,temp);
end
cbfOut(m:m+NSamPerFrame-1,:) = temp;
end
figure
plot(t,cbfOut);
xlabel('Time (sec)'); ylabel('Amplitude (V)');
title('Time Delay Beamformer Output');ylim([-3,3]);
Honglei Chen
Honglei Chen 2013 年 3 月 11 日
Hi OSheen,
The first step of a Frost beamformer is time delay steering so there is no need to add a time delay beamformer in front of Frost beamformer.
As to the error you saw, it is because in your configuration, the steering angle for the time delay beamformer is specified in the property of 'Direction'. Therefore, the syntax for performing time delay beamforming is
y = step(hbf,x)
If you really want to add a Frost beamformer afterwards, what you need to do is passing the y into the Fromst beamformer, e.g.
y2 = step(hbf2,y,ang_dft)
HTH
Osheen
Osheen 2013 年 3 月 12 日
Thank you for your helpful response.
How would I apply the Frost beamformer on REAL data collected from a 4x4 microphone array? Also what is the best way to determine the FIR filter length of the beamformer?
Here is some code I have written so far to apply on real collected data. Please let me know if I am missing something
data = getdata(ai)
hmic=phased.OmnidirectionalMicrophoneElement;
ha=phased.URA([4 4],[0.0635 0.0635],'Element',hmic);
hsig=dsp.SignalReader('Signal',data,'SamplesPerFrame',NSampPerFrame);
frost=phased.FrostBeamformer('SensorArray',ha,'SampleRate',Fs,...
'PropagationSpeed',c,'FilterLength',100,'DirectionSource','Input port');
frostout=zeros(NTSample,1);
for m=1:NSampPerFrame:nt
frostout(m:m+NSampPerFrame-1,:)=step(frost,step(hsig),angSteer);
end
soundsc(frostout,Fs,16)
wavwrite(frostout,'Frostbeamformed real data');
plot(t,frostout);
xlabel('Time (sec)'); ylabel ('Amplitude (V)');
title('Frost Beamformer Output');

サインインしてコメントする。

その他の回答 (1 件)

Zeynep Ertekin
Zeynep Ertekin 2017 年 1 月 22 日

0 投票

Hi,
I need a 2d or 3d sound source localization code with command load; can anyone please help me. Any help will be highly apprecited.

質問済み:

2013 年 3 月 6 日

コメント済み:

2019 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by