mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
ambient mixer
This commit is contained in:
BIN
assets/mods/basegame/audio/ambient/season/matutinal.1.ogg
LFS
Normal file
BIN
assets/mods/basegame/audio/ambient/season/matutinal.1.ogg
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/audio/ambient/season/matutinal.2.ogg
LFS
Normal file
BIN
assets/mods/basegame/audio/ambient/season/matutinal.2.ogg
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -273,14 +273,15 @@ limitations under the License.
|
||||
|
||||
$BULLET Foleys:
|
||||
|
||||
- ambient/season/crepuscular_summer.*.ogg
|
||||
- ambient/season/crepuscular.*.ogg
|
||||
- ambient/season/diurnal_autumn.*.ogg
|
||||
- ambient/season/diurnal_spring.*.ogg
|
||||
- ambient/season/diurnal_summer.*.ogg
|
||||
- ambient/season/diurnal_winter.*.ogg
|
||||
- ambient/season/matutinal.*.ogg
|
||||
- ambient/season/nocturnal_summer.*.ogg
|
||||
|
||||
Copyright (C) 2013, 2015, 2020, 2021 Klankbeeld
|
||||
Copyright (C) 2011, 2013, 2015, 2020, 2021 Klankbeeld
|
||||
Sound from <https://www.freesound.org/people/klankbeeld>
|
||||
|
||||
- effects/steps/GRSS.*.ogg
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.badlogic.gdx.utils.Disposable
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.spriteanimation.AssembledSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATED
|
||||
import net.torvald.terrarum.audio.dsp.*
|
||||
@@ -56,18 +55,20 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
val dynamicSourceCount: Int
|
||||
get() = App.getConfigInt("audio_dynamic_source_max")
|
||||
|
||||
val tracks = Array(10) { TerrarumAudioMixerTrack(
|
||||
val tracks = Array(12) { TerrarumAudioMixerTrack(
|
||||
if (it == 0) "Music"
|
||||
else if (it == 1) "Amb1"
|
||||
else if (it == 2) "Amb2"
|
||||
else if (it == 3) "GUI"
|
||||
else if (it == 4) "\u00E4AMB"
|
||||
else if (it == 5) "\u00E4SFX"
|
||||
else if (it == 6) "\u00F0 \u00E4 \u00F0" // summation
|
||||
else if (it == 7) "\u00D9Open\u00D9" // convolution1
|
||||
else if (it == 8) "\u00D9Cave\u00D9" // convolution2
|
||||
else if (it == 9) "\u00F0 \u00DA \u00F0" // fade
|
||||
else "Trk${it+1}", trackType = if (it >= 3) TrackType.BUS else TrackType.STATIC_SOURCE, maxVolumeFun = {
|
||||
else if (it == 3) "AMB1+2"
|
||||
else if (it == 4) "Amb3"
|
||||
else if (it == 5) "Amb4"
|
||||
else if (it == 6) "GUI"
|
||||
else if (it == 7) "\u00E4SFX"
|
||||
else if (it == 8) "\u00F0 \u00E4 \u00F0" // summation
|
||||
else if (it == 9) "\u00D9Open\u00D9" // convolution1
|
||||
else if (it == 10) "\u00D9Cave\u00D9" // convolution2
|
||||
else if (it == 11) "\u00F0 \u00DA \u00F0" // fade
|
||||
else "Trk${it+1}", trackType = if (it >= 7 || it == 3) TrackType.BUS else TrackType.STATIC_SOURCE, maxVolumeFun = {
|
||||
when (it) {
|
||||
0 -> { musicVolume }
|
||||
4 -> { ambientVolume }
|
||||
@@ -91,21 +92,30 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
get() = tracks[1]
|
||||
val ambientTrack2: TerrarumAudioMixerTrack
|
||||
get() = tracks[2]
|
||||
val guiTrack: TerrarumAudioMixerTrack
|
||||
val amb1plus2: TerrarumAudioMixerTrack
|
||||
get() = tracks[3]
|
||||
|
||||
val ambSumBus: TerrarumAudioMixerTrack
|
||||
val ambientTrack3: TerrarumAudioMixerTrack
|
||||
get() = tracks[4]
|
||||
val sfxSumBus: TerrarumAudioMixerTrack
|
||||
val ambientTrack4: TerrarumAudioMixerTrack
|
||||
get() = tracks[5]
|
||||
val sumBus: TerrarumAudioMixerTrack
|
||||
|
||||
val guiTrack: TerrarumAudioMixerTrack
|
||||
get() = tracks[6]
|
||||
val convolveBusOpen: TerrarumAudioMixerTrack
|
||||
|
||||
val sfxSumBus: TerrarumAudioMixerTrack
|
||||
get() = tracks[7]
|
||||
val convolveBusCave: TerrarumAudioMixerTrack
|
||||
val sumBus: TerrarumAudioMixerTrack
|
||||
get() = tracks[8]
|
||||
val fadeBus: TerrarumAudioMixerTrack
|
||||
val convolveBusOpen: TerrarumAudioMixerTrack
|
||||
get() = tracks[9]
|
||||
val convolveBusCave: TerrarumAudioMixerTrack
|
||||
get() = tracks[10]
|
||||
val fadeBus: TerrarumAudioMixerTrack
|
||||
get() = tracks[11]
|
||||
|
||||
val ambientTracks = arrayOf(
|
||||
ambientTrack1, ambientTrack2
|
||||
)
|
||||
|
||||
var processing = false
|
||||
|
||||
@@ -215,20 +225,19 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
|
||||
musicTrack.filters[1] = Vecto()
|
||||
musicTrack.filters[2] = Spectro()
|
||||
ambientTrack1.filters[1] = Vecto(decibelsToFullscale(24.0).toFloat())
|
||||
ambientTrack1.filters[2] = Spectro()
|
||||
ambientTrack2.filters[1] = Vecto(decibelsToFullscale(24.0).toFloat())
|
||||
ambientTrack2.filters[2] = Spectro()
|
||||
ambientTracks.forEach {
|
||||
it.filters[1] = Vecto(decibelsToFullscale(24.0).toFloat())
|
||||
it.filters[2] = Spectro()
|
||||
amb1plus2.addSidechainInput(it, 1.0)
|
||||
}
|
||||
sfxSumBus.filters[1] = Vecto(0.7071f)
|
||||
sfxSumBus.filters[2] = Spectro()
|
||||
|
||||
ambSumBus.addSidechainInput(ambientTrack1, 1.0)
|
||||
ambSumBus.addSidechainInput(ambientTrack2, 1.0)
|
||||
ambSumBus.filters[1] = Gain(1f) // controlled by the "openness" controller
|
||||
|
||||
listOf(sumBus, convolveBusOpen, convolveBusCave).forEach {
|
||||
it.addSidechainInput(musicTrack, 1.0)
|
||||
it.addSidechainInput(ambSumBus, 1.0)
|
||||
it.addSidechainInput(amb1plus2, 1.0)
|
||||
it.addSidechainInput(ambientTrack3, 1.0)
|
||||
it.addSidechainInput(ambientTrack4, 1.0)
|
||||
it.addSidechainInput(sfxSumBus, 1.0)
|
||||
}
|
||||
|
||||
@@ -282,7 +291,7 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
)
|
||||
|
||||
private val fadeReqs = HashMap<TerrarumAudioMixerTrack, FadeRequest>().also { map ->
|
||||
listOf(musicTrack, ambientTrack1, ambientTrack2, guiTrack, ambSumBus, fadeBus).forEach {
|
||||
listOf(musicTrack, ambientTrack1, ambientTrack2, guiTrack, amb1plus2, fadeBus).forEach {
|
||||
map[it] = FadeRequest()
|
||||
}
|
||||
}
|
||||
@@ -349,8 +358,9 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
(Gdx.audio as? Lwjgl3Audio)?.update()
|
||||
masterTrack.volume = masterVolume
|
||||
musicTrack.getFilter<Gain>().gain = musicVolume.toFloat() * 0.5f
|
||||
ambientTrack1.getFilter<Gain>().gain = ambientVolume.toFloat() * 2
|
||||
ambientTrack2.getFilter<Gain>().gain = ambientVolume.toFloat() * 2
|
||||
ambientTracks.forEach {
|
||||
it.getFilter<Gain>().gain = ambientVolume.toFloat()
|
||||
}
|
||||
sfxSumBus.volume = sfxVolume
|
||||
guiTrack.volume = guiVolume
|
||||
|
||||
@@ -371,15 +381,12 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
musicTrack.stop()
|
||||
musicTrack.currentTrack = null
|
||||
}
|
||||
if (req.fadeTarget == 0.0 && (track == ambientTrack1 || track == fadeBus)) {
|
||||
ambientTrack1.stop()
|
||||
ambientTrack1.currentTrack = null
|
||||
}
|
||||
if (req.fadeTarget == 0.0 && (track == ambientTrack2 || track == fadeBus)) {
|
||||
ambientTrack2.stop()
|
||||
ambientTrack2.currentTrack = null
|
||||
}
|
||||
|
||||
/*ambientTracks.forEach {
|
||||
if (req.fadeTarget == 0.0 && (track == it || track == fadeBus)) {
|
||||
it.stop()
|
||||
it.currentTrack = null
|
||||
}
|
||||
}*/
|
||||
req.callback()
|
||||
}
|
||||
}
|
||||
@@ -427,14 +434,15 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
musicTrack.play()
|
||||
}
|
||||
|
||||
if (!ambientTrack1.isPlaying && ambientTrack1.nextTrack != null) {
|
||||
ambientTrack1.queueNext(null)
|
||||
if (ambientStopped) {
|
||||
requestFadeIn(ambientTrack1, DEFAULT_FADEOUT_LEN * 4, 1.0, 0.00001)
|
||||
ambientTracks.forEach {
|
||||
if (!it.isPlaying && it.nextTrack != null) {
|
||||
it.queueNext(null)
|
||||
if (ambientStopped) {
|
||||
requestFadeIn(it, DEFAULT_FADEOUT_LEN * 4, 1.0, 0.00001)
|
||||
}
|
||||
it.play()
|
||||
ambientStopped = false
|
||||
}
|
||||
ambientTrack1.volume = 1.0
|
||||
ambientTrack1.play()
|
||||
ambientStopped = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +476,22 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
// fade will be processed by the update()
|
||||
}
|
||||
|
||||
fun startAmb1(song: MusicContainer) {
|
||||
if (ambientTrack1.isPlaying == true) {
|
||||
requestFadeOut(musicTrack, DEFAULT_FADEOUT_LEN)
|
||||
}
|
||||
ambientTrack1.nextTrack = song
|
||||
// fade will be processed by the update()
|
||||
}
|
||||
|
||||
fun startAmb2(song: MusicContainer) {
|
||||
if (ambientTrack2.isPlaying == true) {
|
||||
requestFadeOut(musicTrack, DEFAULT_FADEOUT_LEN)
|
||||
}
|
||||
ambientTrack2.nextTrack = song
|
||||
// fade will be processed by the update()
|
||||
}
|
||||
|
||||
fun requestFadeOut(track: TerrarumAudioMixerTrack, length: Double = DEFAULT_FADEOUT_LEN, target: Double = 0.0, source: Double? = null, jobAfterFadeout: () -> Unit = {}) {
|
||||
val req = fadeReqs[track]!!
|
||||
if (!req.fadeoutFired) {
|
||||
@@ -481,8 +505,8 @@ class AudioMixer(val bufferSize: Int): Disposable {
|
||||
}
|
||||
|
||||
fun requestFadeIn(track: TerrarumAudioMixerTrack, length: Double, target: Double = 1.0, source: Double? = null, jobAfterFadeout: () -> Unit = {}) {
|
||||
printdbg(this, "fadein called by")
|
||||
printStackTrace(this)
|
||||
// printdbg(this, "fadein called by")
|
||||
// printStackTrace(this)
|
||||
|
||||
val req = fadeReqs[track]!!
|
||||
if (!req.fadeinFired) {
|
||||
|
||||
@@ -74,19 +74,29 @@ class MixerTrackProcessor(bufferSize: Int, val rate: Int, val track: TerrarumAud
|
||||
track.currentTrack?.reset()
|
||||
track.pullNextTrack()
|
||||
|
||||
val tmpBuf = ByteArray(buffer.size - bytesRead)
|
||||
val newRead = track.currentTrack?.gdxMusic?.forceInvoke<Int>("read", arrayOf(tmpBuf)) ?: 0
|
||||
bytesRead += read0(buffer, bytesRead)
|
||||
}
|
||||
// if isLooping=true, do gapless sampleRead but reads from itself
|
||||
else if (track.currentTrack?.gdxMusic?.isLooping == true && bytesRead < buffer.size) {
|
||||
track.currentTrack?.reset()
|
||||
|
||||
track.currentTrack?.let { it.samplesRead += newRead / 4 }
|
||||
System.arraycopy(tmpBuf, 0, buffer, bytesRead, tmpBuf.size)
|
||||
|
||||
bytesRead += newRead
|
||||
bytesRead += read0(buffer, bytesRead)
|
||||
}
|
||||
|
||||
bytesRead
|
||||
}, { purgeStreamBuf() })
|
||||
}
|
||||
|
||||
private fun read0(buffer: ByteArray, bytesRead: Int): Int {
|
||||
val tmpBuf = ByteArray(buffer.size - bytesRead)
|
||||
val newRead = track.currentTrack?.gdxMusic?.forceInvoke<Int>("read", arrayOf(tmpBuf)) ?: 0
|
||||
|
||||
track.currentTrack?.let { it.samplesRead += newRead / 4 }
|
||||
System.arraycopy(tmpBuf, 0, buffer, bytesRead, tmpBuf.size)
|
||||
|
||||
return newRead
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
// while (running) { // uncomment to multithread
|
||||
/*synchronized(pauseLock) { // uncomment to multithread
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.torvald.terrarum.Terrarum.getPlayerSaveFiledesc
|
||||
import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.audio.dsp.Gain
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
import net.torvald.terrarum.blockstats.MinimapComposer
|
||||
import net.torvald.terrarum.blockstats.TileSurvey
|
||||
@@ -914,7 +913,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
App.audioMixer.convolveBusCave.volume = 0.0
|
||||
}
|
||||
val openness = (TileSurvey.getRatio("basegame.Ingame.openness") ?: 0.0).times(1.74).coerceIn(0.0, 1.0)
|
||||
(App.audioMixer.ambSumBus.filters[1] as Gain).gain = openness.pow(2.0 / 3.0).toFloat()
|
||||
App.audioMixer.amb1plus2.volume = openness.pow(2.0 / 3.0)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,14 +9,15 @@ import com.badlogic.gdx.backends.lwjgl3.audio.Wav
|
||||
import com.badlogic.gdx.backends.lwjgl3.audio.Wav.WavInputStream
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import com.jcraft.jorbis.VorbisFile
|
||||
import com.jme3.math.FastMath
|
||||
import javazoom.jl.decoder.Bitstream
|
||||
import net.torvald.reflection.extortField
|
||||
import net.torvald.reflection.forceInvoke
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.audio.AudioMixer
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack
|
||||
import net.torvald.terrarum.audio.TerrarumAudioMixerTrack.Companion.SAMPLING_RATE
|
||||
import net.torvald.terrarum.gameworld.WorldTime.Companion.DAY_LENGTH
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import javax.sound.sampled.AudioSystem
|
||||
@@ -278,7 +279,7 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
||||
Gdx.audio.newMusic(fileHandle).also {
|
||||
it.isLooping = true
|
||||
}
|
||||
) { stopAmbient() }
|
||||
) { }
|
||||
}
|
||||
catch (e: GdxRuntimeException) {
|
||||
e.printStackTrace()
|
||||
@@ -373,15 +374,34 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
||||
// App.audioMixer.ambientTrack.nextTrack = currentAmbientTrack
|
||||
}
|
||||
|
||||
private fun startAmbient(song: MusicContainer) {
|
||||
currentAmbientTrack = song
|
||||
App.audioMixer.startAmb(song)
|
||||
printdbg(this, "startAmbient Now playing: $song")
|
||||
// INGAME.sendNotification("Now Playing $EMDASH ${song.name}")
|
||||
private fun startAmbient1(song: MusicContainer) {
|
||||
App.audioMixer.startAmb1(song)
|
||||
printdbg(this, "startAmbient1 Now playing: $song")
|
||||
ambState = STATE_PLAYING
|
||||
}
|
||||
private fun startAmbient2(song: MusicContainer) {
|
||||
App.audioMixer.startAmb2(song)
|
||||
printdbg(this, "startAmbient2 Now playing: $song")
|
||||
ambState = STATE_PLAYING
|
||||
}
|
||||
|
||||
private fun queueAmbientForce1(song: MusicContainer) {
|
||||
App.audioMixer.ambientTrack1.let {
|
||||
it.nextTrack = song
|
||||
it.stop()
|
||||
}
|
||||
printdbg(this, "startAmbient1 Now playing: $song")
|
||||
ambState = STATE_PLAYING
|
||||
}
|
||||
private fun queueAmbientForce2(song: MusicContainer) {
|
||||
App.audioMixer.ambientTrack2.let {
|
||||
it.nextTrack = song
|
||||
it.stop()
|
||||
}
|
||||
printdbg(this, "startAmbient2 Now playing: $song")
|
||||
ambState = STATE_PLAYING
|
||||
}
|
||||
|
||||
private lateinit var currentAmbientTrack: MusicContainer
|
||||
|
||||
override fun update(ingame: IngameInstance, delta: Float) {
|
||||
// start the song queueing if there is one to play
|
||||
@@ -409,36 +429,112 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
||||
}
|
||||
}
|
||||
|
||||
val season = ingame.world.worldTime.ecologicalSeason
|
||||
val isAM = (ingame.world.worldTime.todaySeconds < DAY_LENGTH / 2) // 0 until DAY_LENGTH (86400)
|
||||
val solarElevDeg = ingame.world.worldTime.solarElevationDeg
|
||||
val isSunUp = (solarElevDeg >= 0)
|
||||
val seasonName = when (season) {
|
||||
in 0f..2f -> "autumn"
|
||||
in 2f..3f -> "summer"
|
||||
in 3f..5f -> "autumn"
|
||||
else -> "winter"
|
||||
}
|
||||
|
||||
when (ambState) {
|
||||
STATE_FIREPLAY -> {
|
||||
if (!ambFired) {
|
||||
ambFired = true
|
||||
|
||||
val season = ingame.world.worldTime.ecologicalSeason
|
||||
val time = ingame.world.worldTime.todaySeconds // 0 until DAY_LENGTH (86400)
|
||||
val seasonName = when (season) {
|
||||
in 0f..2f -> "autumn"
|
||||
in 2f..3f -> "summer"
|
||||
in 3f..5f -> "autumn"
|
||||
else -> "winter"
|
||||
}
|
||||
val timeMode = "diurnal"
|
||||
// ambient track 1: diurnal/nocturnal
|
||||
// ambient track 2: crepuscular/matutinal
|
||||
val track1 = if (isSunUp)
|
||||
ambients["ambient.season.diurnal_$seasonName"]!!.random() // mad respect to Klankbeeld
|
||||
else
|
||||
ambients["ambient.season.nocturnal"]!!.random() // as it turns out ambient recordings of a wild place AT NIGHT is quite rare
|
||||
|
||||
val track = ambients["ambient.season.${timeMode}_$seasonName"]!!.random()
|
||||
startAmbient(track)
|
||||
val track2 = if (isAM)
|
||||
ambients["ambient.season.matutinal"]!!.random()
|
||||
else
|
||||
ambients["ambient.season.crepuscular"]!!.random()
|
||||
|
||||
startAmbient1(track1)
|
||||
startAmbient2(track2)
|
||||
}
|
||||
}
|
||||
STATE_PLAYING -> {
|
||||
// stopMusic() will be called when the music finishes; it's on the setOnCompletionListener
|
||||
// mix ambient tracks
|
||||
|
||||
// queue up nocturnal
|
||||
if (!isSunUp && oldWorldSolarElev >= 0)
|
||||
queueAmbientForce1(ambients["ambient.season.nocturnal"]!!.random()) // as it turns out ambient recordings of a wild place AT NIGHT is quite rare
|
||||
// queue up diurnal
|
||||
else if (isSunUp && oldWorldSolarElev < 0)
|
||||
queueAmbientForce1(ambients["ambient.season.diurnal_$seasonName"]!!.random()) // mad respect to Klankbeeld
|
||||
|
||||
// queue up crepuscular
|
||||
if (!isAM && oldWorldTime < DAY_LENGTH / 2)
|
||||
queueAmbientForce2(ambients["ambient.season.crepuscular"]!!.random())
|
||||
else if (isAM && oldWorldTime >= DAY_LENGTH / 2)
|
||||
queueAmbientForce2(ambients["ambient.season.matutinal"]!!.random())
|
||||
|
||||
// play around the fader
|
||||
val track2vol = if (isAM)
|
||||
when (solarElevDeg) {
|
||||
in TRACK2_DAWN_ELEV_UP_MIN..TRACK2_DAWN_ELEV_UP_MAX ->
|
||||
FastMath.interpolateLinear(
|
||||
(solarElevDeg - TRACK2_DAWN_ELEV_UP_MIN) / (TRACK2_DAWN_ELEV_UP_MAX - TRACK2_DAWN_ELEV_UP_MIN),
|
||||
1.0, 0.0
|
||||
)
|
||||
in TRACK2_DAWN_ELEV_DN_MAX..TRACK2_DAWN_ELEV_DN_MIN ->
|
||||
FastMath.interpolateLinear(
|
||||
(solarElevDeg - TRACK2_DAWN_ELEV_DN_MIN) / (TRACK2_DAWN_ELEV_DN_MAX - TRACK2_DAWN_ELEV_DN_MIN),
|
||||
1.0, 0.0
|
||||
)
|
||||
in TRACK2_DAWN_ELEV_DN_MIN..TRACK2_DAWN_ELEV_UP_MIN -> 1.0
|
||||
else -> 0.0
|
||||
}
|
||||
else
|
||||
when (solarElevDeg) {
|
||||
in TRACK2_DUSK_ELEV_UP_MIN..TRACK2_DUSK_ELEV_UP_MAX ->
|
||||
FastMath.interpolateLinear(
|
||||
(solarElevDeg - TRACK2_DUSK_ELEV_UP_MIN) / (TRACK2_DUSK_ELEV_UP_MAX - TRACK2_DUSK_ELEV_UP_MIN),
|
||||
1.0, 0.0
|
||||
)
|
||||
in TRACK2_DUSK_ELEV_DN_MAX..TRACK2_DUSK_ELEV_DN_MIN ->
|
||||
FastMath.interpolateLinear(
|
||||
(solarElevDeg - TRACK2_DUSK_ELEV_DN_MIN) / (TRACK2_DUSK_ELEV_DN_MAX - TRACK2_DUSK_ELEV_DN_MIN),
|
||||
1.0, 0.0
|
||||
)
|
||||
in TRACK2_DUSK_ELEV_DN_MIN..TRACK2_DUSK_ELEV_UP_MIN -> 1.0
|
||||
else -> 0.0
|
||||
}
|
||||
val track1vol = 1.0 - track2vol
|
||||
|
||||
App.audioMixer.ambientTrack1.volume = track1vol
|
||||
App.audioMixer.ambientTrack2.volume = track2vol
|
||||
}
|
||||
STATE_INTERMISSION -> {
|
||||
ambState = STATE_FIREPLAY
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
oldWorldSolarElev = solarElevDeg
|
||||
oldWorldTime = ingame.world.worldTime.todaySeconds
|
||||
}
|
||||
|
||||
private var oldWorldSolarElev = Terrarum.ingame?.world?.worldTime?.solarElevationDeg ?: 0.0
|
||||
private var oldWorldTime = Terrarum.ingame?.world?.worldTime?.todaySeconds ?: 0
|
||||
|
||||
private val TRACK2_DUSK_ELEV_UP_MAX = 15.0
|
||||
private val TRACK2_DUSK_ELEV_UP_MIN = 0.1
|
||||
private val TRACK2_DUSK_ELEV_DN_MIN = -0.1
|
||||
private val TRACK2_DUSK_ELEV_DN_MAX = -15.0
|
||||
|
||||
private val TRACK2_DAWN_ELEV_UP_MAX = 20.0
|
||||
private val TRACK2_DAWN_ELEV_UP_MIN = 5.0
|
||||
private val TRACK2_DAWN_ELEV_DN_MIN = 5.0
|
||||
private val TRACK2_DAWN_ELEV_DN_MAX = -10.0
|
||||
|
||||
override fun dispose() {
|
||||
App.audioMixer.requestFadeOut(App.audioMixer.fadeBus, AudioMixer.DEFAULT_FADEOUT_LEN) // explicit call for fade-out when the game instance quits
|
||||
stopMusic(App.audioMixer.musicTrack.currentTrack)
|
||||
|
||||
@@ -266,7 +266,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
App.bogoflops = maxOf(App.bogoflops, bogoflops)
|
||||
|
||||
|
||||
listOf(App.audioMixer.ambientTrack1, App.audioMixer.ambientTrack2).forEach {
|
||||
App.audioMixer.ambientTracks.forEach {
|
||||
it.stop()
|
||||
it.currentTrack = null
|
||||
it.nextTrack = null
|
||||
|
||||
Reference in New Issue
Block a user