Play the same sound track from multiple sources

Adding immersive ambient audio to our games would be much easier if we could emit the same audio loop from multiple parts and attachments at their own respective volumes. Attempting to do this currently will result in sound loops being out of sync, which sounds bad, plus playing a single sound is likely more performant than multiple.

I find myself developing involved scripts that use multiple locations to calculate the volume for a single non-diegetic audio loop using raycasting and distance checks relative to the camera. I’m okay with doing this, but these sounds are coming from volumes in the world and that should be reflected in the right/left (or even surround) audio channels.

Some example uses:

  • Water sounds could emit seamlessly along a winding river. No scripting required.
  • Narrow peninsulas could play the same ocean sounds on both coastlines for a more pleasant listening experience. No scripting required.
  • Large collections of trees/foliage could emit a variety of immersive sounds seamlessly. No scripting required.
  • With scripting, immersive wind and rain sounds could emit from open windows and doorways on the left/right.
  • This would give scripters advanced general control over left/right channels by placing parts around the camera.
27 Likes

This would also come in handy for things like guns where you want to play the same sound rapidly. Right now I have to clone a sound to prevent weird stuttering. This would solve that issue and let me play one sound.

1 Like

Multi-sound systems. Hmm. I do support the idea when I need to experiment with playing one sound from multiple sources, such as the speakers in one mall.

It is not possible to play sounds synchronously for now without bumping into stuttering or desyncs.

3 Likes

What I’m trying to describe is that the sounds wouldn’t play separately. The idea is that many arbitrary sounds could have perfectly synced TimePositions; This would need to be done on an engine-level to prevent distortion.

Here’s a snippet that should help explain the distortion I’m talking about. It creates sounds on the right and left of the camera and plays them simultaneously (this should sound fine), then it plays one sound after another but tries to sync them using TimePosition (this should sound distorted.)
Just open studio, press run, then enter this in the command bar while wearing headphones:

local createSound = function(name)
	local part = Instance.new("Part")
	part.Anchored = true
	part.Size = Vector3.new(1, 1, 1)
	part.Name = name
	
	local sound = Instance.new("Sound", part)
	sound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
	return part, sound
end

if not game:GetService("RunService"):IsRunning() then
	warn("Must be running to hear sounds!")
end

local rightPart, rightSound = createSound("RightSound")
local leftPart, leftSound = createSound("LeftSound")

game:GetService("ContentProvider"):PreloadAsync({rightSound})

local cframe = workspace.CurrentCamera.CFrame
rightPart.CFrame = cframe * CFrame.new(8, 0, 0)
leftPart.CFrame = cframe * CFrame.new(-8, 0, 0)

rightPart.Parent = workspace
leftPart.Parent = workspace

for i = 1, 2 do
	if i == 1 then
		print("Playing simultaneously")
		
		rightSound:Play()
		leftSound:Play()
	else
		print("Playing with delay")
		
		rightSound:Play()
		wait(0.125)
		-- Try to sync left with right after right has started
		leftSound.TimePosition = rightSound.TimePosition
		leftSound:Play()
	end
	
	leftSound.Ended:Wait()
	
	rightSound:Stop()
	leftSound:Stop()
end

rightPart:Destroy()
leftPart:Destroy()
2 Likes

I feel like another way to go about this would be to add the ability to play (or pause or stop) multiple sounds at the same time. Some times it is necessary to have multiple different sounds play at the exact same time. One case I can think of is having multiple P.A. speakers spread around a facility. I’d have a unique audio play for each location based on where they are (the motives for this don’t really matter, although an example would be a monster breaching containment, and each location having their own unique safety protocol), which would require multiple different sounds. However, to keep them all at sync, I’d need them to run at the exact same time. This is currently impossible, and so far all of my attempts at correcting this issue have failed, as the sound is always ultimately out of sync.
Perhaps adding Play(…), Pause(…) and Stop(…) functions to the SoundService could do the trick?

3 Likes

The problem is when a new location is streamed in or created and needs to be synced with the group.

Maybe a property of SoundGroup that syncs sounds that have the same assetId?

1 Like

Bump. The recent Volumetric Sounds update is nice but not being able to play audio in-sync from multiple sources is still a major pitfall on Roblox. I don’t know if it would need its own full-on feature addition, maybe just some way to ensure Sound:Play() doesn’t delay by an arbitrary amount so we can call it on multiple Sounds. Even calling it for each Sound on a separate thread doesn’t seem to make a difference.

2 Likes