# Volumetric Sound

I wanna make volumetric sound system. Basically shoot rays, reflect em N amount times and create new emitters, but for some reason it always going wrong

``````local COS = math.cos
local SIN = math.sin
local EXP = math.exp
local ABS = math.abs
local RANDOM = math.random

local SOUNDEMITTER_FOLDER = workspace:FindFirstChild("SoundEmitters") or Instance.new("Folder")
SOUNDEMITTER_FOLDER.Name = "SoundEmitters"

local function RandomCFrame()
math.randomseed(os.clock())
return CFrame.Angles(
)
end

local function RandomCFrameInDirection(direction, range)
direction = direction.unit

local x = COS(theta)*COS(phi)
local y = SIN(phi)
local z = SIN(theta)*COS(phi)

return CFrame.lookAt(direction, direction + Vector3.new(x,y,z), Vector3.new(0,1,0))
end
``````
``````function SWS.PropogateSoundWaves(p)
local SoundEmitter = p.sound or p.soundemitter or p.Sound or p.SoundEmitter
local NumRays = p.rays or p.Rays or p.NumberOfRays or p.numberofrays
local NumReflections = p.reflections or p.Reflections or p.NumberOfReflections or p.numberofreflections
local Direction = p.direction or p.Direction or p.dir or p.Dir
local Range = p.range or p.Range
``````

Main problem: Instancing new Sound Emitters, calculating Volume and PlaybackSpeed
Baically sound occlusion with reverb and echo, using raycasts and material lookup table.

Nobody knows how your script works. Can you explain at least a little??

Well, variables of math is just micro-optimization, because itâ€™s needs to run every frame, 8 rays, 4 reflections, cframe functions - just read name, random cframe and random cframe in direction, SWS.PropogateSoundWaves is just, does nothing for now

Why do you need your sounds to behave in this way?

Realism? 3D effect? Deep feeling? multiplie answers, but those is mostâ€¦ understandable