New audio stuff IV

BlitzMax Forums/BlitzMax Module Tweaks/New audio stuff IV

marksibly(Posted 2007) [#1]
Hi,

PLEASE READ ENTIRE POST!!!!!!

Ok, final-ish release of the new audio stuff: syncmods for the latest.

Changes:

Each audio module (freeaudioaudio, directsoundaudio, openalaudio) now includes an 'auto detect' driver with the same name as the module.

For example, if you:

Import BRL.OpenALAudio

...then an "OpenAL" audio driver becomes available...

SetAudioDriver "OpenAL".

This driver attempts to work out the best 'sub driver' to use and should work in 99.99% of situations. If you're really paranoid you can still call AudioDrivers() to return a full list of drivers.

This should greatly simplify "Select Audio Driver" menus, eg:
Strict

Repeat
	Print "Select Audio Driver:"
	Print "1) FreeAudio"
	Print "2) OpenAL"
?Win32
	Print "3) DirectSound"
?
	Local n
	Select Input( ">" )
	Case 1 n=SetAudioDriver( "FreeAudio" )
	Case 2 n=SetAudioDriver( "OpenAL" )
?Win32
	Case 3 n=SetAudioDriver( "DirectSound" )
?
	End Select
	If n Exit
Forever


If SetAudioDriver() fails, the audio driver is now set to "Null", so make sure to check the result.

If SetAudioDriver() is never executed, the default audio driver is still "FreeAudio".

The second paramter of LoadSound is now a set of flags with the following values:

SOUND_LOOP=1
SOUND_HARDWARE=2

SOUND_HARDWARE attempts to place the sound into audio hardware memory, and should be used for frequently played, shortish sounds - not recommended for music.

This currently only affects DirectSound (which on XP has problems cleanly changing the pitch of software sounds) but is a good future proofing step as OpenAL supports hardware sounds too, and eventually we can add SOUND_3D etc.

You will still need to call EnableOpenALAudio() if you want to receive the full list of OpenAL drivers back from AudioDrivers(). However, you don't need to do this if you're just using the auto detect driver - ie: SetAudioDriver "OpenAL".

***** IMPORANT *****
Could anyone who was previously getting crashes in OpenALAudio when it was trying to enumerate devices please confirm whether or not 'EnableOpenALAudio' now crashes or not.
*******************

OpenAL appears to work OK on the Mac - but so does FreeAudio so I personally would stick with that for now!

10.4 has OpenAL preinstalled (yay!), but on 10.3 you will need to install the OpenAL framework:

http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=97

OpenAL on Linux doesn't seem to work well at all. I had to rebuild it from scratch to get it working, and even then it has serious lag issues.

Note that we've been having some problems with syncmods lately. If you're having trouble rebuilding modules or linking an app due to missing symbols, I recommend reinstalling the 1.24 update over your current BlitzMax and syncing modules again.

Finally, thanks to REDi for the OpenAL module docs!


Gavin Beard(Posted 2007) [#2]
wow, great work mark, thanks alot. sync'd down perfectly :-)


JoshK(Posted 2007) [#3]
I thought Vista got rid of DirectSound?


JazzieB(Posted 2007) [#4]
It got rid of the HAL side of DirectSound. It still exists, but the mixing is now all done in software instead of hardware, and then sent via OpenAL. Basically, it's now emulated for backwards compatibility sake.


GfK(Posted 2007) [#5]
I just tested my game in Vista (didn't have my dev stuff as it wasn't my PC).

FreeAudio had the notorious 1-second lag.

DirectSound didn't play diddly squat. :/

Must look into this and get it tested again. Its a bit crap that my dev PC and the PC with Vista on are half a mile apart.


The Caffeine Kid(Posted 2007) [#6]
Just released my game (Super Obliteration) and some people have reported that the music doesn't play - just a "ticking" sound.

The normal sound effects (short sounds) are working but not the tunes, which are 1.x meg ogg files.

But there is no other way of doing it is there?


Tachyon(Posted 2007) [#7]
Why does Linux default for "FreeAudio OpenSound System" instead of plain "FreeAudio"? On my Linux system regular "FreeAudio" doesn't even work. This discrepancy breaks my initialization routine between PC/Mac/Linux.


Brucey(Posted 2007) [#8]
Well, I've spent most of today trying to get "dynamic audio" working on linux... using that TSynth example of Skids from a while back.

After debugging just about everything (yes, really), I tracked down the problem to two areas.

in freeaudioglue.cpp fa_CreateSound(), to enable it requires the loop param to be set to 0x80000000.
Which is fine, except that you cannot then "loop" it at the same time.
If loop isn't set to that, the samples data is copied into new memory, and you no longer have access to it - to change it on the fly.

However, the function that calls fa_CreateSound(), in freeaudioaudio.bmx CreateSound(), never sets the "loop_flag" to anything other than -1 (if at all).

For now, I've hacked my version to pass "flags" through, enabling me to use that "dynamic" audio thingy.

It actually works really well once you get past these problems.

Is there any chance of some "official" support for dynamic audio? Please :-)