How can I combine multiple wav files into a single new wav file

I have a folder with six 1-minute wav files. I want to have a script that will combine all wav files in a folder into a new 6-minute wav file. I'm super new at matlab and don't know where to start.

Answers (1)

Use audioread to read them, then vertically concatenate them (assuming they all have the same numbers of channels=columns) using the cat function.

6 Comments

They are all recordings from the same recorder (recorder 1min every ten). Do you have any sample code?
[f1, fs] = audioread(first_file);
f2 = audioread(second_file);
combined = [f1;f2];
sound(combined, fs)
@Walter — Thank you.
Ideally, they all have tthe same sampling frequency (sampling rate) as well.
@Walter - wouldn't this simply play the sound? I need to write it to a new file. Also, this would require me to copy and past in the name of each wav file, making it nearly as much time as using Audacity. I want to give MATLAB a file and tell it to combine all the wav files in that file.
If you need to write the vertically concatenated sounds as a new file, use the audiowrite function.

Sign in to comment.

Asked:

on 10 Sep 2019

Commented:

on 11 Sep 2019

Community Treasure Hunt

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

Start Hunting!