About Store Forum Documentation Contact



Post Reply 
Help with playing sounds
Author Message
Scarlet Thread Offline
Member

Post: #1
Help with playing sounds
Hi all,

I am having a problem with sound in my game specifically sounds that I need to use over again. I am creating sounds within my 'Gate' object class for opening and closing the gate. I am creating the sounds with Sound::create(UID).

When the gate opens or closes I use Sound::play(), on the appropriate sound to play it. It works the first time but then it cuts out and won't play not matter how many more times I call Sound::play() after the first time.

Any idea what I'm doing wrong? Do I have to create the sound each time I want to use it? I don't want to if I don't have to but if that's the way it works then I guess I will.
02-20-2013 12:17 AM
Find all posts by this user Quote this message in a reply
gwald Offline
Member

Post: #2
RE: Help with playing sounds
Hey

The sound tut has SoundPlay(UID(3284313217, 1120923307, 106803632, 970034379));
To play each sound fx.

But look at sound.h:

Bool CacheSound(C Str &name); // cache sound file into memory so it won't be played every time from the disk, usage of this function is optional, you can call it at some initialization stage of your game, false on fail


Bool CacheSound(C UID &id ); // cache sound file into memory so it won't be played every time from the disk, usage of this function is optional, you can call it at some initialization stage of your game, false on fail

My Blog
http://www.esenthel.com/community/showthread.php?tid=6043

I hang out at Esenthel IRC Channel
http://webchat.freenode.net/?channels=#Esenthel
(This post was last modified: 02-20-2013 12:41 AM by gwald.)
02-20-2013 12:28 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #3
RE: Help with playing sounds
Hmm yeh I saw that it did that in the tutorial but I wasn't happy with loading it every time I wanted to play it.

I'll look into Cacheing it though. That should do the trick. Thanks for the info.

Edit: Cheers it worked perfectly
(This post was last modified: 02-20-2013 09:14 AM by Scarlet Thread.)
02-20-2013 06:53 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: Help with playing sounds
Sound.create does not load the entire sound into memory, it only initializes the sound file path, creates small sound buffer, and then streaming during playing comes from the file.

After sound finishes playing it gets automatically deleted.

As suggested 'CacheSound' does what you intended, however I don't think you should bother with it, unless you're developing for Android, I've developed the function only because on some Android devices with very poor flash disk drives, accessing sound files could cause pauses during the game.
02-20-2013 06:09 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #5
RE: Help with playing sounds
Thanks for the extra info. Good to know. I'll just use it in my Android version of the game.
(This post was last modified: 02-20-2013 11:46 PM by Scarlet Thread.)
02-20-2013 11:45 PM
Find all posts by this user Quote this message in a reply
Post Reply