Sound replay without enough buffers

Previous topic - Next topic

erico

So I´m adding sound to this one little game of mine... :) and dosen´t it brings a whole new life into it?

One thing I noticed, is that should I set the buffer on loadsound to 1, if I play it again, it won´t, it will wait untill the sound is over to allow me to play again.

Now coming from AMOS I found that strange (may not be strange to everyone else),
I expected the new playsound command to overide the older and stop it and replay the sound from beguinning.

I have found my ways around this behaviour, and there are many, but I would like to know your opinion on the subject. 

erico

#1
One thing came to my mind now, is it this way so that it easy up calling fast repeated sounds? Like whatever condition thet it is calling sound all the time it will always wait first for it to finish playing? It sounds logical to me now, and an improvement over AMOS :)

Ian Price

There is an optional parameter in the LOADSOUND command that allows multiple sounds to be played simultaneously or at different times - upto four IIRC.

LOADSOUND "sfx.wav", number, max number of simultaneous sounds.

When playing a new sound the old one isn't terminated. I personally like this approach - it could sound strange  if sound just stops halfway through playing, depending on circumstances.

GLBasic's sound system isn't the best for sfx, but at least it's reliable, unlike Blitz3D for example. Could do with some post-processing commands etc. but on the whole it does what I need it to.
I came. I saw. I played.

erico

#3
Thanks, I know about the buffers up to 4. In fact I am using it in a few places.

I kind of like the non-termination way too. It is usefull in many situations I now find.
It is just that I first found it out strange that a command would be called without producing an immediate result.

Thinking about both approaches, I sure prefer the current one.

The sound system is going quite nice and flawless here :)

edit: ops...just found out the caanoo does not enjoy calling same sound over, while on pc/mac it waits the sound to finish, it seems a bit different and strange on caanoo, it is also cutting out other sounds, will check / confirm this later.

Wampus

Quote from: erico on 2013-Mar-08
Now coming from AMOS I found that strange (may not be strange to everyone else),
I expected the new playsound command to overide the older and stop it and replay the sound from beguinning.

As it happens I intend to write a sound routine today that will do that if you set it to a certain mode. It will also loop sounds, have universal sound volume, etc. In theory it will behave the same on different devices because it will have its own way of managing buffers, channels and checking sound play length, etc. If you're interested I'll post the code here when its done. I promise it'll be easy to use with an example proggy given and some adequate documentation of how to use.

mentalthink

Wampus this will be fantastic... I think a lot of times in make a library for fx like reverbs echos and this things... but I think this not it's standard in all platforms... but SDL, can't do this?¿...

Wampus

As far as I know those sorts of fx aren't supported by SDL. I would love stuff like that.

I was planning on using the standard GLBasic sound commands but in encapsulating them in code to handle loading and playing in a different way. The idea is to allow more options for handling sound effects.

erico

#7
Really nice Wampus!

I just got back home/base, so work on the game will continue.
I´m not sure there is time to add anything to it, but sure will be nice on next project :good:

I sure would like to see it when you have it. Thanks for the offer! :)

Wampus

#8
Ok, I'll post it. I'll just tidy it up a little first.

EDIT: Its up. Click here to go to the thread in CodeSnippets.