how can I merge to wav files with a pause of 3 seconds between them?

Illustration
Dominiek Goemaere - 2024-03-19T21:54:25+00:00
Question: how can I merge to wav files with a pause of 3 seconds between them?

i want to merge 2 wav-files but i need a pause of 3 seconds between them. How can I do that?  

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

Supposing that the samples are in wav1 and wav2 and that the respective sampling frequencies are fs1 and fs2, then
 
merged_fs = max(fs1, fs2);
merged_wav = [reshape(wav1, fs1, merged_fs); zeros(merged_fs * 3, size(wav1, 2); reshape(wav2, fs2, merged_fs)];

This can be made simpler if the two are the same sampling frequency, fs

merged_wav = [wav1; zeros(fs * 3, size(wav1, 2)); wav2];

Note: this code expects that the wav files have the same number of channels.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!