Speaker limit to 8
BuildmasterW opened this issue ยท 5 comments
Minecraft Version
1.18.x
Version
cc-tweaked-1.18.2-1.100.8
Details
There appears to be a limit of 8 speakers playing at one time. I tried to connect a bunch of speakers to one network cable and used the following API https://github.com/MCJack123/AUKit After attempting to play the song "Unforgettable" in a dfpwm file, only 8 speakers played the sound, in order from which was placed first (The first 8 that were placed played the song).
@SquidDev Where is the limitation on Minecraft? Is it client or server sided? Also, do you know if there is any way around it (EG: Mod or changes in a config file)
Thanks!
It's a client side limitation in the underlying sound library. See com.mojang.blaze3d.audio.Library
, where it creates the pools of sound channels:
int channels = this.getChannelCount();
int streamingLimit = Mth.clamp((int)Mth.sqrt((float)channels), 2, 8);
int staticLimit = Mth.clamp(channels - streamingLimit, 8, 255);
this.staticChannels = new Library.CountingChannelPool(staticLimit);
this.streamingChannels = new Library.CountingChannelPool(streamingLimit);
The limit of 8 is hard coded, so can't be changed via a config file. I'm not aware of any mod which increases it.
This is a limitation of Minecraft itself - it only allows 8 streaming sounds to be played at once. You can see this with Jukeboxes as well, if you try to play 9 records at the same time.
Unfortunately I don't think there's anything I can really do to fix this short of bypassing Minecraft's sound system (which I really don't want to do). I'll leave this open in case people have ideas, but I fear this will remain unfixable.
I have some mod source code that changes it!
package com.example.examplemod;
import com.mojang.logging.LogUtils;
import com.mojang.blaze3d.audio.Library;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.event.server.ServerStartingEvent;
import org.slf4j.Logger;
// The value here should match an entry in the META-INF/mods.toml file
@Mod("examplemod")
public class ExampleMod
{
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();
private boolean didrun = false;
public ExampleMod() {
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event)
{
// Do something when the server starts
LOGGER.info("HELLO from server starting");
if (!didrun) Minecraft.getInstance().getSoundManager().soundEngine.library.streamingChannels = new Library.CountingChannelPool(16);
didrun = true;
}
}
# accesstransformer.cfg
public com.mojang.blaze3d.audio.Library f_83690_ # streamingChannels
public com.mojang.blaze3d.audio.Library$CountingChannelPool
public net.minecraft.client.sounds.SoundEngine f_120220_ # library
public net.minecraft.client.sounds.SoundManager f_120349_ # soundEngine
This was written for 1.18.2, so it may will need porting for other versions (mainly the obfuscated named in the access transformer).