ComputerCraft icon indicating copy to clipboard operation
ComputerCraft copied to clipboard

[Bug] PlaySound can't play more than one note at the same time while PlayNote can.

Open Extamov opened this issue 7 years ago • 8 comments

Version: 1.80pr1 build 04 MC Version: 1.12.2

peripheral.wrap("right").playSound("minecraft:block.note.harp",1,1.1892071)
peripheral.wrap("right").playSound("minecraft:block.note.bass",1,0.59460354)

If you will try to run this code, it will not play both sounds

peripheral.wrap("right").playNote("harp",1,15)
peripheral.wrap("right").playNote("bass",1,3)

But this one works.

Why is that?

Extamov avatar Jan 27 '18 23:01 Extamov

To quote the original PR (#237):

To prevent sound pollution, sounds are limited to once per tick. However, up to 8 notes can be played per tick to allow for chords. If a note is played, then this will not allow a sound to be played in the same tick as well.

It's worth noting that some sounds last substantially longer than notes (most notably jukebox songs) and so you definitely don't want people starting more than one of these in a tick!

SquidDev avatar Jan 28 '18 00:01 SquidDev

@SquidDev I guess I would not be able to use playSound for creating music.

Not sure why playNote and playSound("minecraft:note") is that different.

I can use sleep(0) for playSound but I can hear that they are not playing at the same time.

That not a good idea to limit sounds to one per tick.

Extamov avatar Jan 28 '18 06:01 Extamov

Not sure why playNote and playSound("minecraft:note") is that different.

The issue is that we know that notes don't last a long time, and so it's OK to have a lot going on at once. However, there's no way of knowing if an arbitrary sound lasts a fraction of a second or 5 minutes, and you definitely don't want people spamming the latter!

I guess we could look into a config option for maximum number of sounds in a tick, but I think the current setup is at least a good default.

SquidDev avatar Jan 28 '18 08:01 SquidDev

@SquidDev Requiring a delay for playSound wont fix the problem.

Using a delay to spam is possible too for 5 minute sounds.

I suggest you to just make it act like playnote and not require a delay

Better add an option in config for playsound

Extamov avatar Jan 28 '18 09:01 Extamov

@ExtendLord would an 'orchestra' of computers work for you in your current situation. I think that will get around this limitation.

Lupus590 avatar Jan 28 '18 14:01 Lupus590

What about a boolean in config (enforceable server-side) to disable the sound per tick limitation (perharps with a warning on description telling the server admin about the unwanted consequences)?

vico93 avatar Jan 28 '18 22:01 vico93

Removing the limit would be Very Bad. This is because if you spam sounds too fast you can crash Minecraft or freeze it really badly. A config option could be added.

Restioson avatar Feb 04 '18 06:02 Restioson

Thats what i proposed

vico93 avatar Feb 05 '18 09:02 vico93