Move all constants into the end of sointu.asm, littering them around started getting messy.

This commit is contained in:
Veikko Sariola 2020-05-26 16:30:57 +03:00
parent 35b8253776
commit cf86a951f5
8 changed files with 41 additions and 87 deletions

View File

@ -376,6 +376,7 @@ su_op_delay_loop:
fld dword [WRK+su_unit.ports+su_delay_ports.delaymod]
do fmul dword [,c_32767,] ; scale it up, as the modulations would be too small otherwise
faddp st1, st0
%define USE_C_32767
%endif
fistp dword [_SP-4] ; dr*y p*p*x, dword [_SP-4] = integer amount of delay (samples)
mov edi, esi ; edi = esi = current time
@ -413,23 +414,7 @@ su_op_delay_loop:
fst dword [_CX+su_delayline_wrk.dcout] ; o'=s+c*o-i
ret
;-------------------------------------------------------------------------------
; Delay data
;-------------------------------------------------------------------------------
SECT_DATA(suconst)
%ifndef C_DC_CONST
c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate)
%define C_DC_CONST
%endif
%ifdef INCLUDE_DELAY_MODULATION
%ifndef C_32767
c_32767 dd 32767.0
%define C_32767
%endif
%endif
%define USE_C_DC_CONST
%endif ; DELAY_ID > -1

View File

@ -66,19 +66,6 @@ EXPORT MANGLE_FUNC(su_op_speed,0)
fstp dword [WRK+su_speed_wrk.remainder] ; save the remainder for future
ret
SECT_DATA(suconst)
c_bpmscale dd 2.666666666666 ; 64/24, 24 values will be double speed, so you can go from ~ 1/2.5 speed to 2.5x speed
%endif
;-------------------------------------------------------------------------------
; Constants
;-------------------------------------------------------------------------------
%ifdef SU_USE_DLL_DC_FILTER
%ifndef C_DC_CONST
SECT_DATA(suconst)
c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate)
%define C_DC_CONST
%endif
%define USE_C_BPMSCALE
%endif

View File

@ -212,14 +212,6 @@ su_op_oscillat_gain:
ret
%define SU_INCLUDE_WAVESHAPER
SECT_DATA(suconst)
%ifndef C_FREQ_NORMALIZE
c_freq_normalize dd 0.000092696138 ; // 220.0/(2^(69/12)) / 44100.0
%define C_FREQ_NORMALIZE
%endif
c_lfo_normalize dd 0.000038
%endif
; PULSE
@ -306,17 +298,8 @@ go4kVCO_gate_bit: ; stack: 0/1, let's call it x
ret ; g'=cg+(1-c)x
; This is a low-pass to smooth the gate transitions
SECT_DATA(suconst)
%ifndef C_16
c_16 dd 16.0
%define C_16
%endif
%ifndef C_DC_CONST
c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate)
%define C_DC_CONST
%endif
%define USE_C_16
%define USE_C_DC_CONST
%endif
@ -348,11 +331,8 @@ su_oscillat_sample_not_looping:
pop_registers _AX,_DX,_CX,_BX
ret
SECT_DATA(suconst)
%ifndef C_32767
c_32767 dd 32767.0
%define C_32767
%endif
%define USE_C_32767
%define USE_C_SAMPLEFREQ_SCALING
%endif

View File

@ -29,18 +29,6 @@ su_synth_obj resb su_synth.size
resb NUM_DELAY_LINES*su_delayline_wrk.size
%endif
;-------------------------------------------------------------------------------
; Constants
;-------------------------------------------------------------------------------
SECT_DATA(suconst)
%ifdef SU_USE_16BIT_OUTPUT
%ifndef C_32767
c_32767 dd 32767.0
%define C_32767
%endif
%endif
;-------------------------------------------------------------------------------
; output_sound macro: used by the render function to write sound to buffer
;-------------------------------------------------------------------------------
@ -91,6 +79,7 @@ SECT_DATA(suconst)
add _SI,2
loop %%loop
mov [_SP+su_stack.bufferptr - su_stack.output_sound], _SI ; save esi back to stack
%define USE_C_32767
%endif
%endmacro

View File

@ -155,19 +155,6 @@ SECT_DATA(suparcnt)
su_opcode_numparams db NUMPARAMS
;-------------------------------------------------------------------------------
; Constants used by the common functions
;-------------------------------------------------------------------------------
SECT_DATA(suconst)
c_i128 dd 0.0078125
c_RandDiv dd 65536*32768
c_0_5 dd 0.5
c_24 dd 24
c_i12 dd 0x3DAAAAAA
EXPORT MANGLE_DATA(LFO_NORMALIZE)
dd DEF_LFO_NORMALIZE
;-------------------------------------------------------------------------------
; su_run_vm function: runs the entire virtual machine once, creating 1 sample
;-------------------------------------------------------------------------------
@ -274,3 +261,36 @@ EXPORT MANGLE_FUNC(su_power,0)
%ifidn __OUTPUT_FORMAT__,win32
%include "win32/gmdls_win32.asm"
%endif
;-------------------------------------------------------------------------------
; Constants
;-------------------------------------------------------------------------------
SECT_DATA(suconst)
c_24 dd 24
c_i128 dd 0.0078125
c_RandDiv dd 65536*32768
c_0_5 dd 0.5
c_i12 dd 0x3DAAAAAA
c_lfo_normalize dd 0.000038
c_freq_normalize dd 0.000092696138 ; // 220.0/(2^(69/12)) / 44100.0
%ifdef USE_C_DC_CONST
c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate)
%endif
%ifdef USE_C_32767
c_32767 dd 32767.0
%endif
%ifdef USE_C_BPMSCALE
c_bpmscale dd 2.666666666666 ; 64/24, 24 values will be double speed, so you can go from ~ 1/2.5 speed to 2.5x speed
%endif
%ifdef USE_C_16
c_16 dd 16.0
%endif
%ifdef USE_C_SAMPLEFREQ_SCALING
c_samplefreq_scaling dd 84.28074964676522 ; o = 0.000092696138, n = 72, f = 44100*o*2**(n/12), scaling = 22050/f <- so note 72 plays at the "normal rate"
%endif

View File

@ -104,7 +104,6 @@
%define TOTAL_ROWS (MAX_PATTERNS*PATTERN_SIZE)
%define SAMPLES_PER_ROW (SAMPLE_RATE*4*60/(BPM*16))
%define DEF_LFO_NORMALIZE 0.000038
%define MAX_SAMPLES (SAMPLES_PER_ROW*TOTAL_ROWS)
%macro SU_BEGIN_PATCH 0

View File

@ -33,9 +33,6 @@ su_gmdls_path1:
su_gmdls_path2:
db 'drivers/etc/gm.dls',0
SECT_DATA(suconst)
c_samplefreq_scaling dd 84.28074964676522 ; o = 0.000092696138, n = 72, f = 44100*o*2**(n/12), scaling = 22050/f <- so note 72 plays at the "normal rate"
SECT_BSS(susamtbl)
EXPORT MANGLE_DATA(su_sample_table) resb SAMPLE_TABLE_SIZE ; size of gmdls.

View File

@ -35,9 +35,6 @@ su_gmdls_path1:
su_gmdls_path2:
db 'drivers/etc/gm.dls',0
SECT_DATA(suconst)
c_samplefreq_scaling dd 84.28074964676522 ; o = 0.000092696138, n = 72, f = 44100*o*2**(n/12), scaling = 22050/f <- so note 72 plays at the "normal rate"
SECT_BSS(susamtbl)
EXPORT MANGLE_DATA(su_sample_table) resb SAMPLE_TABLE_SIZE ; size of gmdls.