BUFFER_SIZE is now strictly samples count

This commit is contained in:
minjaesong
2023-12-11 14:03:34 +09:00
parent 949376b26a
commit 96c9aed25a
11 changed files with 83 additions and 78 deletions

View File

@@ -6,7 +6,7 @@ import net.torvald.terrarum.roundToFloat
class Bitcrush(var steps: Int, var inputGain: Float = 1f): TerrarumAudioFilter() {
override fun thru(inbuf: List<FloatArray>, outbuf: List<FloatArray>) {
for (ch in outbuf.indices) {
for (i in 0 until TerrarumAudioMixerTrack.BUFFER_SIZE / 4) {
for (i in 0 until TerrarumAudioMixerTrack.AUDIO_BUFFER_SIZE) {
val inn = ((inbuf[ch][i] * inputGain).coerceIn(-1f, 1f) + 1f) / 2f // 0f..1f
val stepped = (inn * (steps - 1)).roundToFloat() / (steps - 1)
val out = (stepped * 2f) - 1f // -1f..1f