@SubscribeEvent public void onSoundLoad(SoundSetupEvent event) { try { SoundSystemConfig.setCodec("wav", CodecWav.class); SoundSystemConfig.setCodec("mp3", CodecJLayerMP3.class); } catch (SoundSystemException e) { e.printStackTrace(); } }
@SubscribeEvent(priority = EventPriority.LOWEST) public static void configureSound(@Nonnull final SoundSetupEvent event) { int totalChannels = -1; try { final boolean create = !AL.isCreated(); if (create) { AL.create(); alErrorCheck(); } final IntBuffer ib = BufferUtils.createIntBuffer(1); ALC10.alcGetInteger(AL.getDevice(), ALC11.ALC_MONO_SOURCES, ib); alErrorCheck(); totalChannels = ib.get(0); if (create) AL.destroy(); } catch (final Throwable e) { e.printStackTrace(); } int normalChannelCount = ModOptions.normalSoundChannelCount; int streamChannelCount = ModOptions.streamingSoundChannelCount; if (ModOptions.autoConfigureChannels && totalChannels > 64) { totalChannels = ((totalChannels + 1) * 3) / 4; streamChannelCount = Math.min(totalChannels / 5, MAX_STREAM_CHANNELS); normalChannelCount = totalChannels - streamChannelCount; } DSurround.log().info("Sound channels: %d normal, %d streaming (total avail: %s)", normalChannelCount, streamChannelCount, totalChannels == -1 ? "UNKNOWN" : Integer.toString(totalChannels)); SoundSystemConfig.setNumberNormalChannels(normalChannelCount); SoundSystemConfig.setNumberStreamingChannels(streamChannelCount); // Setup sound buffering if (ModOptions.streamBufferCount != 0) SoundSystemConfig.setNumberStreamingBuffers(ModOptions.streamBufferCount); if (ModOptions.streamBufferSize != 0) SoundSystemConfig.setStreamingBufferSize(ModOptions.streamBufferSize * 1024); DSurround.log().info("Stream buffers: %d x %d", SoundSystemConfig.getNumberStreamingBuffers(), SoundSystemConfig.getStreamingBufferSize()); }