Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » play two consecutive sounds?

Credits go to MikiZX for helping out!
This thread is locked; no one can reply to it. rss feed Print
play two consecutive sounds?
maurus
Member #17,112
August 2019

Hi guys, I'm new here.
I thank you for allowing me to enter.

Today as my first publication I come with a little doubt of a code that I am trying to create with the reproduction of wavs files.

My question is this:
When I make a sound play, how can I tell the program to rebise that this first sound finishes playing to play a second sound?
because the sounds always play at the same time.

I forgot to tell you that I use allegro version 4.2.3 with visual c ++, the code for version five was very complicated for me.

that is all,
From already thank you very much,

Greetings.

Edgar Reynaldo
Member #8,592
May 2007
avatar

You can use allocate_voice to play a sample, and then check voice_get_position against -1 to see when it finishes. Poll for it.

maurus
Member #17,112
August 2019

OK, thank you very much for responding.
I was looking at those two commands, but I don't understand how they are written.
first,
allocate_voice
From what I understand it is not that it serves to have an audio in a channel but not to play it?
and to use this,
voice_get_position
I wouldn't have to use load_sample so that I know what audio it is?

could you please give me a small example of how it is used?
I have always used the play_sound command, and I thought that with the identifier that was returned it could be done, but I did not get it.

MikiZX
Member #17,092
June 2019

Possibly this can help you:
https://www.allegro.cc/forums/thread/586049

I don't use Allegro4 so not really my place to be posting here but you can always check the documentation - that is how I found the above link.

Also, the documentation is what makes me say the following (so please take it with a grain of salt):
'allocate_voice' and 'play_sample' both return a voice number (think of the voice number as an identifier of an available sample playback slot in the audio mixer - there can be many voices(slots) available). If you are using 'allocate_voice' then you would start the playback of that voice using 'voice_start' function.
Use the 'voice_get_position' (for more control) or just 'voice_check' to have some information regarding the audio playback of your sample.

Again, I don't use Allegro 4 so this post is done just in hope it can help you figure out the system on your own.

maurus
Member #17,112
August 2019

Fantastic companion, I have succeeded.
Thank you very much for answering, it was very helpful.
It wasn't as complicated as I imagined, spending a little time it worked.

thanks again,
Greetings.

Go to: