fix(vm): change crush resolution to bits (closes #79)

BREAKING CHANGE: The problem with crush was that it had very few usable values. This changes the crush to map the value nonlinearly, so the crush resolution is bits. Still the upper portion of the values is not very usable (bits 12-24 i.e. hardly any crushing), but at least the lower portion is usable. But now crush resolution has slightly different meaning.
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2023-09-23 21:07:35 +03:00
parent 1ac2ad3c75
commit 7df8103bf9
10 changed files with 24 additions and 10 deletions

View File

@ -34,16 +34,19 @@ su_op_hold_holding:
;-------------------------------------------------------------------------------
; CRUSH opcode: quantize the signal to finite number of levels
;-------------------------------------------------------------------------------
; Mono: x -> e*int(x/e)
; Mono: x -> e*int(x/e) where e=2**(-24*resolution)
; Stereo: l r -> e*int(l/e) e*int(r/e)
;-------------------------------------------------------------------------------
{{.Func "su_op_crush" "Opcode"}}
{{- if .Stereo "crush"}}
{{.Call "su_effects_stereohelper"}}
{{- end}}
fdiv dword [{{.Input "crush" "resolution"}}]
xor eax, eax
{{.Call "su_nonlinear_map"}}
fxch st0, st1
fdiv st0, st1
frndint
fmul dword [{{.Input "crush" "resolution"}}]
fmulp st1, st0
ret
{{end}}