audio engine: resize buffer without restarting the game

This commit is contained in:
minjaesong
2024-01-16 03:31:22 +09:00
parent 755ced9ea4
commit 2bd1b61a35
20 changed files with 39 additions and 121 deletions

View File

@@ -55,13 +55,6 @@ class BinoPan(var pan: Float, var earDist: Float = EARDIST_DEFAULT): TerrarumAud
private val HALF_PI = (Math.PI / 2.0).toFloat()
}
override fun reset() {
outLs = Array(2) { FloatArray(App.audioBufferSize) }
outRs = Array(2) { FloatArray(App.audioBufferSize) }
delayLineL.fill(0f)
delayLineR.fill(0f)
}
/**
* @param intensity -inf to +inf
*/

View File

@@ -34,8 +34,5 @@ class Bitcrush(var steps: Int, var inputGain: Float = 1f): TerrarumAudioFilter()
App.fontSmallNumbers.draw(batch, "B:$bits", x+3f, y+1f)
}
override fun reset() {
}
override val debugViewHeight = 16
}

View File

@@ -18,8 +18,5 @@ object Buffer : TerrarumAudioFilter() {
App.fontSmallNumbers.draw(batch, "Bs:${App.audioBufferSize}", x+3f, y+1f)
}
override fun reset() {
}
override val debugViewHeight = 16
}

View File

@@ -74,12 +74,6 @@ class Convolv(ir: File, val crossfeed: Float, gain: Float = 1f / 256f): Terrarum
private val fftOutL = FloatArray(fftLen)
private val fftOutR = FloatArray(fftLen)
override fun reset() {
realtime = (App.audioBufferSize / TerrarumAudioMixerTrack.SAMPLING_RATEF * 1000000000L)
processingSpeed = 1f
sumbuf.forEach { it.reim.fill(0f) }
}
private fun convolve(x: ComplexArray, h: ComplexArray, output: FloatArray) {
FFT.fftInto(x, fftIn)
fftIn.mult(h, fftMult)

View File

@@ -19,9 +19,5 @@ class Gain(var gain: Float): TerrarumAudioFilter() {
App.fontSmallNumbers.draw(batch, "G:${fullscaleToDecibels(gain.toDouble()).times(100).roundToInt().div(100f)}", x+3f, y+1f)
}
override fun reset() {
}
override val debugViewHeight = 16
}

View File

@@ -67,9 +67,4 @@ class Highpass(cutoff0: Float): TerrarumAudioFilter() {
}
override val debugViewHeight = 16
override fun reset() {
in0.fill(0f)
out0.fill(0f)
}
}

View File

@@ -67,9 +67,4 @@ class Lowpass(cutoff0: Float): TerrarumAudioFilter() {
}
override val debugViewHeight = 16
override fun reset() {
in0.fill(0f)
out0.fill(0f)
}
}

View File

@@ -13,7 +13,4 @@ object NullFilter : TerrarumAudioFilter() {
}
override val debugViewHeight = 0
override fun reset() {
}
}

View File

@@ -53,8 +53,4 @@ class Reverb(val delayMS: Float = 36f, var feedback: Float = 0.92f, var lowpass:
}
override val debugViewHeight = 0
override fun reset() {
buf.forEach { it.fill(0f) }
}
}

View File

@@ -56,7 +56,4 @@ object SoftClp : TerrarumAudioFilter() {
}
override val debugViewHeight = 0
override fun reset() {
}
}

View File

@@ -91,9 +91,6 @@ class Spectro(val gain: Float = 1f) : TerrarumAudioFilter() {
}
override val debugViewHeight = STRIP_W
override fun reset() {
}
}
@@ -157,13 +154,4 @@ class Vecto(val gain: Float = 1f) : TerrarumAudioFilter() {
}
override val debugViewHeight = STRIP_W
override fun reset() {
backbufL = Array((6144f / App.audioBufferSize).roundToInt().coerceAtLeast(1)) {
FloatArray(App.audioBufferSize)
}
backbufR = Array((6144f / App.audioBufferSize).roundToInt().coerceAtLeast(1)) {
FloatArray(App.audioBufferSize)
}
}
}

View File

@@ -13,7 +13,6 @@ abstract class TerrarumAudioFilter {
}
else thru(inbuf, outbuf)
}
abstract fun reset()
abstract fun drawDebugView(batch: SpriteBatch, x: Int, y: Int)
abstract val debugViewHeight: Int
}

View File

@@ -19,9 +19,6 @@ object XYtoMS: TerrarumAudioFilter() {
}
override val debugViewHeight = 0
override fun reset() {
}
}
object MStoXY: TerrarumAudioFilter() {
@@ -40,7 +37,4 @@ object MStoXY: TerrarumAudioFilter() {
}
override val debugViewHeight = 0
override fun reset() {
}
}