Here is an audio dll and a DBC library to use with it. This came about because a question was asked about how to figure out the current byte position in a sound that was playing using DBC commands. It turns out that even though the PLAY SOUND command allows for a byte position as a parameter, it doesn't seem to work.
You can check out the thread here:
Getting Audio Position
Anyway, I didn't plan on making a DLL. I had originally just planned to make DLL calls to the winmm.dll . It turns out that sounds loaded and playing with the winmm.dll will remain in memory and cause DB.exe to never end as a process unless the sounds are properly closed before exiting DB. I don't know about you, but I'm in the habit of hitting F12 whenever an error occurs or I want to test something new. I couldn't always remember to use the CLI to close the sounds loaded from calls to winmm.dll. So, I created a DLL that will close itself out and cleanup when DB exits.
I'm posting it here because it's specifically for DBC, and I haven't tested every scenario possible with it; I'll leave that to you. This is being released without any guarantees and you use it at your own risk.
I haven't run into any problems and the calls (internally) are right out of the winmm. There are two main files:
DBCaudio.dba
jkkaudio.dll
DBCaudio.dba contains functions written in DBC code. This is the library that you should #INCLUDE with your source - or copy and paste the functions into your source. The descriptions of how they work are contained in the file. The calling convention is pretty clear (I think) and pretty consistent. It's similar to the built in SOUND commands. For instance:
LOAD SOUND filename,snum
load_sound(dll,filename,snum,flag)
PLAY SOUND snum
play_sound(dll,snum,frompos,topos)
value=SOUND EXIST(snum)
value=sound_exist(dll,snum)
I've limited the number of sounds to 1024. I don't know if that is the limit of simultaneous sounds or not - I just picked that number based on the max in DBC. I've run 6 sounds simultaneously without a hiccup.
You should be able to play most audio formats including midi all with the same function calls. A lot depends on how the drivers are set up on individual computers so the library may or may not work for some or all file types.
I haven't had time to put together a jaw dropping demo that show cases all of the functions. I did, however, include an entry from the DBC challenges with 3 different audio file types added in: midi for background music, mp3s for walking sound effects, and a wav for some whining. It's just to show all three file types work and there is a little bit of panning and volume calculation used.
If you have any questions, feel free to ask. The files are attached.
Enjoy your day.