mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
fix: actors having stale musictrack reference after the audioengine reloading
This commit is contained in:
@@ -12,6 +12,7 @@ import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.audio.AudioMixer.Companion.DEFAULT_FADEOUT_LEN
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack
|
||||
import net.torvald.terrarum.audio.dsp.Convolv
|
||||
import net.torvald.terrarum.audio.dsp.LoFi
|
||||
import net.torvald.terrarum.audio.dsp.NullFilter
|
||||
@@ -90,7 +91,9 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
}
|
||||
|
||||
|
||||
// App.audioMixerRenewHooks[this] = { stopGracefully() }
|
||||
App.audioMixerReloadHooks[this] = {
|
||||
loadConvolver(musicTracks[musicNowPlaying])
|
||||
}
|
||||
}
|
||||
|
||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(0.0, 0.0, TILE_SIZED * 2, TILE_SIZED * 3), Cvec(0.44f, 0.41f, 0.40f, 0.2f)))
|
||||
@@ -141,13 +144,7 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
discCurrentlyPlaying = index
|
||||
|
||||
App.audioMixer.requestFadeOut(App.audioMixer.musicTrack, DEFAULT_FADEOUT_LEN / 2f) {
|
||||
startAudio(musicNowPlaying!!) {
|
||||
it.filters[filterIndex] = Phono(
|
||||
"basegame",
|
||||
"audio/convolution/Soundwoofer - large_speaker_Marshall JVM 205C SM57 A 0 0 1.bin",
|
||||
0f, 5f / 16f
|
||||
)
|
||||
}
|
||||
startAudio(musicNowPlaying!!) { loadConvolver(it) }
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +164,7 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
fun stopGracefully() {
|
||||
stopDiscPlayback()
|
||||
(INGAME.musicGovernor as TerrarumMusicGovernor).stopMusic(this, pauseLen = (INGAME.musicGovernor as TerrarumMusicGovernor).getRandomMusicInterval())
|
||||
|
||||
}
|
||||
|
||||
override fun drawBody(frameDelta: Float, batch: SpriteBatch) {
|
||||
@@ -214,6 +212,14 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
playMech.currentFrame = 0
|
||||
}
|
||||
|
||||
private fun loadConvolver(it: TerrarumAudioMixerTrack?) {
|
||||
it?.filters?.set(filterIndex, Phono(
|
||||
"basegame",
|
||||
"audio/convolution/Soundwoofer - large_speaker_Marshall JVM 205C SM57 A 0 0 1.bin",
|
||||
0f, 5f / 16f
|
||||
))
|
||||
}
|
||||
|
||||
private fun unloadConvolver(music: MusicContainer?) {
|
||||
if (music != null) {
|
||||
musicTracks[music]?.let {
|
||||
@@ -232,7 +238,7 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
// App.audioMixerRenewHooks.remove(this)
|
||||
App.audioMixerReloadHooks.remove(this)
|
||||
super.dispose()
|
||||
// testMusic.gdxMusic.dispose()
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.*
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
||||
import net.torvald.terrarum.audio.decibelsToFullscale
|
||||
import net.torvald.terrarum.audio.dsp.Lowpass
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
@@ -393,19 +395,29 @@ class UIInventoryFull(
|
||||
App.audioMixer.requestFadeOut(App.audioMixer.fadeBus, 0.25, decibelsToFullscale(-3.0))
|
||||
}
|
||||
|
||||
private var shouldIFadeIn: Boolean? = null
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
super.doClosing(delta)
|
||||
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
|
||||
INGAME.resume()
|
||||
INGAME.setTooltipMessage(null)
|
||||
|
||||
App.audioMixer.requestLowpassOut(0.25)
|
||||
App.audioMixer.requestFadeIn(App.audioMixer.fadeBus, 0.25, 1.0)
|
||||
if (shouldIFadeIn == null) {
|
||||
shouldIFadeIn = (App.audioMixer.fadeBus.getFilter<Lowpass>().cutoff < SAMPLING_RATE / 2)
|
||||
}
|
||||
|
||||
if (shouldIFadeIn == true) {
|
||||
App.audioMixer.requestLowpassOut(0.25)
|
||||
App.audioMixer.requestFadeIn(App.audioMixer.fadeBus, 0.25, 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
super.endOpening(delta)
|
||||
transitionPanel.uis.forEach { it.opacity = FastMath.pow(opacity, 0.5f) }
|
||||
|
||||
shouldIFadeIn = null
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
@@ -417,6 +429,8 @@ class UIInventoryFull(
|
||||
tooltipShowing.clear()
|
||||
|
||||
// printdbg(this, "Clearing out tooltipShowing")
|
||||
|
||||
shouldIFadeIn = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
||||
import net.torvald.terrarum.audio.dsp.Lowpass
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
@@ -53,10 +56,17 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
}
|
||||
|
||||
override fun renderUI(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
|
||||
// undo sound fadeout/muting when this panel is opened
|
||||
if (handler.openCloseCounter == 0f && App.audioMixer.fadeBus.getFilter<Lowpass>().cutoff < SAMPLING_RATE / 2) {
|
||||
App.audioMixer.requestLowpassOut(0.25)
|
||||
App.audioMixer.requestFadeIn(App.audioMixer.fadeBus, 0.25, 1.0)
|
||||
}
|
||||
|
||||
ControlPanelCommon.render("basegame.soundcontrolpanel", width, batch)
|
||||
uiItems.forEach { it.render(frameDelta, batch, camera) }
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user