Can Multiple Sound Files Be Played At The Same Time?

TextingStories
Thanks for those with the help of telling me where to and how to look for sound files, I have tried different rooms and I am quite pleased with what I have found and have done so far. However, at least from using freesounds.org anyway, although they have many sounds, not all is what I am looking for or need. But with that already in mind, I had downloaded different sounds to use.

My plan was to play two or three or even more sound files at the same time so that they over lap and thus create the “ambiance” of what I need, but that is not working. At least when using the built in Quest features, I can start a sound when entering a room and loop it and I can of course stop the sound (Hehehe... did not realize I had to do that manually the first time...), but I can not add two or more sound files to play simultaneously. Or I should say I can not hear two or more sound files at the same time. Why is that?

I think I read the answer some where, not sure where, I even did a search for it, but could not find it again. I want to say someone said that Quest can only play one sound file at a time. Is there a way to force a change either by code or some thing else? I stack three scripts of entering room play sound, but only one (I want to say the last one, or maybe it was the first, definitely the one in the middle did not play.) sound file played.

Can Quest play more than one sound file at a time or am I going to have to take the sounds I have and edit them myself so they become “one” sound file and then I can use it? And if that is the case, any idea how I am suppose to do that. I have no editing skills sadly. Thanks.

Pertex
I don't use sounds in my game so I can't say much about it. But if you tried to play more than one sound simultaneously and it's not working, then it's not supported by Quest :D In my opinion this is a minor problem. Sound does not make a game better, but no sound does not make a good game worse.

Alex
Yes you can only play one sound at a time. Most people play Quest games via their web browser, and HTML5 audio support is fairly limited at the moment, so this is a restriction that won't change very soon.

In the meantime, you could use free software such as Audacity to mix sounds together.

Krammy
2014 and still no multi-sound support. I kind of need this right now so I can play sound effects over my music.

This would be a great feature to add. What's stopping you from adding this?

Pertex
Krammy wrote:What's stopping you from adding this?


Money? Time? But you can order this new feature:
"Developing a small feature - every Quest release brings something new, and developing features takes time. You can contribute £150 towards the cost of developing a feature for the next release. "
By the way, I don't think this would be a small feature, perhaps it will be a bit more expensive

Krammy
I appreciate the reply. Maybe I'll go ahead and suggest it then.

george
I think it might be easier to use a JS audio lib to play the sounds, and just call into the JS lib from Quest. However I haven't done any research into this yet.

Silver
I've hit upon this now too. Even just a limit of two sounds would be better so you can have a background ambience and then the current action sound triggered over the top of it. Action sounds without ambience will sound well odd so might just have to stick with a back ground track that changes with mood if there's no solution to this.

If a two track solution could be introduced it would have to have a priority system. So you could set a sound to be either foreground or background so if there was a clash with a third sound it would cancel out the other foreground sound and not the background one.

Pertex
Oh, you can play more than one audiofile at the same time but only when playing online with an actual browser. You only must use the html5 tag audio. It is not working with the offline player of quest, the internal chrome browser seems to be to old to support this tag. Perhaps ALex finds time to replace the old chrome engine?

TextStories
I prefer to play my games off line myself. Although I have not had a need to play more than one sound at a time in my game, plus it gives it a little charm when it does. However, having more than one sound would be a nice feature as well eventually.

Silver
Pertex wrote:Oh, you can play more than one audiofile at the same time but only when playing online with an actual browser. You only must use the html5 tag audio.


Can you explain that please? I just tested in online mode and had the same issue with multiple samples. I think I have a solution anyway in that I won't make my ambient track constant so it can be run with timers instead. That would also solve the looping problems: on my first test it played once and then gave up the fight, on my second the loop worked as it should but it has an annoying click between loops (not a problem at my end as it sounds seemless in my DAW). I accept that a lot of these issues may be beyond Alex's control and are browser issues.

Pertex
I am working with external servers so first I uploaded soundfiles on an external server. With the start script of game I am loading these files with
loadMusic ("sound1","http://www.test.org/forest.wav", "")


  <function name="loadMusic" parameters="id, url, url2"><![CDATA[
text="<audio id='"+ id +"'><source src='"+url +"' />"
if (LengthOf(url2)>0){
text = text + "<source src='" + url2 +"' />"
}
text = text + "</audio>"
msg(text)

]]></function>


Then I have two functions to start and stop playing the file: playMusic ("sound1") and stopMusic ("sound1")
  <function name="playMusic" parameters="id">
JS.playMusic (id)
</function>
<function name="stopMusic" parameters="id">
JS.stopMusic (id)
</function>


And here are the Javascript functions:

function playMusic(id) {
document.getElementById(id).play();
}

function stopMusic(id) {
document.getElementById(id).pause();
}


You can test it here with my test game: http://play.textadventures.co.uk/Play.a ... omchphqmyw

Silver
Cheers. I'll *try* to get my head round it. :D

Do the sounds have to be external then or can they be called from the game directory?

I'll probably have many more questions.

Pertex
Silver wrote:Do the sounds have to be external then or can they be called from the game directory?


Uuuh, good question, I can't say that at the moment. It was some time ago when I experimented with it

Silver
Pertex wrote:

"Krammy"

What's stopping you from adding this?



Money? Time? But you can order this new feature:
"Developing a small feature - every Quest release brings something new, and developing features takes time. You can contribute £150 towards the cost of developing a feature for the next release. "



That option has been nuked from orbit it seems.

www.textadventures.co.uk/quest/gift

Silver
Pertex wrote:I am working with external servers so first I uploaded soundfiles on an external server. With the start script of game I am loading these files with
loadMusic ("sound1","http://www.test.org/forest.wav", "")


  <function name="loadMusic" parameters="id, url, url2"><![CDATA[
text="<audio id='"+ id +"'><source src='"+url +"' />"
if (LengthOf(url2)>0){
text = text + "<source src='" + url2 +"' />"
}
text = text + "</audio>"
msg(text)

]]></function>


Then I have two functions to start and stop playing the file: playMusic ("sound1") and stopMusic ("sound1")
  <function name="playMusic" parameters="id">
JS.playMusic (id)
</function>
<function name="stopMusic" parameters="id">
JS.stopMusic (id)
</function>


And here are the Javascript functions:

function playMusic(id) {
document.getElementById(id).play();
}

function stopMusic(id) {
document.getElementById(id).pause();
}


You can test it here with my test game: http://play.textadventures.co.uk/Play.a ... omchphqmyw


That's brilliant. It works! It didn't on my tablet using Safari but did with Chrome on my desktop.

Now I just have to work out how to put that in my game in the completely different context of auto-playing upon certain actions. :D

I've watched a few youtube vids on html5 but all I've managed to do is get the controls to appear but not the sound. Unfortunately it's the opposite that I want. Maybe if I write the code backwards?

Silver
Krammy wrote:I appreciate the reply. Maybe I'll go ahead and suggest it then.


There's a sort of solution to this now thanks to the masterful Jay. You can play your background noises using the existing Quest method with loops and stops etc and script in foreground sounds using html 5. You might want a primer on html5: not all browsers support .mp3 for instance and mobile browsers don't support autoplay. This is a reasonably good series of vids on the basics of audio and video in html5:

1) https://www.youtube.com/watch?v=HZt32u4WysA
2) https://www.youtube.com/watch?v=A7lAjtRGEKI
3) https://www.youtube.com/watch?v=splzDvU8qG0
4) https://www.youtube.com/watch?v=pO4nAPmVbtQ

The solution is in this post but You might want to scroll up a post or two to see the problem presented:

viewtopic.php?f=3&t=4632&p=30519#p30519

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums