Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Joining WAV files together in Matlab

910 views
Skip to first unread message

Bill Smith

unread,
Apr 12, 2003, 12:07:43 PM4/12/03
to
Hi,


We have a requirement to manipulate audio, specifically WAV files in
Matlab.


The idea is to allow the user to select all or part of a file and
only play that particular section of the file. Being a complete
newbie to matlab, I have absolutely no idea on how to go about this
and would appreciate any assistance, URL links or code examples that
would help with this.


I'm currently at the stage where I can read in and write new files
with the wavread/wavwrite commands.


Cheers


B.Smith

RM

unread,
Apr 12, 2003, 12:20:09 PM4/12/03
to
Hi Bill,


You can join wav files together using square brackets.


try the following code: (file 1 and file 2 should be the same sample
rate and bit depth)


[y1,fs,bits] = wavread('file1.wav');
[y2] = wavread('file2.wav');
y3 = [y1; y2];


% To Listen:
sound(y3,fs);


% To Write to WAV:
wavwrite(y3,fs,bits,'file3.wav');

Bill Smith

unread,
Apr 12, 2003, 12:24:16 PM4/12/03
to


Thanks for the info. I guess my major problem is that I need to able
to 'insert' one wav file inside of the other one - it isn't simply a
case of joining them together. For example, if I'm using the standard
windows soundset - tada.wav and chord.wav, I would need to be able to
play the 'ta <insert chordhere> da'


Again, any help appreciated and thanks for your input so far.

RM

unread,
Apr 12, 2003, 12:51:25 PM4/12/03
to
> Thanks for the info. I guess my major problem is that I need to able
> to 'insert' one wav file inside of the other one - it isn't simply
a
> case of joining them together. For example, if I'm using the
standard
> windows soundset - tada.wav and chord.wav, I would need to be able
to
> play the 'ta <insert chordhere> da'
>
> Again, any help appreciated and thanks for your input so far.
>


Ok, no problem - you can read specific sections of a wave file into
matlab using:


wavread('filename',[1 5000]);


where the values in the square brackets indicate the start and end
samples you want to extract.


Alternatively if you read the entire wav file into matlab you can do
the same thing:


[y1,fs,bits] = wavread('file1.wav');

[y2,fs,bits] = wavread('file2.wav');


% Extract first 500 samples from y1,
% Then attach y2,
% Then extract the remaining samples
% ans stick them on the end.
y3 = [y1(1:500,:); y2; y1(501:end)];


wavwrite(y,fs,bits,'file3.wav');

Bill Smith

unread,
Apr 12, 2003, 1:08:40 PM4/12/03
to
> Ok, no problem - you can read specific sections of a wave file into
> matlab using:
>
> wavread('filename',[1 5000]);
>
> where the values in the square brackets indicate the start and end
> samples you want to extract.
>
> Alternatively if you read the entire wav file into matlab you can
do
> the same thing:
>
> [y1,fs,bits] = wavread('file1.wav');
> [y2,fs,bits] = wavread('file2.wav');
>
> % Extract first 500 samples from y1,
> % Then attach y2,
> % Then extract the remaining samples
> % ans stick them on the end.
> y3 = [y1(1:500,:); y2; y1(501:end)];
>
> wavwrite(y,fs,bits,'file3.wav');
>


Nice one Rich.

Praveen

unread,
Nov 7, 2012, 6:48:07 AM11/7/12
to
Hi,
i want to concatenate multiple(100) wave files using single wavread command....and play it in matlab.... help me out... i think it should be done using for loop... but not able to execute....?/

Thank you











"Bill Smith" <billsm...@hotmail.com> wrote in message <eebc5...@WebX.raydaftYaTP>...

LightBreeze

unread,
Dec 23, 2014, 2:15:17 AM12/23/14
to
You may also refer to the step by step guide to join wav files on Mac or Windows at http://www.idealshare.net/audio-joiner-for-mac-windows.html

This guide can merge almost all kinds of audio files like merge MP3, merge WAV, merge M4A, merge FLAC, merge AAC, merge AC3, merge OGG, merge WMA, merge Apple Lossless, AIFF, AU, RA, CAF, APE, AMR, QCP, AWB, DTS, 3GA, VOC, M4R, M4B, and etc

"Bill Smith" <billsm...@hotmail.com> wrote in message <eebc5...@WebX.raydaftYaTP>...

timmdd pan

unread,
Oct 28, 2015, 3:14:10 AM10/28/15
to
use some video editor to merge the multiple files together..no matter the audio or video.
The steps are often like this:
1, Add Files to the converter software, and you can edit them first to clip the segments you don’t want.
2, Use the “Merge” option.
3, Run the software
hope this article could help you some:
http://www.videoconverterfactory.com/tips/merge-videos.html

1143...@students.liu.edu.lb

unread,
Mar 7, 2018, 11:58:35 AM3/7/18
to
i want to mix to audio
this the code :
clear all
close all
clc
[x,fs] = audioread('sound.wav'); % hayda lezim ykoun 3endak 7a eb3atlak code tene la ta3emlo la hayda lfile bte7ke fa byetsayav
T = length(x)./fs; % time in seconds
t2=length(x);
n=0;
filename= 'sound1.wav';
filename1='sound2.wav';
Fs1=fs/1.25;
Fs2=fs*1.25;
disp(T);
disp(t2);
half = ceil(t2/2);
s1 = x(1:half);
s2 = x(half + 1 : end);
disp(length(s1));
disp(length(s2));
while n < T
if n < T/2
audiowrite(filename, s1,Fs1);
disp(n);
end
if n >T/2
audiowrite(filename1, s2,Fs2);
disp(n);
end
n=n+1;
end
0 new messages