2018-04-19 09:36:21

Hello everyone!
OK, I'm going to try to explain the issue I am having in a few lines.

I am trying to build a binaural scene in a game. However, the sounds that play only represent their center position on the screen, x/2 and y/2.

This works fine for persons, cars, and other small objects however, when there is a door or a wall, that occupies 5 squares or the whole x or y in the case of walls, I am clueless as to how to implement this into sound.

Does anyone have any ideas?
I don't think this has nothing to do with the sound library that I use, rather it's to do with maths.

I thought about creating multiple coppies of the sound, one for each position, but people say it's a really bad idea.

So what do you suggest?

Thanks.

ReferenceError: Signature is not defined.

2018-04-19 19:22:41

I think objects with odd shapes such as cubes instead of spheres are hard to do. A dirty workaround would be to change the position of the sound as the player moves.

Roel
golfing in the kitchen

2018-04-19 23:44:06

When working with spacial environments in games I think designers tend to use reverb, echo, and filter effects like band filters and such to better represent open spaces or environments, perhaps you could use a similar approach for spacial positioning within a given space to determine the position of adjacent walls or doors? If you like I may be able to dig up some articles on the subject, and I do have some python OpenAL EFX examples in my repository. Although another approach could also be to use a sonifier as a kind of representational conversion of a literal map.

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

2018-04-20 16:10:07

I hope i understand your question properly.
If not my apologies.

What i think the question is.
How to represent rooms sizes intersections and reflections.

So based on that here is what i do with the binaural system i use.

Example: You stand in the middle of a room.
The room is a large sized room.
In that room there is a object  in the left front of you.
We will asume this is a pillar.

Now what we need to do is use mathmetics for calculating distances obstructions and Size

Here's how i would calculate it using 3d vectors.
If you need the formulas for calculating  let me know then i will add them to the post.
As right now i am just pointing out the requirements.

1: Calculate distance between you and the source of the sound.
This is simply done with vector subtractions and positioning.
You could even get all corners of your vector and its rotation.
Then calculate the edges to see which one is closest.
So you can determine the closest correct distance value.
Anoteher way would be getting a single center point and point of source.
This can work as well but i prefer more detailed calculations so you get more accurate reflections and reverb of sounds.

2: Obsctructions / collissions.
This is important of course since sounds can be blocked / muffled when theres a object between you and the sound source.
Again there are multiple ways to do this.
And to be accurate on the sound bounces.

So multiple ways:
RayCasting
This is a method that is easy to work with.
With  this you basically draw a line between you and the sound source.
And then check for what ever is blocking in between.

An ugly way of detection.
I personally dont like this one  but as its an possibility why not.
Intersections.
And invisible block is rotating along side with you.
You can use that block to check for intersections.
Its like a invisble collission that tells you whenever a object is obstructing you.
If so, and the sounds source position is behind that collission.
Then adjust its values.

But since you are a programmer i hope i can be more specific but since i dont know what language you program in.
Or what libraries you use i cant really pinpoint a direct calculation.

Based on distance:
Use reverb properties, and use the distance calculations for setting the properties of reverv.
And calculate the best results for it.

For example:
Distance between you and source.
When your in a large room increase the reverb values.
And simply decrese them when the distance is getting lower.
There are many values to assign to a reverb system.
Atleast what i personally use.
So you can fine tune it for that.

Obstructions goes the same but not just reverb.
You can use for example sound distortion to achieve this.

As for the main sounds.
The rotation base of the character should have low pass and high passs for getting good results for determination of the position.
This should not be based of distance of course but on rotation.
Which is easy to calculate in radience degrees.

I would  suggest to use RayCasting.
There are propably better ways out there.
But for me its optimised low on memory and it gives the results needed.

A long reply sorry for that,
But since i dont know if that i have understood the question correctly.
Or knowing what language you program in i cant really provide example codes for it.

If you use C++ . C Sharp, JAva i can provide examples.
As for python and others i am not  familiar with them.

Simple distance calculations.
The example is in C Sharp.
But you get the idea.

float FirstX, SecondX, FirstY, SecondY, ObjectWidth, ObjectHeight;
            if (ObjectOne.X > ObjectTwo.X)
            {
                FirstX = ObjectTwo.X;
                ObjectWidth = ObjectTwo.Width;
                SecondX = ObjectOne.X;
            }
            else
            {
                FirstX = ObjectOne.X;
                ObjectWidth = ObjectOne.Width;
                SecondX = ObjectTwo.X;
            }
            if (ObjectOne.Y > ObjectTwo.Y)
            {
                FirstY = ObjectTwo.Y;
                ObjectHeight = ObjectTwo.Height;
                SecondY = ObjectOne.Y;
            }
            else
            {
                FirstY = ObjectOne.Y;
                ObjectHeight = ObjectOne.Height;
                SecondY = ObjectTwo.Y;
            }
            float FirstMax = Math.Max(0, SecondX - FirstX - ObjectWidth);
            float SecondMax = Math.Max(0, SecondY - FirstY - ObjectHeight);
            var DistanceResult = (float)Math.Sqrt(FirstMax * FirstMax + SecondMax * SecondMax);
       
Now that we have the distance between the 2 objects.
We can set the reverb properties for it.
And also volume etc.

After that we need to use RayCasting or other options for setting higher detail on the reverb properties.
In my own system, i use more properties.
Like velocity, etc etc.
Heres my own snippet.

//This is a basic 3d structure.
var PositionAttributes = new FMOD._3D_ATTRIBUTES();
//Positioning structure.                   
var PositionStructure = new FMOD.DSP_PARAMETER_3DATTRIBUTES();
                    //Set sound position if attached to player.                   
                    if (CurrentSound.Attached)
                        CurrentSound.SoundPosition = new OpenTK.Vector3(Character.Data.Information.Camera.Position.X, 5, Character.Data.Information.Camera.Position.Y);
                    //Create new vector for relative location.
                    var RelativeLocation = OpenTK.Vector3.TransformNormalInverse(CurrentSound.SoundPosition - Character.Data.Information.Camera.Position, Character.Data.Information.Camera.camMatrix);
                    //We invert rotation for proper rotation calculation.                   
                    var Rotation = OpenTK.Vector3.TransformNormalInverse(Character.Data.Information.Camera.Orientation, Character.Data.Information.Camera.camMatrix);
                    //Normalize.
                    Rotation.Normalize();
//Normal degrees from radience using my own function for it in case you wonder.                   
Rotation.X = Player.PlayerCamera.GetDegrees();                   
                    //Set new x y z information.                                       
                    PositionAttributes.position.x = RelativeLocation.X * Rotation.X;
                    PositionAttributes.position.y = RelativeLocation.Y * (Rotation.Y / 2);
                    PositionAttributes.position.z = RelativeLocation.Z;
                    //Set velocity for x y z.
                    PositionAttributes.velocity.x = Character.Data.MoveMentSpeed * 10;
                    PositionAttributes.velocity.y = 0;//Character.Data.MoveMentSpeed;
                    PositionAttributes.velocity.z = Character.Data.MoveMentSpeed * 10;
                    //Assign
                    PositionStructure.relative = PositionAttributes;
                    //Now we calculate and transform the information into byte array
                    byte[] PositionByteArray = Extra.Tools.getBytes(PositionStructure);
                    //Update position data                   
                   
It probably would not make a lot of sense for you.
But this is basically showing the order of processing the sound.

So now we have distance calculations done.
And also we have the rotation and positioning done.
Now we need collission.

Here is a small snippet  for adjusting reverb properties in distance.
This is only for distance adjustments.
I am sure you understand the point of the code.
And what it is doing.
It would propbably not help you with your own code.
but it gives the idea.

if (Character.Data.Information.ClosestObjectDistance < 10)
                        {
                            CurrentSound.DSPEffect.FmodDsp.setParameterFloat(9, Character.Data.Information.ClosestObjectDistance + 170);
                            CurrentSound.DSPEffect.FmodDsp.setParameterFloat(10, Character.Data.Information.ClosestObjectDistance + 17);
                            CurrentSound.DSPEffect.FmodDsp.setParameterFloat(11, Character.Data.Information.ClosestObjectDistance + 34);
                        }

So above,
I set a few parameters for distance of the 2 objects.
And modify the reverb properties.
In my case / system there are 12 values in the reverb controller i can adjust.l
So for the intersection of the pillar.
We would use the same idea as above but.

For example,
If object1 intersecting with object 2 and 3
Get distance between source sound and the obstructing object.
Get distance between you and obstructing object.
Get distance between you and sound source.

The modify the reverb to achieve the sound you wish.
For muffled sound or more low pass or high pass etc etc.
Early reflections, late reflections, and so on.

Anyways,
A long reply.
And i hope again that i understood your question.
If not this post is pretty much useless . smile.

Regards,
XSense

Put your coding where your mouth is.