2019-03-13 08:01:49

Hi,
Yes I understand that, What I don't understand is:
Say, a grid is 10 by 10 squares big, (x 10, y 10), so it's a 2D grid. Now, instead of saying:
for a in range(1,10,1):
sound.position=(a,0,0)
Why is that x number so high, (200). And what does incrementing by 64 mean?

2019-03-13 08:20:28

Are we talking about the 3D audio example? The numbers for that are largely arbitrary, but served the particular purpose of demonstrating the panning effect. With the rolloff factor set low the distances needed to be larger to get the same panning effect, I'd set the Y position of the listener and the player at 240, no particular reason really. The listener's X position was set to 320, and the players X position to 0. Now this puts the player squarely on the left side of the listener, and in order for it to move over to the same position on the right side of the listener it needs to move to 640. I didn't want it to play constantly along the way so made it so it would play at 64 step intervals to play 10 times, plus another 64 for a total position of 704 because the player would also be in front of the listener at one point, which thinking about it might not be quite right, but eh.

Bottom line being, don't worry too much about the specifics of that particular example, its arbitrary and doesn't really matter.

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

2019-07-09 18:40:07 (edited by amerikranian 2019-07-09 18:41:25)

So reviving this old topic, yea!
I'm trying to find a sweet balance between the volume and the sound fading away. I have tried the rolloffs between 0.1 and 40, and I still can hear the sounds when they're like... 100 units away. Suggestions?
Also, the volume drastically jumps between the listener and the player when the player is 1-2 units away when I raise the factor higher, ideas on how to soften that?

2019-07-10 05:03:05

With the roll off factor, the higher the value, the steeper the volume drop over a shorter distance. The lower the value, the more gradual, and longer the distance from the listener. You could try adjusting the sounds volume, but there are also other factors involved with the roll off distance models not currently implemented in the player handler class, though the bindings are in place. For example:

// The distance that the source will be the loudest (if the listener is
// closer, it won't be any louder than if they were at this distance)
alSourcei(source, AL_REFERENCE_DISTANCE, 1.0);
// The distance that the source will be the quietest (if the listener is
// farther, it won't be any quieter than if they were at this distance)
alSourcei(source, AL_MAX_DISTANCE, FLT_MAX);

There are also settings for different distance models, such as AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED, or AL_NONE. For the AL_INVERSE_DISTANCE model the formula works like this:

gain = AL_REFERENCE_DISTANCE / (AL_REFERENCE_DISTANCE + AL_ROLLOFF_FACTOR * (distance – AL_REFERENCE_DISTANCE))

These settings help adjust the effects of volume distance attenuation and drop off. If you like I can try adding them in and you can playing around with them. Or also you could also checkout the [Openal Programmers Guide], which covers some of the nitty gritty of source functions and calls.

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

2019-07-12 16:48:30

Sorry for a late reply, I would appreciate if you add the things you listed above.  Like I said, the major issue for me right now is volume.

2019-07-18 09:41:22 (edited by magurp244 2019-07-18 10:05:34)

Bleh, response time not withstanding, just finished adding in a bunch of extra handler functions. Streaming and queuing sources still isn't handled, also need to work at implementing those environmental reverb presets and vorbis bitrate formats, among a few other doppler-y things...

You can grab the latest version here: [OpenAL PyLite v1.1]

New additions include:
-Listener Gain function for controlling master volume level
-Listener Orientation function for orienting the listener in specific directions
-Listener Velocity function
-Listener Distance Model function which includes 7 different model settings.

-Player direction function
-Player Velocity function
-Player Cone Outer Angle function
-Player Cone Inner Angle function
-Player Source Relative function
-Player Max Distance function
-Player Reference Distance function
-Player Min Gain function
-Player Max Gain function

Here's some examples of how the new functions are used:

from openal import *

self.listener = Listener()

#must be higher than zero
print(self.listener.gain)
self.listener.gain = 0.7

#for "at" and "up" vectors
print(self.listener.orientation)
self.listener.orientation = [160.0, 0.0, 0.0]

#velocity vectors
print(self.listener.velocity)
self.listener.velocity = [160.0, 0.0, 0.0]

#distance model between 0 to 6
print(self.listener.distance_model)
self.listener.distance_model = 4



self.player = Player()

#direction vector
print(self.player.direction)
self.player.direction = [160.0, 0.0, 0.0]

#velocity vector
print(self.player.velocity)
self.player.velocity = [160.0, 0.0, 0.0]

#cone outer angle in 360.0 degrees
print(self.player.cone_outer_angle)
self.player.cone_outer_angle = 160.0

#cone inner angle in 360.0 degrees
print(self.player.cone_inner_angle)
self.player.cone_inner_angle = 160.0

#source relative setting, disabled by default
print(self.player.source_relative)
self.player.source_relative = True

#max attenuation distance
print(self.player.max_distance)
self.player.max_distance = 1.0

#relative distance attenuation
print(self.player.relative_distance)
self.player.relative_distance = 0.0

#minimum gain
print(self.player.min_gain)
self.player.min_gain = 0.5

#maximum gain
print(self.player.max_gain)
self.player.max_gain = 0.5
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-07-25 17:41:46

Sorry for the late response. Rest assured, I have not forgotten about this. I have tried all the modules for distance, and I still can hear the sound source even if it is 70 or so units away from me. I think the solution is to move the player more than one step at a time.  That or keep looping through the list of the players and pause the sound whenever it is supposedly too far away, though I’m not sure how practical that solution maybe in the long term.  The issue with the first approach is the more I move the player, the more sounds seem to jump in terms of pan and volume.  Suggestions?  I like the library, I really do, but it is a bit unnatural when it comes to panning.
If you want to see what I sort of want, you can try playing a hero’s call and listening to it’s 3-D sound positioning. I am not sure that it uses open Al, though.  There are also playthroughs of it on YouTube, the most notable one being by Liam Ervin  so you can get an idea of sound positioning that way.

2019-10-13 17:06:35

I finally figured out how to ask this question:
Consider this, taken from the PB reference:

SoundRange3D()
Syntax
SoundRange3D(#Sound3D, Minimum, Maximum)
Description
Set the range, in world units, for the sound emission. 
Parameters
#Sound3D
The sound to use. 
Minimum
The distance from the sound location when the sound volume starts fading. 
Maximum
The distance from the sound location when the sound can still be heard. Above this distance, the sound will stop playing. Between the minimum and maximum value, the sound will fade according to the current listener position.

Does open AL have something similar to this?

2019-10-13 18:52:13

@31, you may wish to check out a wrapper in C++ that wraps OpenAL written by the author of OpenAL-soft for insparation and how to do things like this: https://github.com/kcat/alure
@33, I think there is. Its either alSpeedOfSound() or alSetDistanceModel(). I'm not exactly sur on this though.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2021-04-12 09:59:27

Hi there, Yes I do have a reason to bring this topic up again smile
@magurp244 I wanted to report that some of the effect classes like reverb, distortion, etc etc are not properly capitalized and doesn't follow the casing rule that the other classes of the wrapper follow. The funny thing is that in the EFX example for instance, the casing for declaration of effects is the general casing rule that most of the classes of the wrapper follow, and thus throwing an error upon the time of declaration during the execution time.

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2021-04-12 10:32:18

Damned version typo's, like cockroaches! Anyhoo, reuploaded v1.3, capitalization should be fixed.

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

2021-04-18 22:08:59 (edited by kianoosh 2021-04-18 23:06:31)

Today I went on checking the wrapper and I noticed that the functions responsible for listener's orientation were completely gone. I think you uploaded a wrong version by mistake since the last changes including velocity support weren't there either.
So I replaced the listener class with the old version but here's a thing. It sets the at vector but not the up vector. It'd be great if you could add that to the wrapper as well.
Thanks
Edit: Another thing that I noticed is that after setting the orientation (And making sure that it has been set correctly), the pan of the playing sound does not change accordingly and I presume that this is coming from not setting the up-vector to 0 1 0.

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2021-04-18 23:13:48

Thats... odd. I rechecked the package and the listener class handles for orientation and velocity are there. Checking the OpenAL documentation though, I think I can see what you mean by the "at" vs "up" orientation not working right. I've adjusted the orientation handler into two types, "at_orientation" and "up_orientation" which you can set independently now.

Latest v1.4 can be found [here].

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

2021-04-19 03:49:53 (edited by kianoosh 2021-04-19 03:52:06)

Yeah, now the functions are there but here comes another thing. I ran the test again and saw that setting of the orientation does absolutely nothing. So I went checking/comparing things and found out that the lib that I was using previously and was working fine in that matter, uses alListenerfv for vector6 or 6-element arrays. So I tried to do the same by making the whole orientation-setting function a single function and do it all there since openal doesn't have separate enums for both the at vector and the up vector (Or at least that's what i know so far), only to encounter an error saying ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_float instance instead of float
And since i have absolutely no experience with ctypes and its type conversions and stuff I can't go further to fix this issue. Also having separate functions for setting the at vector and up vector isn't a good idea, or at least it's not a good idea the way you implemented them since there are three values needed for each vector while the function requires 6 values thus resulting an error saying something like expected 6 values, got 3.
Thank you

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2021-04-19 04:33:53

Hm, I think I messed up setting the new orientation value. It was supposed to store 3 values you pass it into a 6 value local variable and then update all 6 values together, the 3 being for either one. I re-uploaded v1.4, see if that fixes it. Also, here's the relevant code:

        self._orientation = [0.0,0.0,0.0, 0.0,1.0,0.0]

...

#set listener orientation ("at" vectors)
    def _set_at_orientation(self,pos):
        self._orientation[:3] = pos
        x1,y1,z1, x2,y2,z2 = map(int, self._orientation)
        al.alListener3f(al.AL_ORIENTATION, x1, y1, z1, x2, y2, z2)

    def _get_at_orientation(self):
        return self._orientation[:3]

#set listener orientation ("up" vectors)
    def _set_up_orientation(self,pos):
        self._orientation[3:] = pos
        x1,y1,z1, x2,y2,z2 = map(int, self_orientation)
        al.alListener3f(al.AL_ORIENTATION, x1, y1, z1, x2, y2, z2)

    def _get_up_orientation(self):
        return self._orientation[3:]

...

    at_orientation = property(_get_at_orientation, _set_at_orientation, doc="""get/set "at" orientation""")
    up_orientation = property(_get_up_orientation, _set_up_orientation, doc="""get/set "up" orientation""")
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-02-23 18:04:14

I tried a lot to set the rolloff of the sound a little bit, ie if a player goes 20 steps it goes down permanently, but it won't adjust, I tried a lot of values.
This is my code
import os
os.add_dll_directory(os.getcwd())

from openal import *

class SND:
    def __init__(self):
        self.listener=Listener()
        self.player=Player()
    def Play(self, filename="", ox=0, oy=0):
        sound=LoadSound(filename)
        self.player=Player()
        self.player.position = (ox,oy,0)
        self.player.add(sound)
        self.player.loop=True
        self.player.rolloff = 10.01
        self.player.play()

    def update(self, px, py):
            self.listener.position = (px,py,0)

battle.net tag abdallah#22878 the new one because i lost my previous account
my facebook

2022-02-26 06:22:01

@41
Whups, missed this. I believe the rolloff factor is between 0.0 and 1.0, so it always has to be set within that range. The higher the value, the shorter the drop off, so if its set to something like 0.01 it won't drop off for quite a distance, but if set to 1.0 will drop off right away.

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

2022-03-02 21:32:10 (edited by blindLightning 2022-03-02 21:32:36)

hey,
when trying to run the examples i get this error.
AttributeError: function 'alcGetStringiSOFT' not found                                                                 
how should i fix this?

One of the lead developers of the Final Hour audio game, currently in beta.
https://finalhour.lowerelements.club

2022-03-03 01:19:38

@43
That error is usually from a mismatched OpenAL version. You see, there are two versions of OpenAL, the [official] version, and the open sourced [OpenAL Soft] version which everyone uses. The official one is outdated, and if you have it installed your system will default to it, causing errors like this. Unless its needed for something else, you should uninstall it to resolve the issue. Something else you can add to the script to help it find local dll's if it becomes and issue is:

import os
os.add_dll_directory(os.getcwd())
from openal import *
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-03-03 01:35:29

all right thank you, i'll give that a shot as its used in other stuff i have on my system.

One of the lead developers of the Final Hour audio game, currently in beta.
https://finalhour.lowerelements.club

2022-03-03 01:48:25

If its absolutely required on your system, OpenAL Soft includes instructions on how to overwrite the outdated installed OpenAL binaries, both are compatible with each other and shouldn't conflict with whatever else requires OpenAL on your system.

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

2022-03-03 02:00:47

well, i uninstalled openal because i don't use the program any more so it was unimportant.
I've sorted that error but now i get this traceback.

  File "C:\Users\user\Documents\OpenAL_Py_Lite\OpenAL_Py_Lite_v1.4\3D_Audio\OpenAL_3D.py", line 5, in <module>
    from openal import *
  File "C:\Users\user\Documents\OpenAL_Py_Lite\OpenAL_Py_Lite_v1.4\3D_Audio\openal.py", line 1964, in <module>
    al = lib_openal()
  File "C:\Users\user\Documents\OpenAL_Py_Lite\OpenAL_Py_Lite_v1.4\3D_Audio\openal.py", line 66, in __init__
    self._lib = ctypes.CDLL('OpenAL32.dll')
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

One of the lead developers of the Final Hour audio game, currently in beta.
https://finalhour.lowerelements.club

2022-03-03 02:10:42 (edited by magurp244 2022-03-03 02:14:53)

@47
Hm, That may have to do with the OpenAL Soft binary being 32 bit or 64 bit. To solve that you can download the OpenAL Soft binaries, and in the bin folder are two directories, win32, and win64. In each of those is a file called soft_oal.dll, rename whichever one you use to OpenAL32.dll and replace the OpenAL32.dll in the examples folder with it.

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

2022-03-03 02:11:25

allright, thank you

One of the lead developers of the Final Hour audio game, currently in beta.
https://finalhour.lowerelements.club

2022-03-06 16:52:01

I seem to be receiving the same error as Lightning, though I am not able to follow the steps to fix it. I downloaded the ZIP file you redirected to, but I'm not sure where it goes.

-----
YouTube
GitHub
Discord: @tunmi13#1880