mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
why the hell I thought circular buffering would be better, when it makes FOUR memcpy insead of TWO
This commit is contained in:
@@ -96,20 +96,11 @@ object FFT: Disposable {
|
|||||||
return ComplexArray(signal)
|
return ComplexArray(signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fft(signal0: ComplexArray) {
|
|
||||||
ffts[signal0.size]!!.complexForward(signal0.reim)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fftInto(signal0: ComplexArray, out: ComplexArray) {
|
fun fftInto(signal0: ComplexArray, out: ComplexArray) {
|
||||||
System.arraycopy(signal0.reim, 0, out.reim, 0, signal0.reim.size)
|
System.arraycopy(signal0.reim, 0, out.reim, 0, signal0.reim.size)
|
||||||
ffts[signal0.size]!!.complexForward(out.reim)
|
ffts[signal0.size]!!.complexForward(out.reim)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ifftAndGetReal(signal0: ComplexArray): FloatArray {
|
|
||||||
ffts[signal0.size]!!.complexInverse(signal0.reim, true)
|
|
||||||
return signal0.getReal()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ifftAndGetReal(signal0: ComplexArray, output: FloatArray) {
|
fun ifftAndGetReal(signal0: ComplexArray, output: FloatArray) {
|
||||||
ffts[signal0.size]!!.complexInverse(signal0.reim, true)
|
ffts[signal0.size]!!.complexInverse(signal0.reim, true)
|
||||||
for (i in 0 until signal0.size) {
|
for (i in 0 until signal0.size) {
|
||||||
|
|||||||
@@ -93,18 +93,6 @@ class Convolv(irModule: String, irPath: String, val crossfeed: Float, gain: Floa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var bufferIndex = 0
|
|
||||||
private fun pushSumCircular(gain: Float, sampleL: FloatArray, sampleR: FloatArray, sumbuf: Array<ComplexArray>) {
|
|
||||||
val baseIdx = bufferIndex * 2
|
|
||||||
for (i in sampleL.indices) {
|
|
||||||
sumbuf[0].reim[baseIdx + i * 2] = (sampleL[i] + sampleR[i] * crossfeed) * gain
|
|
||||||
sumbuf[0].reim[baseIdx + i * 2 + 1] = 0f
|
|
||||||
sumbuf[1].reim[baseIdx + i * 2] = (sampleL[i] * crossfeed + sampleR[i]) * gain
|
|
||||||
sumbuf[1].reim[baseIdx + i * 2 + 1] = 0f
|
|
||||||
}
|
|
||||||
bufferIndex = (bufferIndex + sampleL.size) % (fftLen - sampleL.size)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun drawDebugView(batch: SpriteBatch, x: Int, y: Int) {
|
override fun drawDebugView(batch: SpriteBatch, x: Int, y: Int) {
|
||||||
// processing speed bar
|
// processing speed bar
|
||||||
val w = processingSpeed
|
val w = processingSpeed
|
||||||
|
|||||||
Reference in New Issue
Block a user