ID:2443576
 
Not a bug
BYOND Version:512
Operating System:Windows 10 Enterprise
Web Browser:Firefox 66.0
Applies to:Dream Seeker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:

When a sound uses the SOUND_UPDATE flag on channel 0, it affects all sounds rather than just itself.

Normally the variables of a sound datum should only apply to all sounds when two things are true: A file is not present for the sound ("null sound") and it's set to channel 0.

Unfortunately, when modifying a sound with a file on channel 0, it seems to apply to all sounds, even when there is a file, changes to status involving SOUND_UPDATE apply to all sounds.

Numbered Steps to Reproduce Problem:
- Play some sounds on various channels.
- Create a sound with a file on channel 0.
- Play that sound
- Change that sound's status with SOUND_UPDATE involved (paired with the pause or mute flags)
- All sounds stop playing


Expected Results:

Only the sound which has its status changed is affected by the flags.

Actual Results:

All sounds are affected.

Workarounds:

Currently, to use a nonzero channel for the sound, however this adds complexity to another issue where a channel must already be populated with a sound in order for sounds with the SOUND_UPDATE status to play at all.

Lummox JR resolved issue (Not a bug)
You can't modify a sound on channel 0 because starting a sound on channel 0 means "Just play it anywhere." That sound has no channel reference to allow it to be changed after the fact.

Modifying volume or other parameters universally is, however, a desired behavior in some cases. That's exactly what channel 0 updates are meant to be used for. Likewise, playing a null sound on channel 0 is a universal stop.
So it's entirely intentional that a sound with a file and channel of 0 should stop all sounds if it's stopped?

Because if that's the case the reference needs an update, and that this means it's impossible to use SOUND_UPDATE on a sound without a defined channel without also affecting all other sounds, regardless of channel.

It seems like the fix that makes SOUND_UPDATE ignore the file in order to avoid the nonsensical "update a sound that isn't playing" is also clobbering the ability to use SOUND_UPDATE without defining a channel.
In response to Bravo1
Bravo1 wrote:
So it's entirely intentional that a sound with a file and channel of 0 should stop all sounds if it's stopped?

Not with SOUND_UPDATE; current behavior is that the file is ignored on SOUND_UPDATE. But playing a null sound on channel 0 without the flag will stop all sounds.

Anything else with SOUND_UPDATE on channel 0 should be interpreted as a change to all channel settings.

Because if that's the case the reference needs an update, and that this means it's impossible to use SOUND_UPDATE on a sound without a defined channel without also affecting all other sounds, regardless of channel.

It's impossible to use SOUND_UPDATE on a sound without a defined channel because there's no channel to use it on. If you fire off a sound with no channel, you're basically telling the engine to use any channel available and that you don't care what happens to it after that. So the engine will not map that sound to a DM-defined channel number and will not allow updates on that sound; the only way to affect that sound from this point is to change channel settings for all channels or to stop all sounds. That's always been the case.

In 513 client.SoundQuery() can be used to get some channel info, so I think it might possibly be reasonable to assign channel numbers to sounds with no defined channel when the query happens, which would allow subsequent updates.

It seems like the fix that makes SOUND_UPDATE ignore the file in order to avoid the nonsensical "update a sound that isn't playing" is also clobbering the ability to use SOUND_UPDATE without defining a channel.

Any such ability should not have existed, though; it makes no sense. Either you want to update all channels or you want to update a specific channel, but there's no such thing as updating an undefined< channel.
In response to Lummox JR
Lummox JR wrote:

Any such ability should not have existed, though; it makes no sense. Either you want to update all channels or you want to update a specific channel, but there's no such thing as updating an undefined< channel.

Not channel, a sound. If I have a sound that constantly plays but I'd like to update it as it plays, that's no longer possible unless I give it a defined channel.


Before the change I could create a sound with channel set to 0 and I could update that sound without affecting any other sounds. Now that isn't possible.


From the reference:
SOUND_UPDATE updates the settings for the sound currently playing on the specified channel. If this flag is not set or no channel is specified, the sound will start again from the beginning.

Nothing describes anything about the flag affecting an entire channel, or all sounds. So if this wasn't the intended behavior before then the reference was improperly explaining SOUND_UPDATE since its inclusion.

Should it not be possible to update a single sound without giving it a defined channel?


In response to Bravo1
Bravo1 wrote:
Not channel, a sound. If I have a sound that constantly plays but I'd like to update it as it plays, that's no longer possible unless I give it a defined channel.

That's how it's supposed to be. You can't update a sound that has no channel and never could. The only thing you could ever do was update a specific channel, or update all channels. If you never specified a channel, there's nothing to update unless you take the shotgun approach and do everything.

Before the change I could create a sound with channel set to 0 and I could update that sound without affecting any other sounds. Now that isn't possible.

I don't see how it was ever possible before. If you didn't specify a channel then you don't have anything to update.

From the reference:
SOUND_UPDATE updates the settings for the sound currently playing on the specified channel. If this flag is not set or no channel is specified, the sound will start again from the beginning.

Nothing describes anything about the flag affecting an entire channel, or all sounds. So if this wasn't the intended behavior before then the reference was improperly explaining SOUND_UPDATE since its inclusion.

I agree with you that the reference should be updated to reflect the proper behavior.

Should it not be possible to update a single sound without giving it a defined channel?

No, because it makes no sense. When you play a sound without defining a channel, it's fire-and-forget and you give up the ability to update/stop that sound without updating/stopping all sounds.

I think where we're not on the same page is that you might think that a /sound datum is a stateful object and that's what gets updated in SOUND_UPDATE. That's not the case, though. The datum is really nothing more than a collection of instructions to give to the client as output, in much the same way that you send text to browse(); updating that text does not update what's in the browser control.

Instead, SOUND_UPDATE can only ever apply to a channel or to everything, because it's either a channel or everything that you're updating.
I don't see how it was ever possible before. If you didn't specify a channel then you don't have anything to update.

I'll see if I can get a test case

I think where we're not on the same page is that you might think that a /sound datum is a stateful object and that's what gets updated in SOUND_UPDATE. That's not the case, though.

Well I may be mistaken in that regard but I only had the reference to go by when it came to the /sound datum and based on all the wording surrounding it, it seems like it's a stateful object. If that wasn't the case then the wording has been off for a very long time.