How to play and merge/mix 2 wav files

조회 수: 4 (최근 30일)
AM
AM 2016년 11월 28일
편집: AM 2016년 12월 7일
Hi,
Basically I want to merge the two wav files so that both music or voice annotates and play the a sound(i.e., you can hear both the voice and the music), and than save as a new wav file.
I am thinking of creating a merge/play button, but I do not know how to go about it. Any help would be much appreciated. Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2016년 11월 29일
With regards to a Merge/Play button: create the button ahead of time in GUIDE, but set the default properties for it as 'Visible', 'off' . Then, in your code, as soon as you have verified that you have both inputs so the conditions are right for allowing merging, set the button 'Visible' property to 'on'.
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 11월 29일
You should not use two audio players at the same time, as you have little control over synchronizing them. If your input is at two different sampling frequencies then you should resample() the lower rate one to a higher rate.
nrow = max(size(data1, 1), size(data2, 1));
out = zeros(nrow, 2);
out(1 : size(data1, 1), 1) = data1(:,1);
out(1 : size(data2, 1), 2) = data2(:,1);
now you can play out and the two will appear on left and right ear.
Walter Roberson
Walter Roberson 2016년 11월 30일
Please post your current version.
Are you input sounds mono or stereo?
Are they to be played one on the left channel and one on the right channel, or are they to be averaged together?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by