How to affect audio direction

Hello!
How would I change a sound to go towards a specific direction?
Imagine in the image below that the square is the sound origin and the open end of the exterior shape is the direction I want the sound to travel, but I don’t want the sound to go past the other walls/lines.
Audio Question
Sorry for the crude example!

You could make a part and put the sound inside the part.
Make a bodyvelocity or something and make the part go in the direction you want. As soon as the part starts moving, play the sound.

I don’t know how you would make soundproof walls though…

1 Like

I think that sound instances has no feature to achieve that.

Maybe you could handle this on client side, and “detecting zones”. When player is the zone that is not covered by a wall, play the sound in client (or increase volume), outside the zone, decrease volume or stop sound
You could detect those zones using touching events, or region, or even raycasting

3 Likes

Is the sound a constant one, or does it change like music or a sound effect?

If it’s constant how about you put a series of small Parts in a row, each with the same sound in them.
Make the RollOffMinDistance and RollOffMaxDistance very small in the first one, then make it larger in each of the next Parts.
Basically a line of sound parts, each one creating the sound in ever expanding RollOffMaxDistances so the final ‘map’ of the sound looks like a rough cone shape.

1 Like

From my understanding, you want the sound not to go through walls, correct? If so, that isn’t possible- and if that wasn’t it, chances are you are out of luck for what it actually was as Roblox’s sound system is super limited in what it can do.

Edit: Re-read it, now I see what you mean, this is not possible. Audios are just, and only can be a sphere.

1 Like

So I could use something similar to zoneplus and make the audio only audible when in that part? Is that possible?

1 Like

You can raycast from the client to the sound part, and when the raycast is unblocked, play the sound or turn the volume up.

1 Like

It’s not a constant sound, it’s music. I considered adding multiple parts with the audio but then realized that unless I made the rolloff distance the exact same but then when you went out of range the sound would immediately cut off and it’d be weird.

1 Like

What if there are multiple clients?

Exactly, you could use a module like that. I prefer not using that module specifically, and just build a more basic function that reads the zones, as I said even by only raycasting if the raycast is not blocked by a wall, keep the volume up, if its blocked by a wall, turn the volume down

1 Like

What about a long skinny sound Part?
The way sounds from Parts are now being done the sound is emitted from the entire part, not just the center.
In your diagram make the sound Part the size of the square in the center, but resize it past the open end of the box.
Make your RollOffMaxDistance the distance from the red part to the walls.
It won’t spread out (maybe if it’s a wedge, I haven’t tried that though) but it’ll seem like you can hear the sound out the open end of the room, just not out the walls.

1 Like

How would I change the audio to emanate off the entirety of the part instead of just the middle?

It should already do that as I stated previously:

1 Like

I achieved some directional (note - not vertical) audio using Roblox’s Pathfinding system to find the shortest path to the audio source, determining the last visible waypoint on the path and creating a second duplicate sound at the location of that waypoint.

I got my inspiration for this system from the game Rainbow Six Siege - which has a very complex ambient directional audio system.

If you require more understanding on directional audio, I recommend watching SmartEveryDay’s video on the subject.
SmarterEveryDay - YouTube

Version 1
(2) Sound Engine - YouTube
Version 2
(2) Realistic Sound Engine v2 (Use Headphones) - YouTube

Getting the audio to sound correct is the most difficult part of this, as you’ll need to adjust distory, eq and reverb to estimate what the sound would be like after traveling the distance and path.

You also need to consider the cutoff point of when the audio is no longer hearable, whether by pure distance from the sound or density of the path to make it to user.

The steps I used to create this is something like this:

  1. Get the current position of the player (Pos1)
  2. Get the current position of the sound (Pos2)
  3. Cast a ray to see if the sound is within line of sight (if so, simply play the audio as is) - if not…
  4. Using Pathfinding to path from Pos1 to Pos2 (Path1)
    (Advanced filtering - skip if unsure)
    4.1 Block the current path using Pathfinding Modifiers and large non-collidable transparent blocks to see if the sound would also come from a second location (see video one where the sound could come from both sides of the wall)
  5. Cast a ray along the waypoints of the path from the player towards the sound - until you cannot see a waypoint (SoundPosition)
  6. Create a duplicate sound (within a non-collidable transparent Part) positioned at SoundPosition
  7. Apply EQ/Reverb/Distortion/Volume and any other filters to make the sound fit the environment.

Of course, this requires creating a system for generating these sounds for both static and moving objects, which will vary the complexity, but this is a start to this sort of system.

3 Likes

This is not true for me as I tried putting it into a long part already and it still only came from the middle. Now I could just adjust the rolloff distances to be the same, but it wouldn’t fully achieve what I’m trying to get. If it works for you is there any way you could show me?

For the step of determining if the sound is within the line of sight, would it count if you are viewing the part through a semitransparent part?

Up to you, you could set up an whitelist for parts to ignore when ray casting

1 Like

This sounds promising. You could make a sound react this way. Depending on where the player is, it could also favor one side.

something like this.

Distance = (ThisPart.Position - PlrPosition).Magnitude
	if Distance < 20 
1 Like

It’s a Beta feature called Volumetric sounds.
I use it in a large, flat Part at my terrain water surface with wave sounds in it. Players at the water surface hear it, but as they walk away from the water the volume decreases.

2 Likes

Did you go to your Beta features in Settings and enable the Volumetric sounds?
The way it works is explained in the in the post I put the link to (there’s even a video of it working before and after the beta feature), but here they are again…

This feature is available for Opt-In Beta now!
If you would like to opt-in, open Roblox Studio and head to “File > Beta Features > Volumetric Sounds” and enable it!

2 Likes