Add inverse gain to compressor. The inverse gain is applied to the signal before any compressor calculations.

This commit is contained in:
Veikko Sariola 2020-05-27 18:53:54 +03:00
parent c5b6e6e28c
commit 7e3dc19c83
6 changed files with 13 additions and 7 deletions

View File

@ -431,13 +431,16 @@ su_op_delay_loop:
SECT_TEXT(sucompr)
EXPORT MANGLE_FUNC(su_op_compressor,0)
fdiv dword [INP+su_compres_ports.invgain]; l/g, we'll call this pre inverse gained signal x from now on
fld st0 ; x x
fmul st0, st0 ; x^2 x
%ifdef INCLUDE_STEREO_COMPRES
jnc su_op_compressor_mono
fld st2 ; r l^2 l r
fmul st0, st0 ; r^2 l^2 l r
faddp st1, st0 ; r^2+l^2 l r
fld st2 ; r x^2 l/g r
fdiv dword [INP+su_compres_ports.invgain]; r/g, we'll call this pre inverse gained signal y from now on
fst st3 ; y x^2 l/g r/g
fmul st0, st0 ; y^2 x^2 l/g r/g
faddp st1, st0 ; y^2+x^2 l/g r/g
call su_op_compressor_mono ; So, for stereo, we square both left & right and add them up
fld st0 ; and return the computed gain two times, ready for MULP STEREO
ret

View File

@ -347,15 +347,16 @@ endstruc
%assign COMPRES_ID CUR_ID
%assign CUR_ID CUR_ID + 2
%xdefine OPCODES OPCODES MANGLE_FUNC(su_op_compressor,0),
%xdefine NUMPARAMS NUMPARAMS 4,
%xdefine NUMPARAMS NUMPARAMS 5,
%endif
%endmacro
%macro SU_COMPRES 5
%macro SU_COMPRES 6
db %2
db %3
db %4
db %5
db %6
USE_COMPRES
%xdefine CMDS CMDS COMPRES_ID + %1,
%if %1 == STEREO
@ -365,12 +366,14 @@ endstruc
%define ATTAC(val) val
%define RELEASE(val) val
%define INVGAIN(val) val
%define THRESHOLD(val) val
%define RATIO(val) val
struc su_compres_ports
.attack resd 1
.release resd 1
.invgain resd 1
.threshold resd 1
.ratio resd 1
endstruc

View File

@ -33,7 +33,7 @@ BEGIN_PATCH
END_INSTRUMENT
BEGIN_INSTRUMENT VOICES(1) ; Global compressor effect
SU_RECEIVE STEREO
SU_COMPRES MONO,ATTAC(32),RELEASE(80),THRESHOLD(32),RATIO(64)
SU_COMPRES MONO,ATTAC(32),RELEASE(64),INVGAIN(32),THRESHOLD(64),RATIO(96)
SU_MULP MONO
SU_OUT STEREO, GAIN(128)
END_INSTRUMENT

View File

@ -33,7 +33,7 @@ BEGIN_PATCH
END_INSTRUMENT
BEGIN_INSTRUMENT VOICES(1) ; Global compressor effect
SU_RECEIVE STEREO
SU_COMPRES STEREO,ATTAC(32),RELEASE(80),THRESHOLD(32),RATIO(64)
SU_COMPRES STEREO,ATTAC(32),RELEASE(64),INVGAIN(32),THRESHOLD(64),RATIO(96)
SU_MULP STEREO
SU_OUT STEREO, GAIN(128)
END_INSTRUMENT