audiomanager: will gracefully not play if there is nothing to play

This commit is contained in:
minjaesong
2023-11-21 00:21:19 +09:00
parent 4b17957b65
commit 6229b0f60b
3 changed files with 8 additions and 13 deletions

View File

@@ -97,7 +97,7 @@ object AudioMixer: Disposable {
init {
masterTrack.filters[0] = SoftLim
masterTrack.filters[1] = Buffer
masterTrack.filters[2] = Scope
masterTrack.filters[2] = Scope()
fadeBus.addSidechainInput(musicTrack, 1.0)
fadeBus.addSidechainInput(ambientTrack, 1.0)

View File

@@ -38,7 +38,7 @@ object SoftLim : TerrarumAudioFilter() {
}
}
object Scope : TerrarumAudioFilter() {
class Scope : TerrarumAudioFilter() {
val backbufL = Array(BUFFER_SIZE / 16) { FloatArray(BUFFER_SIZE / 4) }
val backbufR = Array(BUFFER_SIZE / 16) { FloatArray(BUFFER_SIZE / 4) }

View File

@@ -66,6 +66,9 @@ class TerrarumMusicGovernor : MusicGovernor() {
songs.forEach {
App.disposables.add(it.gdxMusic)
}
ambients.forEach {
App.disposables.add(it.gdxMusic)
}
}
@@ -113,17 +116,9 @@ class TerrarumMusicGovernor : MusicGovernor() {
override fun update(ingame: IngameInstance, delta: Float) {
if (songs.isEmpty()) {
if (!warningPrinted) {
warningPrinted = true
printdbg(this, "Warning: songs list is empty")
}
return
}
// val ingame = ingame as TerrarumIngame
if (musicState == 0) musicState = STATE_INTERMISSION
if (ambState == 0) ambState = STATE_INTERMISSION
// start the song queueing if there is one to play
if (songs.isNotEmpty() && musicState == 0) musicState = STATE_INTERMISSION
if (ambients.isNotEmpty() && ambState == 0) ambState = STATE_INTERMISSION
when (musicState) {