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 / How does DB sound work behind the scenes?

Author
Message
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 30th May 2012 15:12
Does anyone know how DBP sound mixing happens behind the scenes? Traditionally, I have always tried to limit the number of simultaneous sounds I play for performance reasons. I generally have all my sound loaded, and then a pool of sound numbers (say 16). I then clone sound into that pool, play them and delete them, so I can control how many sounds are playing simultaneously.

I'm looking at sound now and wondering if that's necessary. Can I just play as many simultaneous sounds as I like, and let DBP handle it, mixing the sounds as appropriate and not affecting performance. The process of me cloning/deleting sounds myself has an overhead that it'd be good to minimize.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 30th May 2012 16:29 Edited at: 30th May 2012 16:31
As far as I'm aware all sound is controlled by the hardware, including mixing and there's only a very smidging (practically zero) overhead. Most sound devices nowadays can handle 128 channels. So my guess is that the only overhead is your own code.

EDIT: Obviously mp3's have to be decoded and other formats like mod, ogg, etc also do too but a standard wav format is native to audio hardware.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th May 2012 21:29 Edited at: 30th May 2012 21:29
There is still the small overhead of copying the sound data to the buffers accessed by the hardware. I didn't think that cloning and deleting sounds had much of an overhead since the actual sound data is not copied.

[b]
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 30th May 2012 22:16
Thanks for your thoughts. What prompted the question is a very strange lag. When I was deleting cloned sound, I got a massive lag for a short time. The first time each "sound slot" was deleted and replaced with a cloned sound, my frame rate plummeted. Then once all sound slots had been deleted and cloned once or twice, everything ran fine again.

What's strange is a cloned sound is supposedly just a reference to the original WAV file, so deleted the clone shouldn't have any overhead, and indeed, it doesn't seem to after the program had settled. But still, the initial lag was too much, so I ended up completely rewriting how my sounds work. Now I pre-clone everything so I can just trigger whichever sounds I want. If they're just references to the original sound, it shouldn't have much memory overhead.

Login to post a reply

Server time is: 2026-07-07 22:22:13
Your offset time is: 2026-07-07 22:22:13