Play 2 wav files after each other
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to play 2 files after each other.
However, I tried multiple things and it either plays the two files simultaniously or the second file does not get played at all.
This is th ecode I tried:
[y1, Fs1] = audioread('file1.wav'); %this file is 5 seconds long
[y2, Fs2] = audioread('file2.wav'); %this file is 1.6 seconds long
player = audioplayer(y1, Fs1);
player2 = audioplayer(y2, Fs2);
play(player);
pause(2);
play(player2);
Like this they just play simultaniously, without a time difference of 2 seconds.
File2 does not get played 2 seconds later than file1.
Can anyone help me with this?
0 comentarios
Respuestas (1)
Star Strider
el 19 de Feb. de 2020
[y1, Fs1] = audioread('file1.wav'); %this file is 5 seconds long
[y2, Fs2] = audioread('file2.wav'); %this file is 1.6 seconds long
player = audioplayer(y1, Fs1);
player2 = audioplayer(y2, Fs2);
playblocking(player);
playblocking(player2);
2 comentarios
Star Strider
el 19 de Feb. de 2020
My pleasure.
You did not mention the 2 second delay. I thought you were pausing after the first one to let it finish, and not allowing enough time.
Try this:
playblocking(player);
pause(2)
playblocking(player2);
That worked when I ran it.
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!