From 1b2fdf38de3d038a2d2e8d7143ad0baf4e9f6bea Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 20 Nov 2023 17:59:46 +0900 Subject: [PATCH] narrower mixer gui --- src/net/torvald/terrarum/audio/AudioMixer.kt | 2 +- .../terrarum/audio/MixerTrackProcessor.kt | 17 +++++++++++++---- .../torvald/terrarum/ui/BasicDebugInfoWindow.kt | 11 +++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/net/torvald/terrarum/audio/AudioMixer.kt b/src/net/torvald/terrarum/audio/AudioMixer.kt index 9390af1af..dafb66c76 100644 --- a/src/net/torvald/terrarum/audio/AudioMixer.kt +++ b/src/net/torvald/terrarum/audio/AudioMixer.kt @@ -44,7 +44,7 @@ object AudioMixer: Disposable { val tracks = Array(5) { TerrarumAudioMixerTrack( if (it == 0) "BGM" else if (it == 1) "AMB" - else if (it == 2) "Sfx Mix" + else if (it == 2) "SFX" else if (it == 3) "GUI" else if (it == 4) "BUS1" else "Trk${it+1}", isBus = (it == 4) diff --git a/src/net/torvald/terrarum/audio/MixerTrackProcessor.kt b/src/net/torvald/terrarum/audio/MixerTrackProcessor.kt index e3814c7d2..2b5201c47 100644 --- a/src/net/torvald/terrarum/audio/MixerTrackProcessor.kt +++ b/src/net/torvald/terrarum/audio/MixerTrackProcessor.kt @@ -93,9 +93,9 @@ class MixerTrackProcessor(val bufferSize: Int, val rate: Int, val track: Terraru // get samples and apply the fader if (track.isMaster || track.isBus) { - // TEST CODE must combine all the inputs + // TODO combine all the inputs track.sidechainInputs[TerrarumAudioMixerTrack.INDEX_BGM]?.let { (side, mix) -> - samplesL0 = side.processor.fout0[0].applyVolume((mix * track.volume).toFloat()) + samplesL0 = side.processor.fout0[0].applyVolume((mix * track.volume).toFloat()) // must not applyVolumeInline samplesR0 = side.processor.fout0[1].applyVolume((mix * track.volume).toFloat()) samplesL1 = side.processor.fout1[0].applyVolume((mix * track.volume).toFloat()) samplesR1 = side.processor.fout1[1].applyVolume((mix * track.volume).toFloat()) @@ -129,6 +129,14 @@ class MixerTrackProcessor(val bufferSize: Int, val rate: Int, val track: Terraru }*/ } + // source channel: skip processing if there's no active input +// else if (track.getSidechains().any { it != null && !it.isBus && !it.isMaster && !it.streamPlaying } && !track.streamPlaying) { + else if (!track.streamPlaying) { + samplesL0 = null + samplesR0 = null + samplesL1 = null + samplesR1 = null + } else { samplesL0 = streamBuf.getL0(track.volume) samplesR0 = streamBuf.getR0(track.volume) @@ -210,11 +218,12 @@ class MixerTrackProcessor(val bufferSize: Int, val rate: Int, val track: Terraru } private fun FloatArray.applyVolume(volume: Float) = FloatArray(this.size) { (this[it] * volume) } - private fun FloatArray.applyVolumeInline(volume: Float) { + /*private fun FloatArray.applyVolumeInline(volume: Float): FloatArray { for (i in this.indices) { this[i] *= volume } - } + return this + }*/ private fun resumeSidechainsRecursively(track: TerrarumAudioMixerTrack?, caller: String) { diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 318b8d9dc..d992a52c0 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -373,7 +373,7 @@ class BasicDebugInfoWindow : UICanvas() { } } - private val stripW = 64 + private val stripW = 56 private val stripGap = 1 private val stripFilterHeight = 32 private val stripFaderHeight = 200 @@ -475,11 +475,14 @@ class BasicDebugInfoWindow : UICanvas() { } // fader + val sliderX = x + stripW - 12 + + // slider text val dB = track.dBfs val dBstr = dB.toIntAndFrac(2,1) val dBfs = dB.coerceIn(-dbLow, 0.0).plus(dbLow).div(dbLow).toFloat() batch.color = FILTER_NAME_ACTIVE - App.fontSmallNumbers.draw(batch, dBstr, x+32f, faderY+1f) + App.fontSmallNumbers.draw(batch, dBstr, sliderX - 16f, faderY+1f) // fader trough batch.color = COL_METER_TROUGH @@ -513,10 +516,10 @@ class BasicDebugInfoWindow : UICanvas() { // slider trough batch.color = COL_METER_TROUGH - Toolkit.fillArea(batch, x + 48, faderY + 16, 2, meterTroughHeight) + Toolkit.fillArea(batch, sliderX, faderY + 16, 2, meterTroughHeight) // slider handle - drawFaderHandle(batch, x + 48f, faderY + 18f + meterHeight - dBfs * meterHeight) + drawFaderHandle(batch, sliderX.toFloat(), faderY + 18f + meterHeight - dBfs * meterHeight) // currently streaming if (track.streamPlaying) {