% This script reads in an audio file segment of a phrase about a scare crow % and uses the simarraysigim function to simulate this word spoken over an % array in a room with reverberation. It compares the recordings between % a near and far mic to comare the impact of the room response (the % further the mic from the speaker the more room effects can be heard). % This script requires the programs "simarraysigim.m," "regmicsline.m," % "roomimpres.m," and wave file scare_crow.wav % % Written by Kevin D. Donohue (donohue@engr.uky.edu) July 2005 (updated % June 2008) [y,fs]= wavread('scare_crow.wav'); % Read in sample sound source to simulate % array recording % Reflection coefficients of 4 walls, floor, and ceiling. refcoef = [.90, .90 .90 .90 .2 .4]; % Coordinates of opposite corners of a rectangular room foroom = [-7 -3 -1.24; 1 3 1.24]'; % Set speed of sound in propagation data structure for simarraysig.m prop.c = 348; c = prop.c; % Frequency dependent Attenuation temp = 28; % Temperature centigrade press = 29.92; % pressure inHg hum = 80; % humidity in percent dis = 1; % Distance in meters (normalized to 1 meter) prop.freq = fs/2*[0:100]/100; % Create 100 point frequency axis prop.atten = atmAtten(temp, press, hum, dis, prop.freq); % Attenuation vector % Create mic array, 5 mics (1 meter spacing) on the x-axis (2=y and 0=z) % starting at -5 meters with a spacing of 1 meter in the positive % x direction fom = [-5 2 0; 0 2 0]'; % End coordinates of array mpos = regmicsline(fom,1); % Generate linear microphone array [dimnum, micnum] = size(mpos); % Get number of dimensions and mics % Set signal position near far negative end of array and 1 meter in front of % the array element sigpos = [-5; 1; 0]; % Simulate array recording [sigout, tax] = simarraysigim(y, fs, sigpos, mpos, foroom, refcoef, prop); % Plot the signals received by the first and last mic in array %compute delay between the first and last mic d1 = sqrt(sum((mpos(:,1)-sigpos(:)).^2))/c; dend = sqrt(sum((mpos(:,micnum)-sigpos(:)).^2))/c; delay = dend-d1; % Actual delay based on distances from source figure(1) plot(tax,sigout(:,1), 'r', tax, sigout(:,micnum), 'k') xlabel('seconds') ylabel('signal amplitudes') title(['First mic signal (red) and last mic signal (black) delay of ' num2str(delay*1000) 'millisecs']) % Play sounds at first and last mic without multipath and then at first and last mic % with multpath soundsc([sigout(:,1); sigout(:,micnum)],fs)