2016-09-09 18:25:52 (edited by Hrvoje 2016-09-09 18:30:53)

Hello all,
So, I'm now experimenting with making true 3d game in python where you can move in directions left, right, forward, back, up and down. So 3d sound will also be used.
There's one thing which confuses me though. Libaudioverse's positioning works totally different than bgt's (I don't know if it's similar to OpenAl or not because I haven't worked with OpenAl yet). I've chose Libaudioverse because it has many advanced features that may be useful later if I decide to implement reverb for large arias, or filters for representing objects behind the closed door.
So, in BGT you position sounds and listener by specifying x,y coordinates, e.g., 50, 0. Libaudioverse uses positive and negative values for this, and I'm not sure how to make it convertable to real coordinates, so instead writing (-1, 0, 0), I can simply specify x,y,z position of the object on a map let's say 50,50,0 and then convert it to values that Libaudioverse understands. I'm not the best when it comes to math, so I need at least some guidelines on how to achieve this conversion. Let's say the room max size is 100 by 100, and you can clime upto 100 squares in the air, the player is at coordinates x50, y0, z0 and there's an object e.g. telephone ringing at room coordinates x50, y50, z0. Please note that this game will not have turning like in fps. Instead it'll work like an rpg where you can move in 4 directions (north, south, east and west), and you can clime up and down, for example on a ladder or tree.
I was trying to follow the code for Shooter game that was recently posted, but code is not commented with docstrings so it may take a lot of time.
Thanks for any help.

2016-09-09 18:30:11

BTW, I accidentaly posted to OT. Please move it to developers room.

2016-09-09 21:14:17

As I understood when reading the OpenAL documentation, and if
LibAudioverse follows this same principle, you'll want the relative
coordinates of the object based on the player.
For example, let's say you have a player in 50, 0, 0 and you have an
object in 50, 50, 0.
The relative coordinates will be 0, -50, 0.
Why? Because the relative coordinates are the player's cordinates being
subtracted by the object's coordinates.
So, in this case, 50-50=0
0-50=-50
0-0=0
You can see that, if you have negative coordinates, it means that your
player is behind an object.
I'm not sure if I've complicated it further. Let me know if I did, so I
can try to explain it in another form.
Hope it helps.

2016-09-10 00:50:17

Both Pyglet and PyAL have 3D positional audio support through OpenAL, and I have some example scripts available that may help if your interested [here]. PyAL also has undocumented bindings for EFX extensions like reverb, echo, etc. The latest version of OpenAL Soft also has support for HRTF, and lately i've been working on expanding the bindings in both Pyglet and PyAL to make full use of all these functions along with provided examples.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-09-10 12:58:48

Hello,
I've downloaded hrtf example. I have also replaced file alc.py in pyal in order to get hrtf functionality, however when I run example I'm getting: AttributeError: function 'alcGetStringiSOFT' not found
I'm not sure why. I'm running the example on Python27, and I've installed PyAl 0.1.0 which is stable release.

2016-09-11 00:02:07 (edited by magurp244 2016-09-11 00:33:27)

Thats odd, the example script doesn't even use alcGetStringiSOFT. Did you already have OpenAL installed before hand? The pack comes with the latest version of OpenAL Soft, if you run it with that and the hrtf tables in the same directory as the example script it should default to that one. If that doesn't work, try updating or installing the latest version of OpenAL Soft.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-09-11 01:06:09 (edited by Hrvoje 2016-09-11 01:07:46)

Yep, I've installed latest openal and I made sure that openal32.dll and hrtf table files are in the same directory where example is located. I have replaced files in both pyal and pyglet, and I even cleared cached .pyc files to make sure that no old version of the py file is left. Btw, my system is Windows 10 X64. Here's the entire traceback thrown by python.
Traceback (most recent call last):
  File "C:\Users\Hrvoje\Downloads\Compressed\OpenAL HRTF Python Example\OpenAL HRTF.py", line 2, in <module>
    from pyglet.media.drivers.openal import lib_openal as al
  File "C:\Python27\lib\site-packages\pyglet\media\drivers\openal\__init__.py", line 44, in <module>
    import lib_alc as alc
  File "C:\Python27\lib\site-packages\pyglet\media\drivers\openal\lib_alc.py", line 156, in <module>
    alcGetStringiSOFT = _lib.alcGetStringiSOFT
  File "C:\Python27\lib\ctypes\__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python27\lib\ctypes\__init__.py", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'alcGetStringiSOFT' not found
There's one thing which confuses me though. There are basically two openal versions, one from openal.org which is currently installed on my system, and the one by openal soft. And both of them are copying openal dll into system32 folder.

2016-09-11 02:09:32

Hmm, I see. OpenAL is broken into two branches, the closed source OpenAL by Creative, and the open sourced version called OpenAL Soft. OpenAL Soft is the better maintained of the two, usually they recommended installing regular OpenAL from openal.org to setup proper linking, then replace the dll's with those from OpenAL Soft for more features and fixes.

The problem may be that because your using a 64 bit system its not putting or finding the correct up to date version in the right folders. The OpenAL32.dll I included was the 32 bit version, you could try grabbing the 64 bit version out of OpenAL Soft and replacing the one in the folder with the example script. Generally, for 64 bit systems the 32 bit OpenAL32.dll goes in the syswow64 folder, and the 64 bit version goes in the system32 folder.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer