I have multiple sound emitter objects that play a sound to players in range and will constantly update the sound's x, y, z, and volume attributes.
When multiple of these emitter objects are playing the same sound file (but different sound objects) to the same player at the same time on different channels, glitches can be heard if the volumes of the sound objects are different (in my case, two sound objects with volumes 8 and 50).
Numbered Steps to Reproduce Problem:
1. Play two or three versions of the same sound file to a player on different channels
2. While the sound is playing, constantly send updates to the sound through sound.status = SOUND_UPDATE
Code Snippet (if applicable) to Reproduce Problem:
//Per server tick:
if(!(sound in M.soundChannels))
//Does not actually find the lowest channel from 800, but is computationally cheaper than other methods
//unless the list is sorted.
var/lowestChannel = 800
for(var/i in M.soundChannels)
if(M.soundChannels[i] >= lowestChannel)
lowestChannel = M.soundChannels[i]+1
M.soundChannels += sound
M.soundChannels[sound] = lowestChannel
sound.status = SOUND_UPDATE
sound.channel = M.soundChannels[sound]
var/dx = x-M.x, dy = y-M.y
sound.x = dx
sound.y = dy //sin(60) * (dy)
sound.z = 0 //cos(60) * (dy)
var/r2 = (dx*dx+dy*dy)//+sound.z*sound.z)
var/vr = volume/d2
var/intensity = (d2-r2)*vr
sound.volume = intensity
//world<<"[intensity] - [sqrt(r2)] - [M.soundChannels[sound]]"
listeners -= M
M.soundChannels -= sound
The same sound file is played on different channels with different parameters without problem.
One of the instances of the sound file will override the other, and will cause occasional "blips" and similar audio glitches
Does the problem occur:
Every time? Or how often?
In other games?
In other user accounts?
On other computers?
When does the problem NOT occur?
The problem is not as discernible when the sound objects parameters are similar.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)