Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Play Sound Stuck in Playing state

Author
Message
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 15th May 2010 20:14
Hi, guys
bellow is the link from code snippets thread.

http://forum.thegamecreators.com/?m=forum_view&t=170129&b=6

The problem is that if there is many sounds in the playing array while some of them are cleaned if new ones are created something goes wrong and sometimes there is sound stucked in the array that is allready played.It happens when you presist on fast adding sounds.I made some workaround with the force_free function, i capped the max sounds before forcibly delete them all or this can cause in time more sounds to stuck, until nothing is played anymore.

If someone can look at it and give some suggestions what can cause this?

Where there is a will, there is a way.
I often edit my posts, that`s who i am
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th May 2010 21:30
I had a problem using "play music" too... it seems that mps's once they have been played once always show up as playing even after they've been stopped.

I suggest you convert all your sounds/music to "ogg" and load them using "load sound" (it is undocumented but this command will load ogg which is similar compression size to mp3). I use "Audacity" to convert sound files (free and easy to use)...

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 16th May 2010 01:39
But in my case this happens only sometimes.Most of the time playing state is good and sounds plays good.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th May 2010 01:49
Are you saying it's not a problem then?

Cool... if sometimes doesn't bother you then ignore my advice!!

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 16th May 2010 14:18
I just do not understand what is the diference making the sounds ogg`s?

Where there is a will, there is a way.
I often edit my posts, that`s who i am
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th May 2010 18:54
You can load ogg using "Load Sound" instead of "Load Music", the "Sound Playing" command works whereas the "Music Playing" one doesn't...

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 16th May 2010 23:40 Edited at: 17th May 2010 00:32
I`ll try what you said before to check what happens.Do you know why Sound Playing works but Music Playing doesn`t?Is it related to dbpro, or it`s my fault?

EDIT: If i use sounds instead of musics anything i add to play array restart other sounds and they all play at the same time.There is no sounds stucked, but this is irrelevant now.

EDIT2: I managed the problem from EDIT1 with altering the code a bit.Now i use UDT array with custom playing_state and there is no more sound restarts when new sound is added in the array.There is the code:



My next problem is that delete sound command doesn`t free up virtual memory.I load really small sounds, max 3 sec each.Loading them again and again arround 100 times makes used virtual memory arround 100k.What could cause this?Before when i used music commands delete music do the cleaning of vmemory.

Where there is a will, there is a way.
I often edit my posts, that`s who i am
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th May 2010 00:34
Quote: "Is it related to dbpro, or it`s my fault?"

It's a known bug... (not your fault!)

I would suggest you either do the ogg thing or use "timer()" to check when you started playing your mp3 and again to check when the song/sound has finished (you need to know how long the sound clip is) EXAMPLE:

...unchecked

luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 17th May 2010 01:45
Actually i worked with the above code and i think i`ve done it right with using mp3`s.

You can visit the thread in the first post, there is 2 versions now.One for musics, one for sounds.They are the same but 1 load mp3`s and the other ogg`s.

Music version have no longer stuck issue.And on top of this it free up the virtual memory used.So in the end, music version is better, it can be used for musics and sounds.It`s just annoying that it binds you to using of mp3 format.

Thanks about your suggestion with the timer, but i`m not that used to them and i think they aren`t actually needed.You can try the code.I`ll wait for your opinion.

Where there is a will, there is a way.
I often edit my posts, that`s who i am

Login to post a reply

Server time is: 2026-07-25 11:48:50
Your offset time is: 2026-07-25 11:48:50