mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
filter info view for BinoPan
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.audio
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.backends.lwjgl3.audio.Lwjgl3Audio
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import com.jme3.math.FastMath
|
||||
@@ -95,6 +96,8 @@ object AudioMixer: Disposable {
|
||||
|
||||
|
||||
init {
|
||||
// musicTrack.filters[0] = BinoPan((Math.random() * 2.0 - 1.0).toFloat())
|
||||
|
||||
masterTrack.filters[0] = SoftClp
|
||||
masterTrack.filters[1] = Buffer
|
||||
masterTrack.filters[2] = Scope()
|
||||
@@ -138,11 +141,19 @@ object AudioMixer: Disposable {
|
||||
private var lpStart = SAMPLING_RATED / 2.0
|
||||
private var lpTarget = SAMPLING_RATED / 2.0
|
||||
|
||||
// TODO make sidechaining work
|
||||
// TODO master volume controls the master track
|
||||
// TODO fadein/out controls the master track
|
||||
|
||||
fun update(delta: Float) {
|
||||
// test the panning
|
||||
/*(musicTrack.filters[0] as? BinoPan)?.let {
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
|
||||
it.pan = (it.pan + 0.001f).coerceIn(-1f, 1f)
|
||||
}
|
||||
else if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
|
||||
it.pan = (it.pan - 0.001f).coerceIn(-1f, 1f)
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
// the real updates
|
||||
(Gdx.audio as? Lwjgl3Audio)?.update()
|
||||
masterTrack.volume = masterVolume
|
||||
|
||||
@@ -207,8 +207,7 @@ class BinoPan(var pan: Float, var soundSpeed: Float = 340f, var earDist: Float =
|
||||
val delayInSamples = (timeDiffMax * sin(angle)).absoluteValue
|
||||
val volMultDbThis = PANNING_CONST * pan.absoluteValue
|
||||
val volMultFsThis = decibelsToFullscale(volMultDbThis).toFloat()
|
||||
val volMultDbOther = -(PANNING_CONST * pan.absoluteValue)
|
||||
val volMUltFsOther = decibelsToFullscale(volMultDbOther).toFloat()
|
||||
val volMUltFsOther = 1f / volMultFsThis
|
||||
|
||||
if (pan >= 0) {
|
||||
delays[0] = delayInSamples
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||
import net.torvald.terrarum.modulebasegame.ui.abs
|
||||
import net.torvald.terrarum.weather.WeatherDirBox
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import net.torvald.terrarum.weather.WeatherStateBox
|
||||
@@ -588,7 +589,8 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
private val paramViewHeight = hashMapOf(
|
||||
"Lowpass" to 16,
|
||||
"Buffer" to 16,
|
||||
"Scope" to stripW
|
||||
"BinoPan" to 32,
|
||||
"Scope" to stripW,
|
||||
)
|
||||
|
||||
|
||||
@@ -606,6 +608,21 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
batch.color = FILTER_NAME_ACTIVE
|
||||
App.fontSmallNumbers.draw(batch, "F:${filter.cutoff.toInt()}", x+3f, y+1f)
|
||||
}
|
||||
is BinoPan -> {
|
||||
val w = filter.pan * 0.5f * stripW
|
||||
batch.color = COL_METER_GRAD2
|
||||
Toolkit.fillArea(batch, x + stripW / 2f, y.toFloat(), w, 14f)
|
||||
batch.color = COL_METER_GRAD
|
||||
Toolkit.fillArea(batch, x + stripW / 2f, y+14f, w, 2f)
|
||||
|
||||
batch.color = FILTER_NAME_ACTIVE
|
||||
val panLabel = if (filter.pan == 0f) "<C>"
|
||||
else if (filter.pan < 0) "L${filter.pan.absoluteValue.times(100).toIntAndFrac(3,1)}"
|
||||
else "R${filter.pan.absoluteValue.times(100).toIntAndFrac(3,1)}"
|
||||
App.fontSmallNumbers.draw(batch, panLabel, x+3f, y+1f)
|
||||
|
||||
App.fontSmallNumbers.draw(batch, "AS:${filter.soundSpeed.roundToInt()}", x+3f, y+17f)
|
||||
}
|
||||
is Buffer -> {
|
||||
batch.color = FILTER_NAME_ACTIVE
|
||||
App.fontSmallNumbers.draw(batch, "Bs:${BUFFER_SIZE/4}", x+3f, y+1f)
|
||||
|
||||
Reference in New Issue
Block a user