adjustable audio buffer size via config

This commit is contained in:
minjaesong
2023-11-26 22:53:36 +09:00
parent 21e0f984be
commit bf64c26e29
6 changed files with 27 additions and 12 deletions

View File

@@ -13,11 +13,14 @@
"MENU_IO_CLEAR": "Clear", "MENU_IO_CLEAR": "Clear",
"MENU_IO_IMPORT": "Import", "MENU_IO_IMPORT": "Import",
"MENU_IO_MANUAL_SAVE": "Manual Save", "MENU_IO_MANUAL_SAVE": "Manual Save",
"MENU_LABEL_AMBIENT_SOUNDS": "Ambient Sounds",
"MENU_LABEL_COPYRIGHT": "Copyright", "MENU_LABEL_COPYRIGHT": "Copyright",
"MENU_LABEL_DELETE": "Delete", "MENU_LABEL_DELETE": "Delete",
"MENU_LABEL_EXTRA_JVM_ARGUMENTS": "Extra Arguments", "MENU_LABEL_EXTRA_JVM_ARGUMENTS": "Extra Arguments",
"MENU_LABEL_HARDWARE": "Hardware",
"MENU_LABEL_IME": "IME", "MENU_LABEL_IME": "IME",
"MENU_LABEL_IME_TOGGLE": "Toggle IME", "MENU_LABEL_IME_TOGGLE": "Toggle IME",
"MENU_LABEL_INTERFACE": "Interface",
"MENU_LABEL_KEYBOARD_LAYOUT": "Keyboard Layout", "MENU_LABEL_KEYBOARD_LAYOUT": "Keyboard Layout",
"MENU_LABEL_PASTE": "Paste", "MENU_LABEL_PASTE": "Paste",
"MENU_LABEL_PASTE_FROM_CLIPBOARD": "Paste from Clipboard", "MENU_LABEL_PASTE_FROM_CLIPBOARD": "Paste from Clipboard",
@@ -28,6 +31,7 @@
"MENU_LABEL_SYSTEM_INFO": "System Info", "MENU_LABEL_SYSTEM_INFO": "System Info",
"MENU_MODULES" : "Modules", "MENU_MODULES" : "Modules",
"MENU_OPTIONS_ATLAS_TEXTURE_SIZE": "Atlas Texture Size", "MENU_OPTIONS_ATLAS_TEXTURE_SIZE": "Atlas Texture Size",
"MENU_OPTIONS_AUDIO_BUFFER_SIZE": "Audio Buffer Size",
"MENU_OPTIONS_AUTOSAVE": "Autosave", "MENU_OPTIONS_AUTOSAVE": "Autosave",
"MENU_OPTIONS_BLUR": "Blur", "MENU_OPTIONS_BLUR": "Blur",
"MENU_OPTIONS_DEBUG_CONSOLE": "Debug Console", "MENU_OPTIONS_DEBUG_CONSOLE": "Debug Console",
@@ -35,6 +39,7 @@
"MENU_OPTIONS_ENABLE_SCRIPT_MODS": "Enable Script Mods", "MENU_OPTIONS_ENABLE_SCRIPT_MODS": "Enable Script Mods",
"MENU_OPTIONS_JVM_HEAP_MAX": "Max Heap Memory", "MENU_OPTIONS_JVM_HEAP_MAX": "Max Heap Memory",
"MENU_OPTIONS_LIGHT_UPDATE_PASSES": "Light Calculation Depth", "MENU_OPTIONS_LIGHT_UPDATE_PASSES": "Light Calculation Depth",
"MENU_OPTIONS_MASTER_VOLUME": "Master Volume",
"MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "Show notification for", "MENU_OPTIONS_NOTIFICATION_DISPLAY_DURATION": "Show notification for",
"MENU_OPTIONS_PARTICLES": "Particles", "MENU_OPTIONS_PARTICLES": "Particles",
"MENU_OPTIONS_PERFORMANCE": "Performance", "MENU_OPTIONS_PERFORMANCE": "Performance",

View File

@@ -21,6 +21,7 @@ object DefaultConfig {
"screenheight" to TerrarumScreenSize.defaultH, "screenheight" to TerrarumScreenSize.defaultH,
"fullscreen" to false, "fullscreen" to false,
"atlastexsize" to 2048, "atlastexsize" to 2048,
"audiobuffersize" to 512,
"language" to App.getSysLang(), "language" to App.getSysLang(),
"notificationshowuptime" to 4000, // 4s "notificationshowuptime" to 4000, // 4s

View File

@@ -117,6 +117,7 @@ object AudioMixer: Disposable {
val callables = tracks.map { Callable { val callables = tracks.map { Callable {
if (!it.processor.paused) { if (!it.processor.paused) {
try { it.processor.run() } try { it.processor.run() }
catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() } catch (e: Throwable) { e.printStackTrace() }
} }
} } } }
@@ -126,7 +127,8 @@ object AudioMixer: Disposable {
processingExecutor.submitAll(callables) processingExecutor.submitAll(callables)
processingExecutor.join() processingExecutor.join()
} }
catch (_: Throwable) {} catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() }
/*processingSubthreads = tracks.map { Thread { /*processingSubthreads = tracks.map { Thread {

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.backends.lwjgl3.audio.OpenALLwjgl3Audio
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import com.badlogic.gdx.utils.Queue import com.badlogic.gdx.utils.Queue
import net.torvald.reflection.forceInvoke import net.torvald.reflection.forceInvoke
import net.torvald.terrarum.App
import net.torvald.terrarum.getHashStr import net.torvald.terrarum.getHashStr
import net.torvald.terrarum.hashStrMap import net.torvald.terrarum.hashStrMap
import net.torvald.terrarum.modulebasegame.MusicContainer import net.torvald.terrarum.modulebasegame.MusicContainer
@@ -20,7 +21,7 @@ class TerrarumAudioMixerTrack(val name: String, val isMaster: Boolean = false, v
const val SAMPLING_RATE = 48000 const val SAMPLING_RATE = 48000
const val SAMPLING_RATEF = 48000f const val SAMPLING_RATEF = 48000f
const val SAMPLING_RATED = 48000.0 const val SAMPLING_RATED = 48000.0
const val BUFFER_SIZE = 256*4 // n ms -> 384 * n val BUFFER_SIZE = 4 * App.getConfigInt("audiobuffersize") // n ms -> 384 * n
} }
val hash = getHashStr() val hash = getHashStr()

View File

@@ -36,7 +36,7 @@ object ControlPanelCommon {
val optionName = optionNames.first() val optionName = optionNames.first()
val arg = args.split(',') val arg = args.split(',')
return if (args == "h1" || args == "p" || args == "emph") { return if (args == "h1" || args == "p" || args == "emph" || args == "pp") {
(object : UIItem(parent, x, y) { (object : UIItem(parent, x, y) {
override val width = 1 override val width = 1
override val height = 1 override val height = 1
@@ -232,6 +232,7 @@ object ControlPanelCommon {
akku += when (option) { akku += when (option) {
"h1" -> realRowHeight + linegap + h1MarginBottom "h1" -> realRowHeight + linegap + h1MarginBottom
"pp" -> realRowHeight - 7
else -> realRowHeight + linegap else -> realRowHeight + linegap
} }
} }

View File

@@ -17,15 +17,20 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
handler.allowESCtoClose = false handler.allowESCtoClose = false
ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf( ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf(
arrayOf("mastervolume", { Lang["MENU_OPTIONS_MASTER_VOLUME"] }, "sliderd,0,1"), arrayOf("", { Lang["MENU_OPTIONS_SOUND_VOLUME"] }, "h1"),
arrayOf("", { "" }, "p"), arrayOf("mastervolume", { Lang["MENU_OPTIONS_MASTER_VOLUME"] }, "sliderd,0,1"),
arrayOf("bgmvolume", { Lang["MENU_LABEL_MUSIC"] }, "sliderd,0,1"), arrayOf("", { "" }, "pp"),
arrayOf("", { "" }, "p"), arrayOf("bgmvolume", { Lang["MENU_LABEL_MUSIC"] }, "sliderd,0,1"),
arrayOf("ambientvolume", { Lang["MENU_LABEL_AMBIENT_SOUND"] }, "sliderd,0,1"), arrayOf("", { "" }, "pp"),
arrayOf("", { "" }, "p"), arrayOf("ambientvolume", { Lang["MENU_LABEL_AMBIENT_SOUNDS"] }, "sliderd,0,1"),
arrayOf("sfxvolume", { Lang["CREDITS_SFX"] }, "sliderd,0,1"), arrayOf("", { "" }, "pp"),
arrayOf("", { "" }, "p"), arrayOf("sfxvolume", { Lang["CREDITS_SFX"] }, "sliderd,0,1"),
arrayOf("guivolume", { Lang["MENU_LABEL_INTERFACE"] }, "sliderd,0,1"), arrayOf("", { "" }, "pp"),
arrayOf("guivolume", { Lang["MENU_LABEL_INTERFACE"] }, "sliderd,0,1"),
arrayOf("", { Lang["MENU_LABEL_HARDWARE"] }, "h1"),
arrayOf("audiobuffersize", { Lang["MENU_OPTIONS_AUDIO_BUFFER_SIZE"] }, "spinnersel,128,256,512,1024,2048"),
arrayOf("", { "(${Lang["MENU_LABEL_RESTART_REQUIRED"]})" }, "p"),
)) ))
} }