I got OpenAL to work with BlitzMax

BlitzMax Forums/BlitzMax Programming/I got OpenAL to work with BlitzMax

JoshK(Posted 2006) [#1]
OpenAL is a free cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.

http://www.leadwerks.com/post/openal.zip


RiK(Posted 2006) [#2]
Now then, if someone could get this working on Mac too we'd be well away!


skidracer(Posted 2006) [#3]
Josh, are those dll files freely distributable or did they have some sort of license (LGPL?) attached?

<edit>

Jeesh, what a joke. The OpenAL site says the library is LPGL but the creative dll installer doesn't attach an LGPL license, instead the license they do show on their installer looks a lot like a public domain one. In my mind LGPL <> freely integrate.


Creative Labs, Inc. is providing you with this OpenAL32.dll installer and other OpenAL files ("Software"). You may use and freely integrate with your software applications and distribute such throughout the world at no cost or further obligation to Creative.

NO WARRANTY
ANY USE BY YOU OF THE SOFTWARE IS AT YOUR OWN RISK. THE SOFTWARE IS PROVIDED FOR USE "AS IS" WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY LAW, CREATIVE DISCLAIMS ALL WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CREATIVE IS NOT OBLIGATED TO PROVIDE ANY UPDATES OR UPGRADES TO THE SOFTWARE.

No other entity or person is authorized to expand or alter this warranty or any other provisions herein. Creative does not warrant that the functions contained in the Software will meet your requirements or that the operation of the Software will be uninterrupted or error-free or free from malicious code. For purposes of this paragraph, "malicious code" means any program code designed to contaminate other computer programs or computer data, consume computer resources, modify, destroy, record, or transmit data, or in some other fashion usurp the normal operation of the computer, computer system, or computer network, including viruses, Trojan horses, droppers, worms, logic bombs, and the like.

You assume full responsibility for the selection of the Software to achieve your intended results, and for the downloading, use and results obtained from the Software. You also assume the entire risk as it applies to the quality and performance of the Software.

IN NO EVENT WILL CREATIVE'S LIABILITY TO YOU OR ANY OTHER PERSON EVER EXCEED THE AMOUNT PAID BY YOU TO USE THE SOFTWARE, REGARDLESS OF THE FORM OF THE CLAIM.




popcade(Posted 2006) [#4]
It seems Creative distribute OpenAL runtimes with unsupported basic, however on the official site it's under LGPL.

If someone just want to play XM via DSound under Win32 as music support, uFMOD can do this.

Not found something can replace freeaudio yet(under the term of "Cross Platform")


JoshK(Posted 2006) [#5]
OpenAL is completely free. It was also used in UT2004.


popcade(Posted 2006) [#6]
Are we allowed to link OpenAL statically?
(Can't find info about this tho)

Or anyone planning to make a cross-platform module?


Yan(Posted 2006) [#7]
According to the LGPL, if you statically link a library, the resultant executable is considered to be a 'derivative work', you are therefore obliged to provide the entire source.

That's as far as I can make out, at least. :o/


So what's the deal with creative then, do they own the OpenAL library, or are they just distributing it?


popcade(Posted 2006) [#8]
Yeah I know that, so I'm curious, with looking into the distribution, I found i'm wrong.

OpenAL is under GNU "LIBRARY" GENERAL PUBLIC LICENSE, which is a bit looser license allow to staticaly link into your final work, as well as ALUT.

however BMax haven't got threading yet, using a DLL is a better way to avoid problems.


Yan(Posted 2006) [#9]
Can I have some, yoxola?


popcade(Posted 2006) [#10]
Yeah, go to http://www.openal.com/

You can download the source, and the license are attached.

I don't think it can be compiled without modification tho.


JoshK(Posted 2006) [#11]
The API is a lot like OpenGL, which is nice. Use my example source, and I think you will have no problem getting it to do more.


Booticus(Posted 2006) [#12]
OK I admit, I am pretty dense. I downloaded your example and compile and run it. But no sample playing. I downloaded and installed OpenAL also. Should I be doing anything special?


REDi(Posted 2006) [#13]
@Leadwerks, Sorry dude, dont mean to hijack your thread, I've been meaning to put this out for a while, but it breaks the current version of MaxMod, but i thought it might save you some work..

openal module (bbdocs and source) http://redi.me.uk/forum/index.php

no alut included because it adds an extra dll, and anything alut does is easy to do yourself anyway. (or use alut directly, or better still freeaudio)

Hope it helps

@Booticus, I bet if you delete that OpenAL32.dll it'll work ;) for some reason known only to creative, theres two different dlls for 32/64 bit machines, both called OpenAL32.dll .. :D

*EDIT* BTW OpenAL is VERY dodgy on linux, as soon as I change the pitch of a source it starts "crackling", and quite a few of the functions arent even implemented, I havnt tried EFX on it yet, but i bet it dont work :(


JoshK(Posted 2006) [#14]
Cool, is it complete?

Do you have an example of how to use EAX?

How do I load a wav file without alut?


REDi(Posted 2006) [#15]
yeah its complete, but i've just noticed a stupid error that i'll fix when i get home later. (error in efx)

I might do a few examples for efx ect later, its all pretty easy to do tho :)

heres a lil example of using freeaudio to load the sounds. (converted from your code above btw)


*EDIT*
DOH... LOL just downloaded a different version of the sdk from http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=45 and its got a load of stuff thats not in the sdk I had, oh well it wont take long...

*EDIT AGAIN*
I've put a new version up, still not 100% but wont have any time for a day or two.


JoshK(Posted 2006) [#16]
Cool. LoadAudioSample seems more reliable than the alut wav loader.

I'd really like to see an example with EAX.

Thanks! This is very straightforward and easy. Maybe Blitz will start including it.


Booticus(Posted 2006) [#17]
Hey thanks guys! I simply used Papa Lazarou's mod and ran it from within the folder I got from Leadwerks. Plays the sample! w00t! I'm on my way now!


ImaginaryHuman(Posted 2006) [#18]
I ran into the same issue with the LGPL thing ... if a library is LGPL and you use it in your app, you have to provide the full sourecode of your app as LGPL source.

Although I think this GPL stuff is good for keeping people from making things exclusive, I do think that sometimes it goes to the other extreme and makes things TOO public, such that everything you create that uses it has to be totally public too.


skidracer(Posted 2006) [#19]
To be correct, if you are writing a library that incorporates LGPL code your library must also be licensed as LGPL.

If you are writing an application that is not LGPL then you must only link dynamically to any LGPL code / libraries you use, static linking is not allowed. You must also include LGPL licenses to cover the libs and enough information for the user to rebuild the LGPL libraries (dll files) you are using.


popcade(Posted 2006) [#20]
LGPL Lesser GNU Public License
GLPL GNU Library Public License

What's the exact difference about these two?
LGPL is fine enough to me, however GLPL is still a myth.


anawiki(Posted 2006) [#21]
Can I stream ogg files with this? I managed to run the mod and example but I don't know how to stream ogg files.


Yan(Posted 2006) [#22]
Yoxola, they're one and the same. Library GPL was renamed to Lesser GPL.


popcade(Posted 2006) [#23]
With some searching, I think LGPL can be considered as version 2 of GLPL, so it's get sorted out.

I can understand why Toque put OpenAL dlls externally, it's licensing issue.


Yan(Posted 2006) [#24]
/me slaps yoxola with a rusty kangaroo...


popcade(Posted 2006) [#25]
Well, it seems google is a good friend tho.

The next question is, if it's MoleBoxed, not statically linked, how doe it stands?


imekon(Posted 2006) [#26]
Tried to get openal.zip as originally posted but it doesn't seem to be there...

EDIT: Got it! Network glitch I guess.


REDi(Posted 2006) [#27]
@anawiki , I've already coded ogg streaming into maxmod (uses openal) just click on the forum link in my sig.


JoshK(Posted 2006) [#28]
How about that EAX example?


REDi(Posted 2006) [#29]
(make sure you use a mono sample...)


Well it works but I'm gonna need to write my own EFX->EAXEFX helper functions cos I cant access the ones in EFX-Util.h


JoshK(Posted 2006) [#30]
Cool, why does it have to be mono?


REDi(Posted 2006) [#31]
dunno, efx only seems to work on mono sounds, same with 3d i think.

none of this works on linux, the distros well out of date.


JoshK(Posted 2006) [#32]
That actually makes sense, for 3D.

I get a compile error on line 60:

Building eax
Compiling:eax.bmx
Compile Error: Identifier 'EFXEAXREVERBPROPERTIES' not found
[C:/Documents and Settings/Administrator/Desktop/eax.bmx;60;1]
Build Error: failed to compile C:/Documents and Settings/Administrator/Desktop/eax.bmx
Process complete


REDi(Posted 2006) [#33]
you must have an old version of the mod, delete it and try the new one


anawiki(Posted 2006) [#34]
@REDi: Fantastic work. I am going to use it right away.

BTW. Demo.bmx tries to import SID.SidStream and that mod does not exists (but replacing import line with type SidStream from CustomStreamDemo.bmx makes the trick).


JoshK(Posted 2006) [#35]
Works great!

I will go ahead and start using it. Whether it needs to be a dll or a module, you guys can figure that out, and we'll just go with whatever way it is supposed to be used.


REDi(Posted 2006) [#36]
@anawiki, oops forgot to remove that, you can just delete that import (you only need to import the ones your gonna use ie MaxMod.OggStream for ogg, MaxMod.Protracker for Amiga mods, ect) or you can get a copy of gmans sid module here... http://www.gprogs.com/forum/index.php

@Leadwerks, its dynamically linked to the dll in system32, i think that allows us to make non LGPL apps with it, but if anyone knows different..


skidracer(Posted 2006) [#37]
its dynamically linked to the dll in system32, i think that allows us to make non LGPL apps with it, but if anyone knows different..


Yes thats the way I understand it. I just detest the way Creative and others distribute the dll without the license. It is my understanding if you distribute the dll yourself you must include the LGPL license with it and enough information so the user can download all source and rebuild exactly the same version of the library themselves. The freedom for the end user to recompile / fix / expand the library being the primary intent of the LGPL license.


REDi(Posted 2006) [#38]
sweet, thanks for clarifying that skid


anawiki(Posted 2006) [#39]
How stable is OpenAL and REDi's mod?
It doesn't work on my WinME laptop. BMX program just doesn't start (no loading etc.) :(


REDi(Posted 2006) [#40]
could you try this for me anawiki

every time it uses an openal command it'll print something out to the ide, should help to find out whats going on.

also could you make sure the openal installer you used was this one... http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=46

REQUEST: does anyone with a Mac fancy having a go at the Mac import bit?


anawiki(Posted 2006) [#41]
Hi REDi
Apologies for delay but it took me a while to setup BMX on WinME.

Your example gives:
Unhandled memory exception error:...

Line 3:
Global ALDevice = alcOpenDevice (Null)alError("alcOpenDevice")


There is nothing written in console window.

Hope that will help.


anawiki(Posted 2006) [#42]
I probably could suply more details about the error but it seems that audiostream.bmx file is missing in MaxMod.


anawiki(Posted 2006) [#43]
And I don't know why I get this warnings:

alDeleteSources INVALID NAME

I stop the music like this:
music.stop
music.free


REDi(Posted 2006) [#44]
Hi anawiki

Don't worry about the "alDeleteSources INVALID NAME" its fixed next update, not a serious issue anyway more of a warning ;)

I probably could suply more details about the error but it seems that audiostream.bmx file is missing in MaxMod.

MaxMod is closed source ATM.

Your example gives:
Unhandled memory exception error:...

Just noticed that alcOpenDevice was defined using Device$ rather than Device$z, hopefully this *might* fix your problem with WinME.

I'll update soon, just finishing off MaxMod.AudioDriver which is an openal version of the bmx TAudioDriver


Chris C(Posted 2006) [#45]
[quote]
MaxMod is closed source ATM.
[/qoute]
frankly its better that way its tight code, nicely done...


JoshK(Posted 2006) [#46]
I am getting some really strange results with the 3D sound. The sound fades with distance on every axis, and the sound orientation works, sort of. If I am in front of the sound and turn to the right, the sound is louder in my left speaker. If I move behind the sound and turn to the right, the sound still gets louder in the left speaker. It's as if the orientation and position have nothing to do with each other.

The only reason I want to use OpenAL is because it allows EAX effects. Otherwise, I would much rather just write my own sound library. Is there any way to get the BlitzMax audio library to do EAX effects?