How do you concatenate two audio files horizontally? (.WAV)
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
dan bloodworth
am 12 Mär. 2021
Kommentiert: dan bloodworth
am 13 Mär. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 13 Mär. 2021
Bearbeitet: Walter Roberson
am 13 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!