reduced number of tracks; highpass filter wip

This commit is contained in:
minjaesong
2023-11-19 01:47:32 +09:00
parent 60d793f753
commit 19315ac6e8
2 changed files with 45 additions and 1 deletions

View File

@@ -36,9 +36,11 @@ object AudioMixer: Disposable {
get() = App.getConfigDouble("sfxvolume")
val tracks = Array(10) { TerrarumAudioMixerTrack(
val tracks = Array(4) { TerrarumAudioMixerTrack(
if (it == 0) "BGM"
else if (it == 1) "AMB"
else if (it == 2) "Sfx Mix"
else if (it == 3) "GUI"
else "Trk${it+1}"
) }

View File

@@ -64,6 +64,48 @@ class Lowpass(cutoff0: Float, val rate: Int): TerrarumAudioFilter() {
}
class Highpass(cutoff0: Float, val rate: Int): TerrarumAudioFilter() {
var cutoff = cutoff0.toDouble(); private set
private var alpha: Float = 0f
init {
setCutoff(cutoff0)
}
fun setCutoff(cutoff: Float) {
// println("LP Cutoff: $cutoff")
val RC: Float = 1f / (cutoff * FastMath.TWO_PI)
val dt: Float = 1f / rate
alpha = dt / (RC + dt)
this.cutoff = cutoff.toDouble()
}
fun setCutoff(cutoff: Double) {
// println("LP Cutoff: $cutoff")
val RC: Double = 1.0 / (cutoff * Math.PI * 2.0)
val dt: Double = 1.0 / rate
alpha = (dt / (RC + dt)).toFloat()
this.cutoff = cutoff
}
override fun thru(inbuf0: List<FloatArray>, inbuf1: List<FloatArray>, outbuf0: List<FloatArray>, outbuf1: List<FloatArray>) {
for (ch in outbuf1.indices) {
val out = outbuf1[ch]
val inn = inbuf1[ch]
out[0] = outbuf0[ch].last()
for (i in 1 until outbuf1[ch].size) {
out[i] = inn[i] - inn[i-1] + (alpha * out[i-1]) // this actually works but setCutoff need to be changed
}
}
}
}
object Buffer : TerrarumAudioFilter() {
init {
bypass = true