New audio stuff ][

BlitzMax Forums/BlitzMax Module Tweaks/New audio stuff ][

marksibly(Posted 2007) [#1]
Hi,

Ok, more new audio stuff now available via syncmods.

The default audio device is now back to "FreeAudio Default" as it used to be - you'll need to SetAudioDriver() to use anything else.

Also, since some people seem to be experiencing crashes inside OpenAL, I've added EnableOpenALAudio() which will 'turn on' OpenAL audio. Use this before calling AudioDrivers() or SetDriver().

Could those who were experience crashes in openalaudio.bmx please try a quick "Print EnableOpenALAudio()" and let me know if it crashes?


REDi(Posted 2007) [#2]
All drivers working well here! Thanks!

Top notch!


The r0nin(Posted 2007) [#3]
Thanks, Mark! That's fixed my crashing bug...


Tachyon(Posted 2007) [#4]
Just sync'd again and it downloaded a bunch of new audio updates...and now my game just plain crashes with "Unhandled Memory Exception Error". I have no other information to give you because it doesn't tell me anymore than that. I am not setting an audio driver so it should be using the default driver.

...um, it looks like the debugger is highlighting a "flip" command, as if it is crashing there. ??


marksibly(Posted 2007) [#5]
Hi,

Can you try adding a SetAudioDriver "Null" at the top of your program?


Grisu(Posted 2007) [#6]
Crash bug fixed here:
FreeAudio DirectSound
FreeAudio Default
Null


Mark, can you lock the old topic please.


Difference(Posted 2007) [#7]
My wierd "Full black screen - can't escape" problem has gone away with this syncmods, and now I can run
For Local t$=EachIn AudioDrivers()
   Print  t
Next
It returns:
FreeAudio DirectSound
FreeAudio Default
Null


Tachyon(Posted 2007) [#8]
Mark: Your suggestion to add SetAudioDriver "null" seems to have fixed it. I'll continue testing.

Thank you!


TheSin(Posted 2007) [#9]
Is this for non Mac version only? Because syncmods doesn't load anything new here...

Edit: nevermind, I just read the old audio thread, seems like it's still Windows only.


Matthew Smith(Posted 2007) [#10]
Mark,

Tested under Vista:

FreeAudio DirectSound - Great sound, no Delay
FreeAudio Default - Great sound, but Delay (as you pointed out)

It cetainly sounds a great deal better!! Soundcard is a SoundMax Integrated Digital Audio.

I haven't tested the OpenAL stuff.


Barbapapa(Posted 2007) [#11]
Already mentioned in the old thread, should belong here, since the new sync this morning solved the lua problem.


popcade(Posted 2007) [#12]
DSound Driver still cracks... but the default one works great.


ImaginaryHuman(Posted 2007) [#13]
So when can we look forward to this OpenAL support etc going cross-platform to the Mac and Linux?

And does this include any ability to do streaming audio?


GfK(Posted 2007) [#14]
DSound Driver still cracks...
FreeAudio Directsound still crackly here, too. I'm not sure that's supposed to have been fixed yet, though...?

Originally posted in the first thread by Skidracer...

Can you try changing the #define DSOUNDFRAG 2048 in freeaudio.mod/dsounddevice.cpp to 4096 and building modules?
Oops sorry, totally forgot to do that until just now!

I changed it to 4096 and it still crackles but to a lesser extent. I continued increasing it until the problem went away completely (which was at 16384), but then I get a 0.5s lag when playing sounds.


Tachyon(Posted 2007) [#15]
Mark: In reference to my two posts above...after using SetAudioDriver "null" my odd crash seemed to be fixed for a while. But now I am getting no sound at all.

Just rebooted...still no sound.

Removed SetAudioDriver "null" ... got sound but game crashes.

Add it back in... no sound again. ?

I will keep playing around and see if I can pinpoint the problem. :(


popcade(Posted 2007) [#16]
The higher buffer value makes less crackle, I hope BRL can get a more efficient/common value or another solution tho... :|


Tachyon(Posted 2007) [#17]
Ok...this is what is killing my game. For the past 18 months I've had a few functions that would perform a task and play a sound. I've kept all the variables (including the sound sample and the channel) local to these functions and it seemed to work just fine. If the sound duration was long enough, it continued to play even after the system left the function.

For example, this code crashes on my system but it used to work just fine:

SuperStrict
Graphics 640,480

While Not KeyHit( KEY_ESCAPE)
    Play_Local_Sound()
    Delay 100
    Flip
Wend

Function Play_Local_Sound()
    Local Sound:TSound = LoadSound("C:/Program Files/BlitzMax/samples/digesteroids/sounds/teleport.wav")
    Local Channel:TChannel = PlaySound(Sound)
End Function


But now, with the new default driver, this trick doesn't work anymore. To make it work I have to make the sample and channel Global:
SuperStrict
Graphics 640,480

Global Sound:TSound = LoadSound("C:/Program Files/BlitzMax/samples/digesteroids/sounds/teleport.wav")
Global Channel:TChannel

While Not KeyHit( KEY_ESCAPE)
    Play_Global_Sound()
    Delay 100
    Flip
Wend

Function Play_Global_Sound()
    Channel = PlaySound(Sound)
End Function



GfK(Posted 2007) [#18]
The higher buffer value makes less crackle, I hope BRL can get a more efficient/common value or another solution tho... :|
Trouble is, when you increase the buffer size, as the crackle decreases the lag increases. I'm guessing the solution lies elsewhere.


bradford6(Posted 2007) [#19]
Overall, I think the move to OpenAL is going to be awesome. I have been reading some of the documentation and it's integration with OpenGL should make positional 3D sound in miniB3D a snap! not to mention the impressive list of games/apps that use it. http://www.openal.org/titles.html

(well maybe not a snap for you Mark, we DO see how much wrangling you have been going through to get this to work)


anyway, here is another version of the program from yesterday. I have incorporated some of the things you mentioned (setdriver to "null" at program start and check to see if OPENAL fails to load)

I ran this before and after installing OpenAL on 2 systems and it seems to be accurate.

Also, if you hit 'D' it *should* open up your browser to download OpenAL if you need it. (I download and install the "OpenAL SDK 1.1 for Windows" for my 3 PC's and it works fine on all 3. One is an old laptop)



p.s I REALLY need to change that OGG file. Will upload a new sound when i get home tonight...
EDIT: Changed the sound file.


skidracer(Posted 2007) [#20]
Hi Tachyon, I was just considering a solution to this problem this morning, hopefully a fix will be available soon, as my game also has been doing some pretty interesting things with looping sounds when the samples themselves have gone out of scope.


popcade(Posted 2007) [#21]
I think it's a transition time like the new DX7 renderer introduced... will get sorted eventually.

However I still hope BRL integrate streaming in...


Tachyon(Posted 2007) [#22]
Skid: thanks for the quick response. I'll come up with a few workarounds for now, but a fix would be really wonderful! :)


marksibly(Posted 2007) [#23]

Mark: In reference to my two posts above...after using SetAudioDriver "null" my odd crash seemed to be fixed for a while. But now I am getting no sound at all.


Yep, I was just trying to narrow down the problem.


doing some pretty interesting things with looping sounds when the samples themselves have gone out of scope.


Well, openalaudio works - but only because it isn't freeing sounds at all! I've added that now and it should handle this 'deleting a currently playing sound' situation.

This'll be trickier in freeaudio though - perhaps add a refcount to fasound, bumped when it's played through a channel?

Also, can anyone who used to get a crash in openalaudio.bmx please confirm that it still crashes when EnableOpenALAudio() is executed?


Vertex(Posted 2007) [#24]
Is there no way, do bind OpenAL directly with BMax Executables? OpenAL is open source, so i think so(or is it nt allowed by the OpenAL License?)

And, Ogg/Vorbis can be streamed by using alSourceQueueBuffers. I don't know, if FreeAudio have a mechanism for it, but there are long long loading times for static sounds.

I'am a german but I don't realize, why you use the name TAudioSample. In my opinion is a sample one value and only a part of a tone, noise or sound.

cu olli


Brucey(Posted 2007) [#25]
Is there no way, do bind OpenAL directly with BMax Executables?

It's LGPL, which means that you can link to shared objects (like .dll / .so / .dylib) but if you wanted to statically link (that is, build their library code into your app) you would have to make the source to your code available either with the app or online somewhere (with directions on how to obtain it with your distribution).

So unless you want to only make open-source software yourself, it's better to link to the DLLs.


skidracer(Posted 2007) [#26]
To keep to the LGPL, after building your release executable copy the contents of the blitzmax/tmp/ld.tmp file and all the .a files it references into a zip and include it in your distribution.


The Caffeine Kid(Posted 2007) [#27]
After the syncmods my game is now throwing exceptions at seemingly random intervals while playing samples from inside my object methods, having a local ch:tchannel variable showing up as null in debug.


Chris C(Posted 2007) [#28]
the whole point of LGPL is it doesn't "infect" other products that happen to use the library

5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.



As I see it the binding of the library must be LGPL and BLR must make the code *publicly* available.

However whether static or dynamically linked it makes no difference. Your code that uses a LGPL library CAN remain closed source

This is the whole point of LGPL!


popcade(Posted 2007) [#29]
Rip OpenAL out and improve freeaudio is the solution.

Streaming Please ... :|


ImaginaryHuman(Posted 2007) [#30]
So we can still distribute OpenAL with the application/game, so that the user doesn't have to go hunting down an OpanAL driver?


BlitzSupport(Posted 2007) [#31]
All working here, though I notice that OpenAL is very slightly duller/quieter sounding than FreeAudio will bradford6's test.


bradford6(Posted 2007) [#32]
I think you can:
Run the Creative OpenAL Installer in silent mode (with the /s option) along with your installer.

BlitzMax will look for the OpenAL DLL's (in the case of windows...not sure for Linux/Mac)


Anyway. I am liking this OpenAL stuff and I think it will fit nicely witht he other OSS/FOSS libraries that BLitz uses.

remember that you are free to use the FMOD library that is being developed by some users and the FreeAudio module. OpenAL will add free/ cross platform audio support to Blitzmax.


skidracer(Posted 2007) [#33]
Jeeze, sorry everyone for the problems with freeaudio. I think I've sorted the main problem, freeaudio is now back to maintaining it's own copy of the sound sample like it use to (which it has it's own reference counting scheme in place) unless the sound is played using a loop count of exactly $80000000 which signifies the sample is a live stream and the blitzmax programmer needs to keep a reference of the sound object alive while it's channel is playing.

Tachyon, can you try testing with the following fix to pub.freeaudio/freeaudioglue.cpp[124]




marksibly(Posted 2007) [#34]

Is there no way, do bind OpenAL directly with BMax Executables?


Not if it's closed source. The LGPL license means that..."it must be possible for the software to be linked with a newer version of the LGPL-covered program".

In other words, the end user must be able to change the version of OpenAL32.dll used by your app. Statically linking makes this hard/messy, as you'd have to provide the source code to the OpenAL32 module you linked with (so they could 'create a newer version') and a mechanism to rebuild the entire app.


As I see it the binding of the library must be LGPL and BLR must make the code *publicly* available.


I don't belive this necessary - although I'm quite happy to make the source to openal.mod public if necessary.

Since openal uses LoadLibrary/GetProcAddress, the requirement to allow users to upgrade the library is already fulfilled and I don't think we have to do any thing else.

Actually, this LGPL thing is starting to make sense to me now: They key idea is that it must always be possible to modify the LGPL components of a non-LGPL app. DLL's are just the easiest way to do this for the non-LGPL app author.


So we can still distribute OpenAL with the application/game, so that the user doesn't have to go hunting down an OpanAL driver?


The good news on the Mac is that a very up-to-date version of OpenAL comes pre-installed on 10.4!

There's a separate installer for 10.3, but it's kind of old (2004) and is actually missing quite a few functions (although it still works) so be careful if you're using 'raw' openal on the mac - if you hit a missing function you'll get a 'null function pointer' error. You can test if a function is valid using something like: If alcGetString Print "alcGetString OK!"

You'll need to ship this installer (or build a 'newer' version from the source) with 10.3 apps that depend on OpenAL. But unless you're using special features of OpenAL, I'd recommend sticking with freeaudio anyway as it works fine on non-windows platforms.

Linux is another story. I couldn't get OpenAL working at all until I recompiled the whole thing (and on Ubuntu, you have to enable the 'universe' repositories to even find the packages). Even then, there was a nasty Vista-ish lag in audio. FreeAudio rocks on Linux...


Rip OpenAL out and improve freeaudio is the solution.


OpenAL looks like it may be the only sane way to get HW accelerated audio on Vista (esp. 3D), so it's not going anywhere.

The overall impression I am getting with Vista audio is that Vista really, really doesn't like you doing your own mixing ('port audio' has similar problems...) - which is what freeaudio does. If this is true, then there is a real limit to how much we can 'improve' freeaudio.

Games with audio that works fine under Vista do so (still guessing here though...) because they DO NOT do their own mixing. We avoided this route with freeaudio to keep the audiodriver as widely compatible as possible - which worked until Vista...


Tachyon(Posted 2007) [#35]
Skid: Yep, so far that seems to have fixed the problem! :) I'll keep testing and let you know if anything else pops up.

Thanks again for the quick fix!


skidracer(Posted 2007) [#36]
Sorry again for breaking it:)


skidracer(Posted 2007) [#37]
GfK if you have some time could you please test with this new version of dsounddevice.cpp combined with the fix to freeaudioglue.cpp above:




GfK(Posted 2007) [#38]
Done - its still crackly like before using FreeAudio DirectSound. No change at all. :/