concatenate audio files in simulink

How can I concatenate 2 or more audio (.wav) sounds into one?

 Accepted Answer

jibrahim
jibrahim on 3 Apr 2020
Hi Katarina,
Use two 'From Multimedia File' blocks to read the wav files.
There are multiple ways of concatenating two signals in simulink.For example:

5 Comments

I tried you suggestion. However, when I use the concatinate block, I get the two sounds playing at the same time. Instead, I want them to play one after the other. For example, the first audio plays "My name is" and the second plays "Mike", such that when you combine them the output is "my name is Mike".
Make sure you concatenate along the correct dimension.
Audio files show up as 2D arrays in which each column is an audio channel. In the case that you have two audio files each of which has one channel, then if you concatenate along the second dimension (equivalent of horzcat()) then you would end up with a 2D array with two channels, giving the effect of playing one of the files on the left channel and the other on the right channel.
Is there a way to detect the end of one audio and use it as a trigger to intiate the next ?
Output end-of-file indicator
Use this check box to determine whether the output is the last video frame or audio sample in the multimedia file. When you select this check box, a Boolean output port labeled EOF appears on the block. The output from the EOF port defaults to 1 when the last video frame or audio sample is output from the block. Otherwise, the output from the EOF port defaults to 0.
Right now I am able to get it to work by triggering the two audio files to be on/off using a constant pulse. This works only if the messages are constant duration. However if the messagase are of variable duratio, I don't know how to detect that the first message has ended.

Sign in to comment.

More Answers (1)

Hi Walter, if I play one on the left channel and one on the right, wouldn't they still be playing at the same time instead of one after the other?

1 Comment

Yes. My explanation was for how it happened that they were playing at the same time. The cure is to ensure that you concatenate on the first dimension instead of the second.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!