How to play 5 different audio signals x1 to x5 with the function audioplayer(x(i),fs,nBits,22)
1 view (last 30 days)
Show older comments
I have a function which generates multiple sweep generator and it looks like this:
function [x, xinv,y_m]=genmesm_far(fs,T,f_start,f_end,A,L1,L2,tau_2) %Multiple exp. Sweepgenerator. x_m = A*sin(W1*siglen_MESM/log(W2/W1).*(exp(((0:siglen_MESM)./siglen_MESM)*log(W2/W1))-1)); %Multiple Sine Sweep
imax=5;
t = delay (imax,e, L1 ,tau_k);
t_max=max(t);
x = zeros(length(x_m)+t_max+fs,imax);
for n = 1:imax
x(:,n) = [zeros(t(n)+fs,1);x_m';zeros(t_max -t(n),1)];
end
x1 = x(:,1);
x2 = x(:,2);
x3 = x(:,3);
x4 = x(:,4);
x5 = x(:,5);
y_m = x1+x2+x3+x4+x5;% Simulated Measurement
y_m=y_m';
I need to play x1 to X5 and record it..I am using digital audio toolbox: The code below looks like this: s = daq.createSession('directsound'); %create session s.DurationInSeconds =7 ; %duration; s.UseStandardSampleRates = true; s.Rate = fs;
devs = daq.getDevices; %list audio devices in system
[ch12, idx12] = addAudioOutputChannel(s,devs(22).ID,1:2); %balancedlineoutput_1&2
[ch34, idx34] = addAudioOutputChannel(s,devs(18).ID,1:2); %balancedlineoutput_3&4
[ch56, idx56] = addAudioOutputChannel(s,devs(15).ID,1:2); %balancedlineoutput_5&6
queueOutputData(s, [x1 x2 x3 x4 x5 x1]);
startBackground(s);
My question is how can I play all these output from x1 to x5 in a loop in the function audioplayer
nBits = 24;
playOBJ = audioplayer(x1,fs,nBits,22);
recOBJ = audiorecorder(fs,nBits,2,-1);
%play(playOBJ);
recordblocking(recOBJ,5.1*length(x1)/fs);
recordedData = getaudiodata(recOBJ, 'double');
recordedData1 = recordedData(:,1);
recordedData2 = recordedData(:,2);
%%<--Play&Record
0 Comments
Answers (0)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!