How can I merge two audio files(MP3/WAV), to be able to hear them playing both together in the same time and in the right and left side of the headphones?

3 views (last 30 days)
How can I merge two audio files, to be able to hear them playing both together in the same time and in the right and left sides of the headphones? I'm not sure I think it's called vertical Join or so?
-Note: I'm using playeraudio() on guide.

Accepted Answer

Image Analyst
Image Analyst on 21 Nov 2016
Edited: Image Analyst on 21 Nov 2016
If they are the same sampling frequency, can't you just average the two signals and play it?
Or did you want to hear one signal in the left side and the other in the right side? If so, just average the channels in each signal to produce a monochrome signal, then assign one mono signal to the first row of the sound matrix and the other mono signal to the second row of the sound matrix.
  7 Comments
Walter Roberson
Walter Roberson on 28 Nov 2016
One of those two, ySound or yHandel, is a row vector and the other is a column vector. You want both of them to be column vectors.
Also, pay attention to the number of channels in the data.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 22 Nov 2016
If they are both stereo, then
newdata = (data1 + data2)/2;
and play newdata.
If they are both mono and you want to hear one on the left and one on the right, then
newdata = [OneToPutOnLeft, OneToPutOnRight];
and play newdata.

Products

Community Treasure Hunt

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

Start Hunting!