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

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

View File

@@ -117,6 +117,7 @@ object AudioMixer: Disposable {
val callables = tracks.map { Callable {
if (!it.processor.paused) {
try { it.processor.run() }
catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() }
}
} }
@@ -126,7 +127,8 @@ object AudioMixer: Disposable {
processingExecutor.submitAll(callables)
processingExecutor.join()
}
catch (_: Throwable) {}
catch (_: InterruptedException) {}
catch (e: Throwable) { e.printStackTrace() }
/*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.Queue
import net.torvald.reflection.forceInvoke
import net.torvald.terrarum.App
import net.torvald.terrarum.getHashStr
import net.torvald.terrarum.hashStrMap
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_RATEF = 48000f
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()

View File

@@ -36,7 +36,7 @@ object ControlPanelCommon {
val optionName = optionNames.first()
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) {
override val width = 1
override val height = 1
@@ -232,6 +232,7 @@ object ControlPanelCommon {
akku += when (option) {
"h1" -> realRowHeight + linegap + h1MarginBottom
"pp" -> realRowHeight - 7
else -> realRowHeight + linegap
}
}

View File

@@ -17,15 +17,20 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
handler.allowESCtoClose = false
ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf(
arrayOf("mastervolume", { Lang["MENU_OPTIONS_MASTER_VOLUME"] }, "sliderd,0,1"),
arrayOf("", { "" }, "p"),
arrayOf("bgmvolume", { Lang["MENU_LABEL_MUSIC"] }, "sliderd,0,1"),
arrayOf("", { "" }, "p"),
arrayOf("ambientvolume", { Lang["MENU_LABEL_AMBIENT_SOUND"] }, "sliderd,0,1"),
arrayOf("", { "" }, "p"),
arrayOf("sfxvolume", { Lang["CREDITS_SFX"] }, "sliderd,0,1"),
arrayOf("", { "" }, "p"),
arrayOf("guivolume", { Lang["MENU_LABEL_INTERFACE"] }, "sliderd,0,1"),
arrayOf("", { Lang["MENU_OPTIONS_SOUND_VOLUME"] }, "h1"),
arrayOf("mastervolume", { Lang["MENU_OPTIONS_MASTER_VOLUME"] }, "sliderd,0,1"),
arrayOf("", { "" }, "pp"),
arrayOf("bgmvolume", { Lang["MENU_LABEL_MUSIC"] }, "sliderd,0,1"),
arrayOf("", { "" }, "pp"),
arrayOf("ambientvolume", { Lang["MENU_LABEL_AMBIENT_SOUNDS"] }, "sliderd,0,1"),
arrayOf("", { "" }, "pp"),
arrayOf("sfxvolume", { Lang["CREDITS_SFX"] }, "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"),
))
}