mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-25 18:00:37 -04:00
Implement compile definition RUNTIME_TABLES, which enables putting the pointers to delay and sample tables to stack.
Useful for the eventual API to be able to modify the delay and sample tables during runtime.
This commit is contained in:
parent
c7c752cd73
commit
ccb6434fac
@ -317,7 +317,12 @@ EXPORT MANGLE_FUNC(su_op_delay,0)
|
||||
lodsw ; al = delay index, ah = delay count
|
||||
push_registers VAL, COM ; these are non-volatile according to our convention
|
||||
movzx ebx, al
|
||||
%ifdef RUNTIME_TABLES ; when using runtime tables, delaytimes is pulled from the stack so can be a pointer to heap
|
||||
mov _SI, [_SP + su_stack.delaytimes + PUSH_REG_SIZE(2)]
|
||||
lea _BX, [_SI + _BX*2]
|
||||
%else
|
||||
do{lea _BX,[},MANGLE_DATA(su_delay_times),_BX*2,] ; _BP now points to the right position within delay time table
|
||||
%endif
|
||||
movzx esi, word [_SP + su_stack.tick + PUSH_REG_SIZE(2)] ; notice that we load word, so we wrap at 65536
|
||||
mov _CX, PTRWORD [_SP + su_stack.delaywrk + PUSH_REG_SIZE(2)] ; WRK is now the separate delay workspace, as they require a lot more space
|
||||
%ifdef INCLUDE_STEREO_DELAY
|
||||
|
@ -147,6 +147,14 @@ struc su_stack ; the structure of stack _as the units see it_
|
||||
.row RESPTR 1 ; which total row of the song are we at
|
||||
.tick RESPTR 1 ; which total tick of the song are we at
|
||||
.randseed RESPTR 1
|
||||
%ifdef RUNTIME_TABLES ; RUNTIME_TABLES move these table ptrs to stack
|
||||
%if DELAY_ID > -1 ; allowing them to be in the heap &
|
||||
.delaytimes RESPTR 1 ; modifying them safely & having many synths
|
||||
%endif
|
||||
%ifdef INCLUDE_SAMPLES
|
||||
.sampleoffs RESPTR 1
|
||||
%endif
|
||||
%endif
|
||||
%ifdef INCLUDE_MULTIVOICE_TRACKS
|
||||
.voicetrack RESPTR 1
|
||||
%endif
|
||||
@ -344,6 +352,14 @@ EXPORT MANGLE_FUNC(su_render_song,PTRSIZE) ; Stack: ptr
|
||||
xor eax, eax
|
||||
%ifdef INCLUDE_MULTIVOICE_TRACKS
|
||||
push VOICETRACK_BITMASK
|
||||
%endif
|
||||
%ifdef RUNTIME_TABLES ; runtime tables is actually only useful in the api use case, but it's nice it works also in the render case
|
||||
%ifdef INCLUDE_SAMPLES
|
||||
do push ,MANGLE_DATA(su_sample_offsets) ; &su_sample_offsets is in the stack, instead of hard coded
|
||||
%endif
|
||||
%if DELAY_ID > -1
|
||||
do push ,MANGLE_DATA(su_delay_times) ; &su_delay_times is in the stack, instead of hard coded
|
||||
%endif
|
||||
%endif
|
||||
push 1 ; randseed
|
||||
push _AX ; global tick time
|
||||
|
@ -106,6 +106,11 @@ SECT_TEXT(suoscill)
|
||||
|
||||
EXPORT MANGLE_FUNC(su_op_oscillat,0)
|
||||
lodsb ; load the flags
|
||||
%ifdef RUNTIME_TABLES
|
||||
%ifdef INCLUDE_SAMPLES
|
||||
mov _DI, [_SP + su_stack.sampleoffs]; we need to put this in a register, as the stereo & unisons screw the stack positions
|
||||
%endif ; ain't we lucky that _DI was unused throughout
|
||||
%endif
|
||||
fld dword [INP+su_osc_ports.detune] ; e, where e is the detune [0,1]
|
||||
do fsub dword [,c_0_5,] ; e-.5
|
||||
fadd st0, st0 ; d=2*e-.5, where d is the detune [-1,1]
|
||||
@ -311,7 +316,11 @@ su_oscillat_sample: ; p
|
||||
push_registers _AX,_DX,_CX,_BX ; edx must be saved, eax & ecx if this is stereo osc
|
||||
push _AX
|
||||
mov al, byte [VAL-4] ; reuse "color" as the sample number
|
||||
%ifdef RUNTIME_TABLES ; when using RUNTIME_TABLES, assumed the sample_offset ptr is in _DI
|
||||
do{lea _DI, [}, _DI, _AX*8,] ; edi points now to the sample table entry
|
||||
%else
|
||||
do{lea _DI, [}, MANGLE_DATA(su_sample_offsets), _AX*8,]; edi points now to the sample table entry
|
||||
%endif
|
||||
do fmul dword [,c_samplefreq_scaling,] ; p*r
|
||||
fistp dword [_SP]
|
||||
pop _DX ; edx is now the sample number
|
||||
|
@ -97,6 +97,10 @@ if(WIN32) # The samples are currently only GMDLs based, and thus require Windows
|
||||
target_compile_definitions(test_oscillat_sample PUBLIC INCLUDE_GMDLS)
|
||||
regression_test(test_oscillat_sample_stereo ENVELOPE)
|
||||
target_compile_definitions(test_oscillat_sample_stereo PUBLIC INCLUDE_GMDLS)
|
||||
regression_test(test_oscillat_sample_rtables ENVELOPE "" test_oscillat_sample.asm)
|
||||
target_compile_definitions(test_oscillat_sample_rtables PUBLIC INCLUDE_GMDLS RUNTIME_TABLES)
|
||||
regression_test(test_oscillat_sample_stereo_rtables ENVELOPE "" test_oscillat_sample_stereo.asm)
|
||||
target_compile_definitions(test_oscillat_sample_stereo_rtables PUBLIC INCLUDE_GMDLS RUNTIME_TABLES)
|
||||
endif()
|
||||
regression_test(test_oscillat_unison ENVELOPE)
|
||||
regression_test(test_oscillat_unison_stereo ENVELOPE)
|
||||
@ -143,6 +147,11 @@ regression_test(test_delay_dampmod "ENVELOPE;FOP_MULP;PANNING;VCO_SINE;SEND")
|
||||
regression_test(test_delay_drymod "ENVELOPE;FOP_MULP;PANNING;VCO_SINE;SEND")
|
||||
regression_test(test_delay_flanger "ENVELOPE;FOP_MULP;PANNING;VCO_SINE;SEND")
|
||||
|
||||
regression_test(test_delay_rtables "ENVELOPE;FOP_MULP;PANNING;VCO_SINE" "" test_delay.asm)
|
||||
target_compile_definitions(test_delay_rtables PUBLIC RUNTIME_TABLES)
|
||||
regression_test(test_delay_stereo_rtables "ENVELOPE;FOP_MULP;PANNING;VCO_SINE" "" test_delay_stereo.asm)
|
||||
target_compile_definitions(test_delay_stereo_rtables PUBLIC RUNTIME_TABLES)
|
||||
|
||||
regression_test(test_envelope_mod "VCO_SINE;ENVELOPE;SEND")
|
||||
regression_test(test_envelope_16bit ENVELOPE "" test_envelope.asm)
|
||||
target_compile_definitions(test_envelope_16bit PUBLIC SU_USE_16BIT_OUTPUT)
|
||||
|
BIN
tests/expected_output/test_delay_rtables.raw
Normal file
BIN
tests/expected_output/test_delay_rtables.raw
Normal file
Binary file not shown.
BIN
tests/expected_output/test_delay_stereo_rtables.raw
Normal file
BIN
tests/expected_output/test_delay_stereo_rtables.raw
Normal file
Binary file not shown.
BIN
tests/expected_output/test_oscillat_sample_rtables.raw
Normal file
BIN
tests/expected_output/test_oscillat_sample_rtables.raw
Normal file
Binary file not shown.
BIN
tests/expected_output/test_oscillat_sample_stereo_rtables.raw
Normal file
BIN
tests/expected_output/test_oscillat_sample_stereo_rtables.raw
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user