How to play and merge/mix 2 wav files
29 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Walter Roberson
on 29 Nov 2016
Please review http://www.mathworks.com/matlabcentral/answers/313351-how-can-i-merge-two-audio-files-mp3-wav-to-be-able-to-hear-them-playing-both-together-in-the-same for information on merging sounds.
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 Comments
Walter Roberson
on 29 Nov 2016
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
on 30 Nov 2016
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?
More 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!