How to affect audio direction

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

This wouldn’t work as there would be multiple clients and if I tried to make the part follow the player it would be messed up for everyone else. Plus, it would kind of ruin the static effect I was trying for where the sound would stay in one place and then slowly fade as you got closer but not have it go willy nilly out of the area I wanted the sound played in. This is difficult as it’s a rectangle shaped containment space for the sound.

Will try that, I don’t think I have that enabled so I’ll go try that and get back to you with the results. If this works it should solve my problem.

You will have to mess with it a bit. Seems lower sound volumes work best.
But all it all this is really nice and works well. Once you get how it’s working.

1 Like

Volumetric Sounds aren’t available in my beta features tab. They don’t show up. I only have ones in there that are recently released.

1 Like

well you could use raycast to get around that:

basically how the script works is that it raycasts in a heartbeat event from the player’s rootPart to the soundPart and if the result’s Instance is equal to the soundpart then we tween the volume to go from 1 to 0 and if the result is nil or not equal to the soundPart it just tweens the volume from 1 to 0:

-- StarterPlayer --> StarterCharacterScripts
local runService = game:GetService('RunService')

local character = script.Parent
local hrp = character:WaitForChild('HumanoidRootPart')
local params = RaycastParams.new()
params.FilterDescendantsInstances = {script.Parent}

local range = workspace.soundPart.Sound.RollOffMaxDistance
runService.Heartbeat:Connect(function()
	local direction = (workspace.soundPart.Position - hrp.Position).Unit * range
	local origin = hrp.Position
	local raycast = workspace:Raycast(origin, direction, params)
	if raycast and raycast.Instance == workspace.soundPart then
		game.TweenService:Create(workspace.soundPart.Sound, TweenInfo.new(0.25), {Volume = 1}):Play()
	else
		game.TweenService:Create(workspace.soundPart.Sound, TweenInfo.new(0.25), {Volume = 0}):Play()
	end
end)

very sorry for the late response, i wanted to reply yesterday but my internet was really bad.

2 Likes

No problem thanks for responding and the help! I’ll definitely try this method if I can’t find the beta feature that @Scottifly pointed out.

1 Like

If you go to SoundService inside the Explorer, there should be a property called VolumetricAudio, switch that to Enabled.

2 Likes

That’s probably why I didn’t see it. Thanks a lot!

You should mark @epicrobloxpro1994’s as the Solution so other people can also find the answer to the problem, and also so other people don’t see it as unsolved and keep replying to it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.