This commit is contained in:
2024-08-02 14:19:07 +03:00
parent cf53da8e33
commit 53b46c3f83
6 changed files with 77 additions and 90 deletions

View File

@ -1,6 +1,6 @@
%define SU_LENGTH_IN_SAMPLES 4521776
%define SU_LENGTH_IN_SAMPLES 4214960
%define SU_SAMPLE_RATE 44100
%define SU_BPM 110.
%define SU_BPM 118.
;-------------------------------------------------------------------------------
; unit struct
@ -114,7 +114,7 @@ su_render_sampleloop: ; loop through every sample in the row
pop eax ; eax = Sample, Stack: Row, GlobalTick, RandSeed, VoiceTrackBitmask, edi, esi, ebp, esp, ebx, edx, ecx, eax, retaddr_su_render_song, OutputBufPtr
inc dword [esp + 4] ; increment global time, used by delays
inc eax
cmp eax, 6013
cmp eax, 5605
jl su_render_sampleloop
pop eax ; eax = Row, Stack: GlobalTick, RandSeed, VoiceTrackBitmask, edi, esi, ebp, esp, ebx, edx, ecx, eax, retaddr_su_render_song, OutputBufPtr ; Stack: pushad ptr
inc eax
@ -301,6 +301,7 @@ su_op_xch:
section .su_op_filter code align=1
su_op_filter:
lodsb ; load the flags to al
call su_effects_stereohelper
fld dword [edx + 4] ; r x
fld dword [edx]; f r x
fmul st0, st0 ; f2 x (square the input so we never get negative and also have a smoother behaviour in the lower frequencies)
@ -322,10 +323,10 @@ su_op_filter:
jz short su_op_filter_skiplowpass
fadd dword [ebp]
su_op_filter_skiplowpass:
test al, byte 0x04
jz short su_op_filter_skipneghighpass
fsub dword [ebp+4]
su_op_filter_skipneghighpass:
test al, byte 0x08
jz short su_op_filter_skipnegbandpass
fsub dword [ebp+8]
su_op_filter_skipnegbandpass:
ret
;-------------------------------------------------------------------------------
; PAN opcode: pan the signal
@ -548,24 +549,6 @@ su_op_envelope_leave2:
fmul dword [edx + 16] ; [gain]*x'
ret
;-------------------------------------------------------------------------------
; NOISE opcode: creates noise
;-------------------------------------------------------------------------------
; Mono: push a random value [-1,1] value on stack
; Stereo: push two (differeent) random values on stack
;-------------------------------------------------------------------------------
section .su_op_noise code align=1
su_op_noise:
lea ecx,[esp + 60]
imul eax, [ecx],16007
mov [ecx],eax
fild dword [ecx]
fidiv dword [ICONST_2147483648] ; 65536*32768
fld dword [edx]
call su_waveshaper
fmul dword [edx + 4]
ret
;-------------------------------------------------------------------------------
; OSCILLAT opcode: oscillator, the heart of the synth
;-------------------------------------------------------------------------------
@ -797,6 +780,23 @@ su_waveshaper:
fmulp st1 ; x*a/(1-a+(2*a-1)*abs(x))
ret
;-------------------------------------------------------------------------------
; su_effects_stereohelper: moves the workspace to next, does the filtering for
; right channel (pulling the calling address from stack), rewinds the
; workspace and returns
;-------------------------------------------------------------------------------
section .su_effects_stereohelper code align=1
su_effects_stereohelper:
jnc su_effects_stereohelper_mono ; carry is still the stereo bit
add ebp, 16
fxch ; r l
call [esp] ; call whoever called me...
fxch ; l r
sub ebp, 16 ; move WRK back to where it was
su_effects_stereohelper_mono:
ret ; return to process l/mono sound
section .su_clip code align=1
su_clip:
fld1 ; 1 x a
@ -824,9 +824,8 @@ su_vm_jumptable:
dd su_op_outaux
dd su_op_pan
dd su_op_delay
dd su_op_send
dd su_op_noise
dd su_op_filter
dd su_op_send
dd su_op_in
dd su_op_out
@ -843,9 +842,8 @@ su_vm_transformcounts:
db 2
db 1
db 4
db 2
db 1
db 2
db 2
db 0
db 1
@ -954,7 +952,7 @@ su_sample_offsets:
;-------------------------------------------------------------------------------
section .su_delay_times data align=1
su_delay_times:
dw 5230,4533,24054,48109,1116,1188,1276,1356,1422,1492,1556,1618,1140,1212,1300,1380,1446,1516,1580,1642
dw 5230,4533,22423,44847,1116,1188,1276,1356,1422,1492,1556,1618,1140,1212,1300,1380,1446,1516,1580,1642
;-------------------------------------------------------------------------------
@ -962,14 +960,14 @@ su_delay_times:
;-------------------------------------------------------------------------------
section .su_patch_opcodes data align=1
su_patch_opcodes:
db 2,4,4,6,8,2,4,4,10,6,8,13,0,2,4,4,6,8,14,17,13,0,3,5,9,17,13,2,4,8,18,0,2,4,8,2,20,8,22,22,6,14,13,0,2,4,8,14,13,0,25,17,27,0
db 2,4,4,6,8,2,4,4,10,6,8,13,0,2,4,4,6,8,14,17,13,0,3,5,9,17,19,13,2,4,8,20,0,2,4,8,14,13,0,2,4,8,14,13,0,23,17,25,0
;-------------------------------------------------------------------------------
; The parameters / inputs to each opcode
;-------------------------------------------------------------------------------
section .su_patch_operands data align=1
su_patch_operands:
db 57,82,62,63,107,91,65,0,0,67,41,129,79,63,0,1,65,62,129,57,87,50,64,100,91,54,0,0,64,64,129,79,62,0,1,64,78,129,18,19,31,70,0,66,76,77,31,0,2,64,128,130,89,48,0,2,64,97,130,75,28,128,59,86,0,1,20,32,25,64,88,64,112,62,64,0,3,64,47,129,84,128,37,18,2,1,56,53,91,0,92,89,82,82,64,0,128,64,128,72,80,41,0,0,68,0,0,54,76,52,0,4,81,53,128,0,68,0,0,53,2,39,128,67,68,110,116,64,59,77,56,0,43,89,50,103,79,42,0,5,72,128,128,64,72,0,2,33,128,123,14,4,15,90
db 64,82,64,64,128,91,65,0,0,67,41,130,79,63,0,1,65,62,129,64,87,64,64,98,91,54,0,0,64,85,129,79,62,0,1,64,128,129,0,41,31,70,0,66,66,77,31,0,2,64,128,130,89,48,0,2,64,97,130,41,28,128,59,86,0,1,36,43,25,64,80,64,108,62,64,0,3,64,101,128,84,128,37,18,2,1,64,128,72,72,51,91,0,92,89,92,82,64,0,128,64,128,72,87,41,0,13,82,0,0,79,72,52,0,4,81,81,129,64,30,25,0,43,89,50,103,79,42,0,5,72,128,128,64,50,29,2,30,128,120,14,4,15,70
;-------------------------------------------------------------------------------
; Constants
@ -982,7 +980,6 @@ FCONST_0_99609375 dd 0x3f7f0000
FCONST_3_80000em05 dd 0x381f6230
FCONST_9_269614em05 dd 0x38c265dc
FCONST_84_28075 dd 0x42a88fbe
ICONST_2147483648 dd 0x80000000
ICONST_1034594986 dd 0x3daaaaaa
ICONST_24 dd 0x18