The bug
Minecraft can only handle playing 247 different sounds at the same time. It's possible to exceed this limit by having enough sounds played simultaneously, such as by placing numerous armour stands on top of a waterlogged conduit which is underneath lava. This could be fixed by increasing the sound limit to something like 65527, which would be infeasible to achieve in conventional gameplay.
The fix
Code analysis by @unknown can be found in this comment.
Related issues
is duplicated by
Attachments
Comments


Bug still exists in 1.4.4
It is an old glitch. One I wish would be fixed.

Can confirm.

It makes sense to me that the number of sounds played at a given time would have a cap, however if that's what's going on the priority seems screwed up, for as you pointed out, blaze ambience seems to win out over everything.
I would suggest the following priorities:
1. Player Damage
2. Mob Death/damage
3. block change (pistons, buttons)
4. Hostile Mob ambience
5. Passive mob ambience
6. Constant sounds (water, lava, fire [including blaze burning noise], rain)
obviously I have missed some sounds (minecarts, explosions, drops) but I think you get the point

I don't know how involved it is to code but I always wondered why entity to sound relationship within a time slice is 1-to-1? Within certain radius, new sound from an entity/block should not be generated/processed/emitted if the same type of (other) entity has the sound still playing. At the very least, to preserve ambiance, this should be capped at 3 and no more. Playing tens or hundreds of cows mooing in a pen makes neither any sense nor actually sounds any good with sound bytes eventually cutting each other out, not to mention causing way too many issues to be anywhere near worth it.

What really should happen is the game needs to detect how many of a particular sound source is within earshot of the player and if it is over X number of units, it should transition to a single sound file representing the entire multitude. For instance, if I have a certain number of chickens nearby, it will play "smallchickengroup.wav", or "mediumchickengroup.wav" or similar, rather than trying to call individual chicken noises for each chicken. This would be less resource intensive and it would be much more pleasant overall by avoiding phasing, chorusing, and overlap in the sfx.
To add a little bit of sophistication to the mix, the game might also try and still call individual chicken noises for any in your direct line of sight, even if within a larger group, as this would mimic how our brains actually filter sounds.

STILL AN ISSUE IN 1.6.2. MOD PLEASE UPDATE.

Is this still a concern in the latest Minecraft version 14w03b? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

This still occurs in the latest snapshot (14w29b).

Confirmed for 1.8-pre2 (seems to be a tad bit better than before, but definitely still there).

so how can i restore my sound back to normal?...

Confirmed for 15w44b.
To reproduce, create a big pen and put too many mobs inside it.

Confirmed for 1.9-pre1

Question! Is this ticket about loosing sound randomly too? Like I have a lot of cows and sheep in the same pen but I am in a different world now, creative flat no mobs and I just lost my sound. Nothing is playing. No music no water/lava no placing blocks sound nothing at all. Fortunately I get it back if I restart the game. Or is my problem completely different?

Sounds like your problem is different. Maybe not completely different, but different nonetheless.

I've never been able to understand this glitch. Even if the sound would cause performance issues (probably why it's made to clip the sound), you usually get more issues for rendering the entities instead.
Additionally, @Nathanael Tronerud's idea sounds pretty good to me

Riding this track will stop the mine cart sound

Confirmed for 1.10.

Confirmed for 1.10.1.

@unknown's idea would be thousands of times more pleasant to listen to, it's just extremely hard to code because object-oriented programming. Each instance of a chicken, for example, plays a sound randomly regardless of nearby chickens. The only reasonable place to limit sounds created by large groups of things is by controlling the shared link, the sound engine itself. If I recall correctly, Minecraft's sound engine was not created by Mojang; so they might end up having to create a new sound engine and it only gets messier from there.

Can someone confirm for 16w32b?

Confirmed for 1.11.

Confirmed for 1.11.2.
It'd be really great if the sound engine didn't limit how many sounds could be played at once as I was building a noteblock song, but it ignores half the notes...

Confirmed in 1.12-pre3.

Confirmed for 1.12.

Confirmed for 1.12.2
Also Confirmed for 18w03b
Soon as this gets fixed we can finally get Audio loops and all the missing game audio we have been missing for years:

Please stop editing your comment, use the preview instead. And in general you can now delete it. The versions are added and the other half is off-topic.

Confirmed for 18w14a.

I can confirm this is still an issue in 1.13-pre release 5.
I'm not entirely sure, but it seems like it may have improved a tiny bit from 1.12.2 though.

Affects 1.13-pre6.
Placing numerous armour stands in lava on top of a conduit is an easy way to test this.

This can be fixed by increasing the count of "normal" channels in the Paulscode's Sound Libary. The default count is 28, so 28 normal (non-streaming) sounds can be played at the same time. If you call "SoundSystemConfig.setNumberNormalChannels(int)" with a value like 128, 128 normal sounds can be played in parallel. Choosing a high enough number fixes this issue.

Just an addition, if a creeper explodes in an ice spikes biome (snow blocks are the ground), the explosion sound doesn't play. Only the snow breaking sound plays.

Why reporter were changed !?

So that @unknown can update the affected versions instead of having to comment each time, since they've been more recently active on the tracker. (You're still recorded as the original creator in the history tab)

Affect 1.13.1

Is sound handled differently in 19w12a? Sounds do not appear to be cut off anymore, but can fail to play.

The patch notes for this snapshot says that sound system was rewritten to reduce stuttering.

Confirmed, they no longer cut off, but now just a lot don't play at all if there are many. Test scenario: Spawn a gazillion cows in a close space until they start squishing each other to death. Due to all the ambient sounds, most death sounds don't play. Really easy to see, due to all the red cows falling over and the rare death sounds.

Relates to MC-146297.

Why? Because it's also something with sound?

Both issues were affected by 19w12a.
This bug changed to sounds being blocked from playing instead of exchanging current playing sounds with new ones, and MC-146297 resulted in the same snapshot. They were likely caused by the same change in code, or the rewrite of the sound system entirely.

...despite it already being marked as such three hours ago?

I found that my audio randomly cuts out from time to time. Walking or running around, I can hear the noise from my speakers go silent for a second or two and the footstep sounds cutting out for that time. It isn't a hardware issue.
Can confirm for 19w13b. Sometimes, the eating sound is missing when you eat while it's raining. Opening doors, chests, is sometimes missing while the bubble sound is playing. Other sounds missing as well when many are playing the same time, which ruins the gaming experience. And when you throw an enderpearl, generally you can't hear yourself taking damages at the point of impact.

Having difficulty reproducing in 19w14a; potentially fixed.

Maximum number of concurrent sounds has been increased, so it's bit harder to hit limit (though it is still possible, for example with about 300 cows). Also, F3 menu now displays number of playing sounds.

With the test I mentioned in my second to last comment, I can no longer reproduce this issue, at least it's no longer obvious. But F3 shows something like "200/247+0/8", which I guess means that 247 was the maximum number of simultaneous sounds I had at any point, not 300 or more. Whenever I spawn more cows, I get so much server lag that I can't say for sure anymore if the bug is present.

Should we resolve this as fixed then, since you can't come across it without trying super hard and it's therefore effectively impossible to encounter in any notable magnitude?

Just as a note: second number is absolute limit, not high-water mark. And other pair is for streaming sounds (music, jukeboxes, etc).
As for closing: I'm not yet sure, since this should be enough for normal gameplay, but I can still hit limit on my machine.

I suppose you could rectify that by increasing the sound limit even more, but that might not be feasible.
Would it be at all reasonable to have the sound limit be a customisable feature, like render distance is, so it can be adjusted if framerate/memory/other issues become a big enough problem with too high a limit? Or would that just be unreasonable?

Fixed in 19w14a? Because it's very hard to reproduce now with the new sounds limit.

Why is there a limit at all? What's the downside of increasing it?

Limit is in OpenAL-soft library we are using. Seems like we can increase it all the way up to MAX_INT, but for now we are testing default settings.

I'd say a sound limit of 2147483647 would fix this issue.

I have to assume that there's some kind of performance or memory tradeoff or else they wouldn't make it configurable (I'd assume that the library uses a pre-sized array or something and using MAX_INT would allocate several gigabytes memory, but I'm not sure).

in 19w14b you can reproduce it by putting 3 working beacons and a lot of mobs nearby and start a melon farm and sometimes when you farm the melons they won't play the breaking sound

Still in 1.14 Pre-Release 1

Still in 1.14 pre-3, 1.14 pre-4 and 1.14 pre-5

Still in 1.14 Release

Still in 1.14.1 Release

Still in 1.14.2 Pre-Release 1 and 1.14.2 Pre-Release 2

Questioning whether this is the bug I'm experiencing in Minecraft 1.14.1. If I pause the game and return to it some of the sounds (walking on grass, breaking blocks, harvesting berries) become way louder. Moving the main slider doesn't fix this although some sounds do obey the slider.

No, it's not the same. Did you maybe change something about your audio setup (connected headphones, muted or unmuted something, etc.) in the meantime? Minecraft didn't deal very well with that.

Can confirm, can i have ownership as their is no user that owns this.

Sculk sensors can be used to easily achieve the sound limit.

still in 1.16.4

@unknown, while appreciated, it isn't necessary to confirm a report for a certain game version when it is already part of the "Affects Version" list. Understandable if you happen to miss it though, since it's fairly lengthy at this point.

still in latest release for snapshot and java edition

still in latest release for snapshot
Can confirm in 21w05a.

having a question does any have by any chance set the Friendly Creatures off at Music & Sound Options??? at my end have turn my to 100% and i can hear again

Game crashes on 1.16.4/.5 when cap is regularly reached (i.e. constant spider hisses). Turning sound off in menu helps to circumvent the issue when rejoining the world.

Can confirm in 1.16.5

I would like to request ownership of this ticket because reporter is deactivated

Can confirm in 1.17.1.

Such a concept does not exist on a bug tracker. This is not a forum, please only comment if you have additional relevant information.

Can confirm in 1.17.1.

It is a very annoying problem which makes the client more lagged or crash by sending so many messages to the console.You may know that calculating the square root of integers between 0 and 1M and output to the console is more than 10 times slower than only calculating them.So the carpetmod decides to avoid the annoying messages by adding a rule to decide if messages like this should be output.

Requesting ownership of this ticket, as the owner of this ticket is my old deleted Jira account.

Observed this behavior in 21w44a with a large block of tnt

These log items are sometimes supposed to be produced,as they are only presenting when failure in playing a sound the server intends to have it played takes place.However, outputting them is not a good choice, beacuse such a large amount of log printing is very expensive.
Some Solutions:
Remove the code of printing the log items driectly.
Batch the outputting,like printing the number of sound handles which is failed to be created per minute
Print the log only when the debugging mode is enabled

The log spamming caused by multiple sounds was tracked separately in MC-177664, which was already fixed in 1.18 Pre-release 5.

Code analysis
Based on 1.18.2 yarn mappings
I believe the issue is contained here and increasing streaming sources would help with the issue though I think 247 (in my case) is way too many.
SoundEngine#init
int i = this.getMonoSourceCount();
int j = MathHelper.clamp((int)MathHelper.sqrt((float)i), 2, 8);
int k = MathHelper.clamp(i - j, 8, 255);
this.streamingSources = new SoundEngine.SourceSetImpl(k);
this.staticSources = new SoundEngine.SourceSetImpl(j);
Taking a look at getMonoSourceCount()
// ...
IntBuffer intBuffer = memoryStack.mallocInt(i);
ALC10.alcGetIntegerv(this.devicePointer, ALC10.ALC_ALL_ATTRIBUTES, intBuffer);
int j = 0;
while(j < i) {
int k = intBuffer.get(j++);
if (k == 0) {
break;
}
int l = intBuffer.get(j++);
if (k == ALC11.ALC_MONO_SOURCES) {
return l;
}
}
// ...
return 30;
In my case, this method returns 255. Because OpenAL can have a maximum of 256 sounds. (255 for mono, 1 for stereo)
OpenAL Soft has a practical limit of 256 simultaneous sources (the same maximum that can be allocated). It's all done in software, so the OS doesn't affect it.
This means that you can either trade streaming sources (records etc) or be stuck with 255.
TLDR: Minecraft is already using all the sound streams available for the hardware. This should be closed.

It could still be improved by combining sounds together, bypassing OpenAL etc.. Or the most common sound could get less priority, that way the effects of this issue would be basically unnoticeable. So for example if you have 300 chickens around and mine a block, the block mining would get higher priority and 43 of the chickens would make no sound.

Can confirm this in the latest version, ticket owner here since I cannot currently get into my account and cannot update this issue.

Can confirm in 23w04a

Can confirm in 23w05a

Can confirm in 23w32a

Can confirm in 24w13a.

Can confirm in 1.20.5.