Skip to main content
Removed screenshot of code and added actual code.
Source Link
jojeck
  • 11.2k
  • 6
  • 38
  • 75

I have a play function that is called twice, each plays a channel (a column of the two dimensional array) in both speakers. What I am trying to do is to play both channel at the same time. How do I silence a channel and set the the elements in the corresponding column to 0. I also need an output array that im trying to make look like this when the data is output into it. The code is in the link below. 1 0 2 0 1 0 0 4 0 1 0 1

Sound Code

Fs = 44100;
N = 400
t = (1:N)*(1/Fs);
freq = 600;

sound_array = zeros(N,2);
%starts N x 2 matrix
sound_array(:,1) = sin(2*pi*freq*t);
sound_array(:,2) = sin(2*pi*freq*t);

%Sound 1 
sound(sound_array(:,1), Fs);
%Sound 2
sound(sound_array(:,2), Fs);
%Play Consecutive
sound(sound_array, Fs);

I have a play function that is called twice, each plays a channel (a column of the two dimensional array) in both speakers. What I am trying to do is to play both channel at the same time. How do I silence a channel and set the the elements in the corresponding column to 0. I also need an output array that im trying to make look like this when the data is output into it. The code is in the link below. 1 0 2 0 1 0 0 4 0 1 0 1

Sound Code

I have a play function that is called twice, each plays a channel (a column of the two dimensional array) in both speakers. What I am trying to do is to play both channel at the same time. How do I silence a channel and set the the elements in the corresponding column to 0. I also need an output array that im trying to make look like this when the data is output into it. The code is in the link below. 1 0 2 0 1 0 0 4 0 1 0 1

Fs = 44100;
N = 400
t = (1:N)*(1/Fs);
freq = 600;

sound_array = zeros(N,2);
%starts N x 2 matrix
sound_array(:,1) = sin(2*pi*freq*t);
sound_array(:,2) = sin(2*pi*freq*t);

%Sound 1 
sound(sound_array(:,1), Fs);
%Sound 2
sound(sound_array(:,2), Fs);
%Play Consecutive
sound(sound_array, Fs);
Source Link
Asau7610
  • 61
  • 1
  • 10

Playing sound in left and right speaker alternatively and storing output in array in matlab

I have a play function that is called twice, each plays a channel (a column of the two dimensional array) in both speakers. What I am trying to do is to play both channel at the same time. How do I silence a channel and set the the elements in the corresponding column to 0. I also need an output array that im trying to make look like this when the data is output into it. The code is in the link below. 1 0 2 0 1 0 0 4 0 1 0 1

Sound Code