Sound for a large area?


I was wondering how I could apply sound to a large area? Currently, I only know how to do apply sound to my game using nodes, but nodes are 1 point in space. If I wanted to apply sound to a river, for example how would I a) find the coordinates for the entire river path and b) create a more “stretched” sound area? Thanks :slight_smile:

Just add a sound node that is as far away from you as the river I would say. The nearer you are to that river the closer your river sound node should be.

I learned that game development is much about fake :wink:

I don’t know whether it’s possible, but you could add some invisible bounding boxes (from a cube for example) and then check whether the player is inside the bounding box and relative to the distance to the center which is your river the sound plays with a higher or lower volume. Depending on how your river path looks like you might have to add several bounding boxes. Maybe you even can create them in code.

Why not just have a spline along the river and move one sound source along that based on closest distance to the player?

Edit: You could even make it a nice library and make a PR for the engine :smiley:


But wouldn’t that create uneven sounds across the river? Also, what if the river were, say, in the middle of the map? Maybe a directional sound node that plays in the direction of the river path?

So a “mobile” sound node that moves to the player if the player is within x distance from the river’s middle axis? That sounds interesting. :open_mouth:

Just move it along the spline itself, at the point (of the spline) that is closest to the player (each frame). That way the sound will always come from the direction of the river and the distance resolves itself automatically.

You could even make the points of the spline have metadata as to what sound to use to have more dynamic (?) parts of the river have different sounds that blend from one to another along the spline.

1 Like

Yeah exactly what I meant more or less. just fake it that it sounds greate :wink:

I’ll be needing something like that too for laser beams :slight_smile: Even though it might be more realistic to only have the laser source make noise, it’s much cooler to hear the whole beam buzzing.

You could extend that idea with the splines and take the minimum distance to a set of splines.
distance = min(distSpline1, distSpline2)
That would allow for more irregularly shaped areas:

Distance functions could be used to make this work with arbitrary, combined shapes in 3D. I’ll just leave that here for now:

What is a spline exactly? O.o

Interesting. I will have to figure out how to implement this since I am still quite new. Thanks :slight_smile:

Even though the fundamentals of distance functions / distance fields are not as complicated as it might look, i can image that implementing such a sound system can get complex very quick. And it might be complete overkill because:

The nice thing about signed distance functions is that you can trivially detect if you’re inside a shape. So you would know when you’re “inside” the river and then you can for example play the sound at full volume for all channels (sound node position = cam position).

It’s also very efficient. Defining shapes is a matter of combining the functions: Inigo Quilez :: computer graphics, mathematics, shaders, fractals, demoscene and more

– sorry, messed up this post. I was trying to reply to you @Kiddolioable

Wikipedia explains splines quite well.

There are also lots of libraries for splines and closest distances etc.

Thank you :slight_smile:

This video is fantastic in case anyone was curious :slight_smile: