Sound 配置(SoundConfig)

基本信息

属性 值
配置类 com.mitchej123.hodgepodge.config.SoundConfig
配置分类 sound(@Config(modid = "hodgepodge", category = "sound"),SoundConfig.java:8)
源文件 src/main/java/com/mitchej123/hodgepodge/config/SoundConfig.java(168 行)
字段总数 24(23 个 public static + 1 个容器内 public boolean enabled)
容器 public static OutputDeviceManagement outputDeviceManagement(SoundConfig.java:144,标注 @Config.RequiresMcRestart)
忽略字段 manageOutputDevicesAtStartup(SoundConfig.java:147,标注 @Config.Ignore,不出现在配置文件里)
配置文件 config/hodgepodge.cfg 的 S:sound 段
GUI 可见 是(列于 config/gui/HodgepodgeGuiConfig.java:29,排在最后)
挂载的 Mixin 数 1(SoundConfig 1 次)
额外写入 静态方法 apply()(SoundConfig.java:162-176)把 13 项写进 Paulscode SoundSystemConfig

功能

本配置是 Hodgepodge 里唯一有完整自研子系统支撑的配置类:所有 5 项音频增强(HRTF、输出限制器、环境混响、立体声下混、立体声空间化)都由 client/sound/ 下的自研类实现,配置项只是它们的开关。参见 音频管线 与 音效增强菜单。

apply() 在游戏启动时把 Paulscode 原生音量的 13 项参数(声道数、衰减模型、多普勒、缓冲大小、解码上限等)推给 SoundSystemConfig,日志输出 Sound Config Applied(SoundConfig.java:175)。

两级依赖分级

源码注释反复强调一条硬约束:Java 8 内置的 LWJGL2 打包版 OpenAL 不具备这些扩展,只有 lwjgl3ify(Java 17+)路线才有。

特性 所需扩展 lwjgl3ify 必需 生效时机
hrtf ALC_SOFT_HRTF 是 Reload Sounds / 重启
outputLimiter ALC_SOFT_output_limiter 是 Reload Sounds / 重启
spatializeStereoSounds AL_SOFT_source_spatialize(OpenAL Soft 1.19+,晚于 LWJGL2 打包版) 是 Reload Sounds / 重启
environmentalReverb ALC_EXT_EFX 否(两个层级都有) Reload Sounds / 重启
downmixStereoSounds 无,纯 Java 端下混 否 Reload Sounds / 重启
outputDeviceManagement / outputDevice ALC_SOFT_reopen_device 是 需重启

数值

枚举

枚举 取值 用途
SoundConfig.AttenuationType(:11-16) ATTENUATION_NONE / ATTENUATION_ROLLOFF / ATTENUATION_LINEAR 未指定时的默认衰减模型
SoundConfig.Tristate(:120-124) DEFAULT / ON / OFF hrtf / outputLimiter 的三态开关;DEFAULT 交由 OpenAL 设备配置决定

主要数值

配置项 默认值 含义
numberNormalChannels 64 普通(非流式)并发音效通道上限(OpenAL Soft 默认 256)
numberStreamingChannels 8 流式通道上限(音乐、黑胶唱片等)
defaultRolloffFactor 0.03f 默认衰减系数
dopplerFactor 0.0f 多普勒因子
dopplerVelocity 1.0f 多普勒速度
defaultFadeDistance 1000.0f 默认淡出距离
streamingBufferSize 131072 流式解码单次读取字节数(128 KiB)
numberStreamingBuffers 3 每个流式源的缓冲数,慢解码器需 >2
maxFileSize 268435456 非流式音效解码后大小上限(256 MiB),OGG 在完整 PCM 帧处停止
fileChunkSize 1048576 非流式解码器分块大小(1 MiB)
reverbStrength 0.3f 全封闭空间中的混响湿度,范围 @Config.RangeFloat(0.0f, 1.0f)

明细

字段名、类型、默认值与说明直接取自 SoundConfig.java:18-161。

配置项 类型 默认值 说明
numberNormalChannels int 64 hodgepodge sound Maximum number of normal (non-streaming) channels available for simultaneous sound effects. OpenAL Soft defaults to 256 sources unless overridden. If fewer are available, Paulscode creates as many channels as it can. Takes effect after ‘Reload Sounds’ in the sound options, or a restart.
numberStreamingChannels int 8 Maximum number of streaming channels: music, records, and other streamed audio playing at once. Takes effect after ‘Reload Sounds’ in the sound options, or a restart.
defaultAttenuationModel AttenuationType “ATTENUATION_ROLLOFF” Attenuation model to use if not specified. Attenuation is how a source’s volume fades with distance. ATTENUATION_NONE: Global identifier for no attenuation. Attenuation is how a source’s volume fades with distance. When there is no attenuation, a source’s volume remains constant regardless of distance. ATTENUATION_ROLLOFF: Global identifier for rolloff attenuation. Rolloff attenuation is a realistic attenuation model, which uses a rolloff factor to determine how quickly a source fades with distance. A smaller rolloff factor will fade at a further distance, and a rolloff factor of 0 will never fade. NOTE: In OpenAL, rolloff attenuation only works for monotone sounds. ATTENUATION_LINEAR: Global identifier for linear attenuation. Linear attenuation is less realistic than rolloff attenuation, but it allows the user to specify a maximum “fade distance” where a source’s volume becomes zero. ATTENUATION_ROLLOFF
defaultRolloffFactor float 0.03f Default value to use for the rolloff factor if not specified.
dopplerFactor float 0.0f Value to use for the Doppler factor, for determining Doppler scale.
dopplerVelocity float 1.0f Value to use for the Doppler velocity.
defaultFadeDistance float 1000.0f Default value to use for fade distance if not specified.
streamingBufferSize int 131072 Number of bytes to load at a time when streaming.
numberStreamingBuffers int 3 Number of buffers used for each streaming source. Slow codecs may require this number to be greater than 2 to prevent audio skipping during playback.
streamQueueFormatsMatch boolean false Enables a transition-speed optimization by assuming all sounds in each streaming source’s queue will have exactly the same format once decoded (including channels, sample rate, and sample size). This is an advanced setting which should only be changed by experienced developers. NOTE: I have not checked if this is even true for vanilla. Changing this setting will most likely break things.
maxFileSize int 268435456 Maximum decoded size of a non-streaming sound. OGG decoding stops at this limit on a complete PCM frame. Streamed sounds are unaffected.
fileChunkSize int 1048576 Size of each chunk used by non-streaming codecs that honor it. OGG uses streamingBufferSize to keep decode copying bounded.
overrideMIDISynthesizer String “” MIDI device to try using as the Synthesizer. May be the full name or part of the name. If this String is empty, the default Synthesizer will be used, or one of the common alternate synthesizers if the default Synthesizer is unavailable.
downmixStereoSounds boolean true Downmix non-streaming stereo OGG sounds to mono, halving their decoded PCM size and allowing positional audio. Non-streaming is used as a proxy for positional, so rare non-positional effects may also be downmixed. Streaming sounds, normally music and records, are unaffected. Ignored for sounds handled by spatializeStereoSounds. Takes full effect after ‘Reload Sounds’ or a restart.
spatializeStereoSounds boolean true Let OpenAL position stereo sounds that use distance attenuation without converting them to mono. This preserves the stereo PCM but uses roughly twice the buffer memory of mono. Requires lwjgl3ify and AL_SOFT_source_spatialize; otherwise downmixStereoSounds can provide the fallback. Takes full effect after ‘Reload Sounds’ or a restart.
downmixExclusions String[] { “button”, “click”, “/gui”, “menu”, “typing”, “page” } Sounds whose path contains any of these are never downmixed, so interface sounds keep their stereo. Matched case-insensitively against ‘domain:path’, e.g. ‘gregtech:sounds/buttonup.ogg’. Only used by downmixStereoSounds. spatializeStereoSounds needs no list because it decides per playback from the attenuation model. Broad patterns can also match world sounds; those stay stereo and cannot be positioned by the downmix fallback. button click /gui menu typing page
releaseDecodedSoundData boolean true Discard the Java-heap PCM copy after a non-streaming sound is uploaded to OpenAL, removing one of the two cached decoded copies. Turn off only if you suspect it of causing missing or corrupted sounds. Takes full effect after ‘Reload Sounds’ or a restart.
environmentalReverb boolean false Add environmental reverb to positional sounds based on how enclosed the listener is. Requires OpenAL EFX, available in the bundled Java 8 and lwjgl3ify backends. Surroundings are estimated by sampling 12 directions up to 20 blocks four times per second. Takes full effect after ‘Reload Sounds’ or a restart.
reverbStrength float 0.3f How wet the reverb gets in a fully enclosed space. Lower is subtler. Only used when environmentalReverb is on.
hrtf Tristate “DEFAULT” Binaural 3D audio for headphones (HRTF): lets you hear whether a sound is above, below, in front or behind you, instead of just left/right. Designed for headphones; speakers may sound hollow or coloured. DEFAULT leaves it to OpenAL’s device configuration, ON forces it, OFF forces it off. Requires lwjgl3ify; ignored on Java 8. DEFAULT
outputLimiter Tristate “DEFAULT” Protects the final output mix from clipping by reducing gain when its combined level exceeds the device range. It reacts to signal level, not the number of playing sounds, and does not limit sound or channel count. DEFAULT leaves it to OpenAL, ON forces it, OFF disables it. Requires lwjgl3ify; ignored on Java 8. DEFAULT
manageOutputDevicesAtStartup boolean — Let Hodgepodge manage the OpenAL output device, including following system-default changes and recovering from disconnects. Requires lwjgl3ify and ALC_SOFT_reopen_device; otherwise this is ignored. Restart after changing this option.
enabled boolean true Enables output device selection and recovery.
outputDevice String “” OpenAL output device name. Empty follows the system default and switches when the default changes. Use the in-game Sound Enhancements menu instead of editing this value by hand.