How do you concatenate two audio files horizontally? (.WAV)
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
dan bloodworth
il 12 Mar 2021
Commentato: dan bloodworth
il 13 Mar 2021
I'm trying to merge two .WAV files together so that they can be played at the same time.
The problem is they may be of different frequencies as one may be a voice recording. I've learnt how to concat vertically but require some insight into the process of concatenating two separate audios horizontally.
Any help would be appreciated.
0 Commenti
Risposta accettata
Walter Roberson
il 13 Mar 2021
Modificato: Walter Roberson
il 13 Mar 2021
[wav1, Fs1] = audioread('RockGuitar.wav');
[wav2, Fs2] = audioread('guitartune.wav');
maxFs = max(Fs1, Fs2);
rs1 = resample(wav1, maxFs, Fs1);
rs2 = resample(wav2, maxFs, Fs2);
maxlength = max(size(rs1,1), size(rs2,1));
rs1(end+1:maxlength,:) = 0;
rs2(end+1:maxlength,:) = 0;
horizontal_wav = [rs1, rs2];
size(horizontal_wav)
p = audioplayer(horizontal_wav(:,end-1:end), maxFs);
play(p)
You are going to need more work to be able to play the 3 or 4 channels simultaneously. Note that the channels have not been processed for Dolby Surround or Dolby DTS, but you could use them for front and back speakers, for example.
Remember to pay attention to the fact you are not promised that they are all the same number of channels, so horizontal concatenation like you asked for loses the boundaries between which channel came from which sound.
... And you did not ask to play them as separate stereo channels, and you did not ask that the respective channels be mixed together.
5 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Audio I/O and Waveform Generation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!