Refactor all values to have a universal support for modulations.

The modulation is now always added during value transformation.
With this, a lot of *_MOD defines could be removed.
The waveform for some tests changed slightly, because when the
value is saved to memory after modulating it, there is some
rounding errors.
This commit is contained in:
Veikko Sariola 2020-05-01 16:56:30 +03:00
parent 0c08f3d41c
commit 53a1be9b61
35 changed files with 110 additions and 350 deletions

View File

@ -4,6 +4,11 @@
%define VAL esi ; // alias for unit values (transformed/untransformed)
%define COM ebx ; // alias for instrument opcodes
%macro TRANSFORM_VALUES 1
push go4k %+ %1 %+ _val.size/4
call go4kTransformValues
%endmacro
; if SINGLE_FILE is defined, then it means that the whole 4klang.asm will be included
; somewhere else where patterns, pattern_lists and synth_instructions are defined
; Otherwise, they are extern and linker should link them
@ -183,6 +188,7 @@ go4kTransformValues_loop:
push eax
fild dword [esp]
fmul dword [c_i128]
fadd dword [WRK+MAX_WORK_VARS*4+ecx*4]
fstp dword [edx+ecx*4]
pop eax
inc ecx
@ -198,11 +204,9 @@ SECT_TEXT(g4kcod4)
go4kENVMap:
fld dword [edx+eax*4]
%ifdef GO4K_USE_ENV_MOD_ADR
fadd dword [WRK+go4kENV_wrk.am+eax*4]
%endif
fimul dword [c_24]
fchs
; //----------------------------------------------------------------------------------------
; // Power function (2^x)
; //----------------------------------------------------------------------------------------
@ -233,8 +237,7 @@ EXPORT MANGLE_FUNC(Power,0) ; x
SECT_TEXT(g4kcoda)
EXPORT MANGLE_FUNC(go4kENV_func,0)
push 5
call go4kTransformValues
TRANSFORM_VALUES ENV
%ifdef GO4K_USE_ENV_CHECK
; check if current note still active
mov eax, dword [ecx-4]
@ -293,13 +296,7 @@ go4kENV_func_leave: ; // newval bla
fst dword [WRK+go4kENV_wrk.level]
go4kENV_func_leave2:
; // mul by gain
%ifdef GO4K_USE_ENV_MOD_GM
fld dword [edx+go4kENV_val.gain]
fadd dword [WRK+go4kENV_wrk.gm]
fmulp st1, st0
%else
fmul dword [edx+go4kENV_val.gain]
%endif
ret
; //----------------------------------------------------------------------------------------
@ -372,11 +369,11 @@ go4kVCO_gate:
jc go4kVCO_gate_bit
fsub st0, st0 ; // 0
go4kVCO_gate_bit:
fld dword [WRK+go4kVCO_wrk.cm] ; // f x
fld dword [WRK+go4kVCO_wrk.gatestate] ; // f x
fsub st1 ; // f-x x
fmul dword [c_dc_const] ; // c(f-x) x
faddp st1, st0 ; // x'
fst dword [WRK+go4kVCO_wrk.cm]
fst dword [WRK+go4kVCO_wrk.gatestate]
pop eax
ret
%endif
@ -384,36 +381,7 @@ go4kVCO_gate_bit:
SECT_TEXT(g4kcodb)
EXPORT MANGLE_FUNC(go4kVCO_func,0)
%ifdef GO4K_USE_VCO_PHASE_OFFSET
%ifdef GO4K_USE_VCO_SHAPE
%ifdef GO4K_USE_VCO_GATE
push 8
%else
push 7
%endif
%else
%ifdef GO4K_USE_VCO_GATE
push 7
%else
push 6
%endif
%endif
%else
%ifdef GO4K_USE_VCO_SHAPE
%ifdef GO4K_USE_VCO_GATE
push 7
%else
push 6
%endif
%else
%ifdef GO4K_USE_VCO_GATE
push 6
%else
push 5
%endif
%endif
%endif
call go4kTransformValues
TRANSFORM_VALUES VCO
%ifdef GO4K_USE_VCO_CHECK
; check if current note still active
mov eax, dword [ecx-4]
@ -443,9 +411,6 @@ go4kVCO_func_nopswap:
go4kVCO_func_process:
fld dword [edx+go4kVCO_val.transpose]
fsub dword [c_0_5]
%ifdef GO4K_USE_VCO_MOD_TM
fadd dword [WRK+go4kVCO_wrk.tm]
%endif
fdiv dword [c_i128]
fld dword [edx+go4kVCO_val.detune]
fsub dword [c_0_5]
@ -456,11 +421,10 @@ go4kVCO_func_process:
fchs ;// negate detune for stereo
go4kVCO_func_nodswap:
%endif
faddp st1
faddp st1
%ifdef GO4K_USE_VCO_MOD_DM
fadd dword [WRK+go4kVCO_wrk.dm]
fadd dword [WRK+go4kVCO_wrk.detune_mod]
%endif
; // st0 now contains the transpose+detune offset
test al, byte LFO
jnz go4kVCO_func_skipnote
fiadd dword [ecx-4] ; // st0 is note, st1 is t+d offset
@ -476,7 +440,7 @@ go4kVCO_func_normalize_note:
go4kVCO_func_normalized:
fadd dword [WRK+go4kVCO_wrk.phase]
%ifdef GO4K_USE_VCO_MOD_FM
fadd dword [WRK+go4kVCO_wrk.fm]
fadd dword [WRK+go4kVCO_wrk.freq_mod]
%endif
fld1
fadd st1, st0
@ -484,13 +448,8 @@ go4kVCO_func_normalized:
fprem
fstp st1
fst dword [WRK+go4kVCO_wrk.phase]
%ifdef GO4K_USE_VCO_MOD_PM
fadd dword [WRK+go4kVCO_wrk.pm]
%endif
%ifdef GO4K_USE_VCO_PHASE_OFFSET
fadd dword [edx+go4kVCO_val.phaseofs]
%endif
%ifdef PHASE_RENORMALIZE
fld1
fadd st1, st0
fxch
@ -498,9 +457,6 @@ go4kVCO_func_normalized:
fstp st1 ; // p
%endif
fld dword [edx+go4kVCO_val.color] ; // c p
%ifdef GO4K_USE_VCO_MOD_CM
fadd dword [WRK+go4kVCO_wrk.cm] ; // c p
%endif
go4kVCO_func_sine:
test al, byte SINE
jz short go4kVCO_func_trisaw
@ -532,15 +488,9 @@ go4kVCO_func_noise:
go4kVCO_func_end:
%ifdef GO4K_USE_VCO_SHAPE
fld dword [edx+go4kVCO_val.shape]
%ifdef GO4K_USE_VCO_MOD_SM
fadd dword [WRK+go4kVCO_wrk.sm]
%endif
call go4kWaveshaper
%endif
fld dword [edx+go4kVCO_val.gain]
%ifdef GO4K_USE_VCO_MOD_GM
fadd dword [WRK+go4kVCO_wrk.gm]
%endif
fmulp st1, st0
%ifdef GO4K_USE_VCO_STEREO
@ -568,8 +518,7 @@ go4kVCO_func_stereodone:
SECT_TEXT(g4kcodc)
EXPORT MANGLE_FUNC(go4kVCF_func,0)
push 3
call go4kTransformValues
TRANSFORM_VALUES VCF
%ifdef GO4K_USE_VCF_CHECK
; check if current note still active
mov eax, dword [ecx-4]
@ -581,15 +530,9 @@ go4kVCF_func_do:
movzx eax, byte [VAL-1] ; // get type flag
fld dword [edx+go4kVCF_val.res] ; // r in
%ifdef GO4K_USE_VCF_MOD_RM
fadd dword [WRK+go4kVCF_wrk.rm]
%endif
fstp dword [esp-8]
fld dword [edx+go4kVCF_val.freq] ; // f in
%ifdef GO4K_USE_VCF_MOD_FM
fadd dword [WRK+go4kVCF_wrk.fm]
%endif
fmul st0, st0 ; // square the input so we never get negative and also have a smoother behaviour in the lower frequencies
fstp dword [esp-4] ; // in
@ -664,20 +607,7 @@ SECT_TEXT(g4kcodd)
EXPORT MANGLE_FUNC(go4kDST_func,0)
%ifdef GO4K_USE_DST
%ifdef GO4K_USE_DST_SH
%ifdef GO4K_USE_DST_STEREO
push 3
%else
push 2
%endif
%else
%ifdef GO4K_USE_DST_STEREO
push 2
%else
push 1
%endif
%endif
call go4kTransformValues
TRANSFORM_VALUES DST
%ifdef GO4K_USE_DST_CHECK
; check if current note still active
mov eax, dword [ecx-4]
@ -689,9 +619,6 @@ go4kDST_func_do:
movzx eax, byte [VAL-1] ; // get type flag
%ifdef GO4K_USE_DST_SH
fld dword [edx+go4kDST_val.snhfreq] ; // snh in (inr)
%ifdef GO4K_USE_DST_MOD_SH
fadd dword [WRK+go4kDST_wrk.sm] ; // snh' in (inr)
%endif
fmul st0, st0 ; // square the input so we never get negative and also have a smoother behaviour in the lower frequencies
fchs
fadd dword [WRK+go4kDST_wrk.snhphase]; // snh' in (inr)
@ -710,9 +637,6 @@ go4kDST_func_do:
jz short go4kDST_func_mono
fxch st1 ; // inr inl
fld dword [edx+go4kDST_val.drive] ; // drive inr inl
%ifdef GO4K_USE_DST_MOD_DM
fadd dword [WRK+go4kDST_wrk.dm]
%endif
call go4kWaveshaper ; // outr inl
%ifdef GO4K_USE_DST_SH
fst dword [WRK+go4kDST_wrk.out2] ; // outr inl
@ -721,9 +645,6 @@ go4kDST_func_do:
go4kDST_func_mono:
%endif
fld dword [edx+go4kDST_val.drive] ; // drive in (outr)
%ifdef GO4K_USE_DST_MOD_DM
fadd dword [WRK+go4kDST_wrk.dm]
%endif
call go4kWaveshaper ; // out (outr)
%ifdef GO4K_USE_DST_SH
fst dword [WRK+go4kDST_wrk.out] ; // out' (outr)
@ -758,20 +679,7 @@ SECT_TEXT(g4kcodf)
EXPORT MANGLE_FUNC(go4kDLL_func,0)
%ifdef GO4K_USE_DLL
%ifdef GO4K_USE_DLL_CHORUS
%ifdef GO4K_USE_DLL_DAMP
push 8
%else
push 7
%endif
%else
%ifdef GO4K_USE_DLL_DAMP
push 6
%else
push 5
%endif
%endif
call go4kTransformValues
TRANSFORM_VALUES DLL
pushad
movzx ebx, byte [VAL-(go4kDLL_val.size-go4kDLL_val.delay)/4] ;// delay length index
%ifdef GO4K_USE_DLL_NOTE_SYNC
@ -787,35 +695,16 @@ EXPORT MANGLE_FUNC(go4kDLL_func,0)
%endif
go4kDLL_func_process:
mov ecx, eax ;// ecx is delay counter
%ifdef GO4K_USE_DLL_MOD
mov edi, WRK ;// edi is modulation workspace
%endif
mov WRK, dword [MANGLE_DATA(go4k_delay_buffer_ofs)] ;// ebp is current delay
fld st0 ;// in in
%ifdef GO4K_USE_DLL_MOD_IM
fld dword [edx+go4kDLL_val.dry] ;// dry in in
fadd dword [edi+go4kDLL_wrk2.im] ;// dry' in in
fmulp st1, st0 ;// out in
%else
fmul dword [edx+go4kDLL_val.dry] ;// out in
%endif
fxch ;// in out
%ifdef GO4K_USE_DLL_MOD_PM
fld dword [edx+go4kDLL_val.pregain] ;// pg in out
fadd dword [edi+go4kDLL_wrk2.pm] ;// pg' in out
fmul st0, st0 ;// pg'' in out
fmulp st1, st0 ;// in' out
%else
fmul dword [edx+go4kDLL_val.pregain] ;// in' out
fmul dword [edx+go4kDLL_val.pregain] ;// in' out
%endif
%ifdef GO4K_USE_DLL_CHORUS
;// update saw lfo for chorus/flanger
fld dword [edx+go4kDLL_val.freq] ;// f in' out
%ifdef GO4K_USE_DLL_MOD_SM
fadd dword [edi+go4kDLL_wrk2.sm] ;// f' in' out
%endif
fmul st0, st0
fmul st0, st0
fdiv dword [DLL_DEPTH]
@ -838,9 +727,6 @@ go4kDLL_func_process:
faddp st1, st0 ; // 1+sin in' out
;// mul with depth and convert to samples
fld dword [edx+go4kDLL_val.depth] ; // d 1+sin in' out
%ifdef GO4K_USE_DLL_MOD_AM
fadd dword [edi+go4kDLL_wrk2.am] ; // d' 1+sin in' out
%endif
fmul st0, st0
fmul st0, st0
fmul dword [DLL_DEPTH]
@ -872,25 +758,13 @@ go4kDLL_func_buffer_nowrap1:
%ifdef GO4K_USE_DLL_DAMP
fld1 ;// 1 cout in' out'
fsub dword [edx+go4kDLL_val.damp] ;// 1-damp cout in' out'
%ifdef GO4K_USE_DLL_MOD_DM
fsub dword [edi+go4kDLL_wrk2.dm] ;// 1-damp' cout in' out'
%endif
fmulp st1, st0 ;// cout*d2 in' out'
fld dword [edx+go4kDLL_val.damp] ;// d1 cout*d2 in' out'
%ifdef GO4K_USE_DLL_MOD_DM
fadd dword [edi+go4kDLL_wrk2.dm] ;// d1' cout*d2 in' out'
%endif
fmul dword [WRK+go4kDLL_wrk.store] ;// store*d1 cout*d2 in' out'
faddp st1, st0 ;// store' in' out'
fst dword [WRK+go4kDLL_wrk.store] ;// store' in' out'
%endif
%ifdef GO4K_USE_DLL_MOD_FM
fld dword [edx+go4kDLL_val.feedback] ;// fb cout in' out'
fadd dword [edi+go4kDLL_wrk2.fm] ;// fb' cout in' out'
fmulp st1, st0 ;// cout*fb' in' out'
%else
fmul dword [edx+go4kDLL_val.feedback] ;// cout*fb in' out'
%endif
%ifdef GO4K_USE_DLL_DC_FILTER
fadd st0, st1 ;// store in' out'
fstp dword [WRK+eax*4+go4kDLL_wrk.buffer];// in' out'
@ -949,8 +823,7 @@ SECT_TEXT(g4kcodu)
EXPORT MANGLE_FUNC(go4kGLITCH_func,0)
%ifdef GO4K_USE_GLITCH
push 5
call go4kTransformValues
TRANSFORM_VALUES GLITCH
pushad
mov edi, WRK
@ -962,7 +835,6 @@ EXPORT MANGLE_FUNC(go4kGLITCH_func,0)
; je go4kGLITCH_func_notactive ;// out
fld dword [edx+go4kGLITCH_val.active] ;// a in
fadd dword [edi+go4kGLITCH_wrk2.am] ;// a' in
; // check for activity
fldz ;// 0 a' in
fucomip st1 ;// a' in
@ -1017,7 +889,6 @@ go4kGLITCH_func_filldone:
mov dword [WRK+go4kGLITCH_wrk.index], eax
fld dword [edx+go4kGLITCH_val.dsize]
fadd dword [edi+go4kGLITCH_wrk2.sm]
fsub dword [c_0_5]
fmul dword [c_0_5]
call MANGLE_FUNC(Power,0)
@ -1025,7 +896,6 @@ go4kGLITCH_func_filldone:
fstp dword [WRK+go4kGLITCH_wrk.slizesize]
fld dword [edx+go4kGLITCH_val.dpitch]
fadd dword [edi+go4kGLITCH_wrk2.pm]
fsub dword [c_0_5]
fmul dword [c_0_5]
call MANGLE_FUNC(Power,0)
@ -1035,7 +905,6 @@ go4kGLITCH_func_process_done:
;// dry wet mix
fld dword [edx+go4kGLITCH_val.dry] ;// dry out
fadd dword [edi+go4kGLITCH_wrk2.dm] ;// dry' out
fld1 ;// 1 dry' out
fsub st1 ;// 1-dry' dry' out
fmulp st2 ;// dry' out'
@ -1067,8 +936,7 @@ go4kGLITCH_func_leave:
SECT_TEXT(g4kcodg)
EXPORT MANGLE_FUNC(go4kFOP_func,0)
push 1
call go4kTransformValues
TRANSFORM_VALUES FOP
go4kFOP_func_pop:
dec eax
jnz go4kFOP_func_addp
@ -1133,8 +1001,7 @@ go4kFOP_func_mulp2:
SECT_TEXT(g4kcodh)
EXPORT MANGLE_FUNC(go4kFST_func,0)
push 1
call go4kTransformValues
TRANSFORM_VALUES FST
fld dword [edx+go4kFST_val.amount]
fsub dword [c_0_5]
fadd st0
@ -1165,14 +1032,10 @@ SECT_TEXT(g4kcodm)
EXPORT MANGLE_FUNC(go4kFLD_func,0) ;// in main env
%ifdef GO4K_USE_FLD
push 1
call go4kTransformValues
TRANSFORM_VALUES FLD
fld dword [edx+go4kFLD_val.value] ;// value in
fsub dword [c_0_5]
fadd st0
%ifdef GO4K_USE_FLD_MOD_VM
fadd dword [WRK+go4kFLD_wrk.vm] ;// value' in
%endif
%endif
ret
@ -1190,8 +1053,7 @@ EXPORT MANGLE_FUNC(go4kFLD_func,0) ;// in main env
SECT_TEXT(g4kcodi)
EXPORT MANGLE_FUNC(go4kFSTG_func,0)
push 1
call go4kTransformValues
TRANSFORM_VALUES FSTG
%ifdef GO4K_USE_FSTG_CHECK
; check if current note still active
mov eax, dword [ecx-4]
@ -1238,12 +1100,8 @@ SECT_TEXT(g4kcodj)
EXPORT MANGLE_FUNC(go4kPAN_func,0) ;// in main env
%ifdef GO4K_USE_PAN
push 1
call go4kTransformValues
TRANSFORM_VALUES PAN
fld dword [edx+go4kPAN_val.panning] ;// pan in
%ifdef GO4K_USE_PAN_MOD
fadd dword [WRK+go4kPAN_wrk.pm] ;// pan in
%endif
fmul st1 ;// r in
fsub st1, st0 ;// r l
fxch ;// l r
@ -1265,56 +1123,34 @@ EXPORT MANGLE_FUNC(go4kPAN_func,0) ;// in main env
SECT_TEXT(g4kcodk)
EXPORT MANGLE_FUNC(go4kOUT_func,0) ;// l r
TRANSFORM_VALUES OUT
%ifdef GO4K_USE_GLOBAL_DLL
push 2
call go4kTransformValues
pushad
lea edi, [ecx+MAX_UNITS*MAX_UNIT_SLOTS*4]
fld st1 ;// r l r
fld st1 ;// l r l r
fld dword [edx+go4kOUT_val.auxsend] ;// as l r l r
%ifdef GO4K_USE_OUT_MOD_AM
fadd dword [WRK+go4kOUT_wrk.am] ;// am l r l r
%endif
fmulp st1, st0 ;// l' r l r
fstp dword [edi] ;// r l r
scasd
fld dword [edx+go4kOUT_val.auxsend] ;// as r l r
%ifdef GO4K_USE_OUT_MOD_AM
fadd dword [WRK+go4kOUT_wrk.am] ;// am r l r
%endif
fmulp st1, st0 ;// r' l r
fstp dword [edi] ;// l r
scasd
fld dword [edx+go4kOUT_val.gain] ;// g l r
%ifdef GO4K_USE_OUT_MOD_GM
fadd dword [WRK+go4kOUT_wrk.gm] ;// gm l r
%endif
fmulp st1, st0 ;// l' r
fstp dword [edi] ;// r
scasd
fld dword [edx+go4kOUT_val.gain] ;// g r
%ifdef GO4K_USE_OUT_MOD_GM
fadd dword [WRK+go4kOUT_wrk.gm] ;// gm r
%endif
fmulp st1, st0 ;// r'
fstp dword [edi] ;// -
scasd
popad
%else
push 1
call go4kTransformValues
fld dword [edx+go4kOUT_val.gain] ;// g l r
%ifdef GO4K_USE_OUT_MOD_GM
fadd dword [WRK+go4kOUT_wrk.gm] ;// gm l r
%endif
fmulp st1, st0 ;// l' r
fstp dword [ecx+MAX_UNITS*MAX_UNIT_SLOTS*4+8] ;// r
fld dword [edx+go4kOUT_val.gain] ;// g r
%ifdef GO4K_USE_OUT_MOD_GM
fadd dword [WRK+go4kOUT_wrk.gm] ;// gm r
%endif
fmulp st1, st0 ;// r'
fstp dword [ecx+MAX_UNITS*MAX_UNIT_SLOTS*4+12] ;// -
@ -1333,8 +1169,7 @@ EXPORT MANGLE_FUNC(go4kOUT_func,0) ;// l r
SECT_TEXT(g4kcodl)
EXPORT MANGLE_FUNC(go4kACC_func,0)
push 1
call go4kTransformValues
TRANSFORM_VALUES ACC
pushad
mov edi, go4k_synth_wrk
add edi, go4k_instrument.size

View File

@ -80,34 +80,22 @@
%define GO4K_USE_GLOBAL_DLL ; // removing this will skip global dll processing
%define GO4K_USE_FSTG ; // removing this will skip global store unit
%define GO4K_USE_FLD ; // removing this will skip float load unit
%define GO4K_USE_FLD_MOD_VM ; // removing this will skip float load modulation code
%define GO4K_USE_GLITCH ; // removing this will skip GLITCH unit
%define GO4K_USE_ENV_CHECK ; // removing this skips checks if processing is needed
%define GO4K_USE_ENV_MOD_GM ; // removing this will skip env gain modulation code
%define GO4K_USE_ENV_MOD_ADR ; // removing this will skip env attack/decay/release modulation code
%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed
%define GO4K_USE_VCO_PHASE_OFFSET ; // removing this will skip initial phase offset code
%define GO4K_USE_VCO_SHAPE ; // removing this skips waveshaping code
%define GO4K_USE_VCO_GATE ; // removing this skips gate code
%define GO4K_USE_VCO_MOD_FM ; // removing this skips frequency modulation code
%define GO4K_USE_VCO_MOD_PM ; // removing this skips phase modulation code
%define GO4K_USE_VCO_MOD_TM ; // removing this skips transpose modulation code
%define GO4K_USE_VCO_MOD_DM ; // removing this skips detune modulation code
%define GO4K_USE_VCO_MOD_CM ; // removing this skips color modulation code
%define GO4K_USE_VCO_MOD_GM ; // removing this skips gain modulation code
%define GO4K_USE_VCO_MOD_SM ; // removing this skips shaping modulation code
%define GO4K_USE_VCO_STEREO ; // removing this skips stereo code
%define GO4K_USE_VCF_CHECK ; // removing this skips checks if processing is needed
%define GO4K_USE_VCF_MOD_FM ; // removing this skips frequency modulation code
%define GO4K_USE_VCF_MOD_RM ; // removing this skips resonance modulation code
%define GO4K_USE_VCF_HIGH ; // removing this skips code for high output
%define GO4K_USE_VCF_BAND ; // removing this skips code for band output
%define GO4K_USE_VCF_PEAK ; // removing this skips code for peak output
%define GO4K_USE_VCF_STEREO ; // removing this skips code for stereo filter output
%define GO4K_USE_DST_CHECK ; // removing this skips checks if processing is needed
%define GO4K_USE_DST_SH ; // removing this skips sample and hold code
%define GO4K_USE_DST_MOD_DM ; // removing this skips distortion modulation code
%define GO4K_USE_DST_MOD_SH ; // removing this skips sample and hold modulation code
%define GO4K_USE_DST_STEREO ; // removing this skips stereo processing
%define GO4K_USE_DLL_NOTE_SYNC ; // removing this will skip delay length adjusting code (karplus strong)
%define GO4K_USE_DLL_CHORUS ; // removing this will skip delay chorus/flanger code
@ -115,17 +103,7 @@
%define GO4K_USE_DLL_DAMP ; // removing this will skip dll damping code
%define GO4K_USE_DLL_DC_FILTER ; // removing this will skip dll dc offset removal code
%define GO4K_USE_FSTG_CHECK ; // removing this skips checks if processing is needed
%define GO4K_USE_PAN_MOD ; // removing this will skip panning modulation code
%define GO4K_USE_OUT_MOD_AM ; // removing this skips output aux send modulation code
%define GO4K_USE_OUT_MOD_GM ; // removing this skips output gain modulation code
%define GO4K_USE_WAVESHAPER_CLIP ; // removing this will skip clipping code
%define GO4K_USE_DLL_MOD ; // define this to enable modulations for delay line
%define GO4K_USE_DLL_MOD_PM ; // define this to enable pregain modulation for delay line
%define GO4K_USE_DLL_MOD_FM ; // define this to enable feebback modulation for delay line
%define GO4K_USE_DLL_MOD_IM ; // define this to enable dry modulation for delay line
%define GO4K_USE_DLL_MOD_DM ; // define this to enable damping modulation for delay line
%define GO4K_USE_DLL_MOD_SM ; // define this to enable lfo freq modulation for delay line
%define GO4K_USE_DLL_MOD_AM ; // define this to enable lfo depth modulation for delay line
%endif
%ifdef GO4K_USE_VCO_SHAPE
@ -135,13 +113,6 @@
%define INCLUDE_WAVESHAPER
%endif
%ifdef GO4K_USE_VCO_MOD_PM
%define PHASE_RENORMALIZE
%endif
%ifdef GO4K_USE_VCO_PHASE_OFFSET
%define PHASE_RENORMALIZE
%endif
%ifdef GO4K_USE_ENVELOPE_RECORDINGS
%define GO4K_USE_BUFFER_RECORDINGS
%endif
@ -156,6 +127,7 @@
%define MAX_DELAY 65536
%define MAX_UNITS 64
%define MAX_UNIT_SLOTS 16
%define MAX_WORK_VARS 8
%ifndef SAMPLE_RATE
%define SAMPLE_RATE 44100
@ -213,12 +185,6 @@ struc go4kENV_wrk
;// work variables
.state resd 1
.level resd 1
;// modulation targets
.gm resd 1
.am resd 1
.dm resd 1
.sm resd 1
.rm resd 1
.size
endstruc
%define ENV_STATE_ATTAC 0
@ -243,7 +209,6 @@ GO4K_VCO_ID equ 2
db %5
%ifdef GO4K_USE_VCO_SHAPE
db %6
%else
%endif
db %7
db %8
@ -283,16 +248,11 @@ endstruc
struc go4kVCO_wrk
;// work variables
.phase resd 1
;// modulation targets
.tm resd 1
.dm resd 1
.fm resd 1
.pm resd 1
.cm resd 1
.sm resd 1
.gm resd 1
;// stero variables
.phase2 resd 1
.gatestate resd 1
.detune_mod resd 1
.freq_mod resd 1
.size
endstruc
; //----------------------------------------------------------------------------------------
@ -326,10 +286,7 @@ struc go4kVCF_wrk
.low resd 1
.high resd 1
.band resd 1
.freq resd 1 ;// unused but kept so modulation target offsets stay same
;// modulation targets
.fm resd 1
.rm resd 1
.freq_mod resd 1
;// stereo variables
.low2 resd 1
.high2 resd 1
@ -344,13 +301,9 @@ GO4K_DST_ID equ 4
db %1
%ifdef GO4K_USE_DST_SH
db %2
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%else
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%endif
%ifdef GO4K_USE_DST_STEREO
db %3
%endif
%endmacro
%define DRIVE(val) val
@ -361,17 +314,16 @@ struc go4kDST_val
.drive resd 1
%ifdef GO4K_USE_DST_SH
.snhfreq resd 1
%endif
%endif
%ifdef GO4K_USE_DST_STEREO
.flags resd 1
%endif
.size
endstruc
struc go4kDST_wrk
;// work variables
.out resd 1
.snhphase resd 1
;// modulation targets
.dm resd 1
.sm resd 1
;// stereo variables
.out2 resd 1
.size
@ -411,7 +363,7 @@ struc go4kDLL_val
%endif
%ifdef GO4K_USE_DLL_CHORUS
.freq resd 1
.depth
.depth resd 1
%endif
.delay resd 1
.count resd 1
@ -428,16 +380,6 @@ struc go4kDLL_wrk
.buffer resd MAX_DELAY
.size
endstruc
struc go4kDLL_wrk2
;// modulation targets
.pm resd 1
.fm resd 1
.im resd 1
.dm resd 1
.sm resd 1
.am resd 1
.size
endstruc
; //----------------------------------------------------------------------------------------
; // FOP structs
; //----------------------------------------------------------------------------------------
@ -472,13 +414,13 @@ GO4K_FST_ID equ 7
dw %2
%endmacro
%define AMOUNT(val) val
%define DEST(val) val
%define VALUE_MOD(unit,unittype,slot,flags) unit*MAX_UNIT_SLOTS+go4k %+ unittype %+ _val. %+ slot /4+MAX_WORK_VARS+flags
%define WRK_MOD(unit,unittype,slot,flags) unit*MAX_UNIT_SLOTS+go4k %+ unittype %+ _wrk. %+ slot /4+flags
%define FST_SET 0x0000
%define FST_ADD 0x4000
%define FST_POP 0x8000
struc go4kFST_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFST_wrk
@ -501,8 +443,6 @@ struc go4kPAN_val
.size
endstruc
struc go4kPAN_wrk
;// modulation targets
.pm resd 1
.size
endstruc
; //----------------------------------------------------------------------------------------
@ -524,9 +464,6 @@ struc go4kOUT_val
.size
endstruc
struc go4kOUT_wrk
;// modulation targets
.am resd 1
.gm resd 1
.size
endstruc
; //----------------------------------------------------------------------------------------
@ -560,8 +497,6 @@ struc go4kFLD_val
.size
endstruc
struc go4kFLD_wrk
;// modulation targets
.vm resd 1
.size
endstruc
%endif
@ -601,14 +536,6 @@ struc go4kGLITCH_wrk
.buffer resd MAX_DELAY
.size
endstruc
struc go4kGLITCH_wrk2
;// modulation targets
.am resd 1
.dm resd 1
.sm resd 1
.pm resd 1
.size
endstruc
%endif
%ifdef GO4K_USE_FSTG
; //----------------------------------------------------------------------------------------
@ -623,9 +550,11 @@ GO4K_FSTG_ID equ 12
db %1
dw %2
%endmacro
%define GLOBAL_VALUE_MOD(inst,unit,unittype,slot,flags) inst*go4k_instrument.size*MAX_VOICES/4 + unit*MAX_UNIT_SLOTS+go4k %+ unittype %+ _val. %+ slot /4+(go4k_instrument.workspace/4)+MAX_WORK_VARS+flags
%define GLOBAL_WRK_MOD(inst,unit,unittype,slot,flags) inst*go4k_instrument.size*MAX_VOICES/4 + unit*MAX_UNIT_SLOTS+go4k %+ unittype %+ _wrk. %+ slot /4+(go4k_instrument.workspace/4)+flags
struc go4kFSTG_val
.amount resd 1
.op1 resd 1
.size
endstruc
struc go4kFSTG_wrk

View File

@ -286,12 +286,12 @@ SECT_DATA(g4kmuc4)
EXPORT MANGLE_DATA(go4k_synth_parameter_values)
GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(72),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
GO4K_FST AMOUNT(64),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(64),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(32),GATES(0),COLOR(80),SHAPE(64),GAIN(128),FLAGS(PULSE)
GO4K_VCO TRANSPOSE(64),DETUNE(72),PHASE(32),GATES(0),COLOR(96),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(32),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(96),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2)
GO4K_FST AMOUNT(61),DEST(3*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
; GO4K_FST AMOUNT(61),DEST(3*MAX_UNIT_SLOTS+2); TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_MULP)
@ -307,12 +307,12 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument1)
GO4K_ENV ATTAC(72),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
GO4K_FST AMOUNT(64),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(64),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(32),GATES(0),COLOR(80),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(64),DETUNE(72),PHASE(32),GATES(0),COLOR(96),SHAPE(112),GAIN(64),FLAGS(SINE)
GO4K_VCO TRANSPOSE(80),DETUNE(112),PHASE(0),GATES(0),COLOR(64),SHAPE(16),GAIN(128),FLAGS(PULSE|LFO)
GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2)
GO4K_FST AMOUNT(60),DEST(3*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
; GO4K_FST AMOUNT(60),DEST(3*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_MULP)
@ -328,12 +328,12 @@ GO4K_BEGIN_PARAMDEF(Instrument1)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument2)
GO4K_ENV ATTAC(32),DECAY(64),SUSTAIN(64),RELEASE(64),GAIN(64)
GO4K_FST AMOUNT(120),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(120),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(32),GATES(0),COLOR(80),SHAPE(64),GAIN(128),FLAGS(PULSE)
GO4K_VCO TRANSPOSE(64),DETUNE(72),PHASE(32),GATES(0),COLOR(96),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_VCO TRANSPOSE(32),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(96),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2)
GO4K_FST AMOUNT(60),DEST(3*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(68),DEST(2*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
; GO4K_FST AMOUNT(60),DEST(3*MAX_UNIT_SLOTS+2); TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_FOP OP(FOP_ADDP)
GO4K_FOP OP(FOP_MULP)
@ -349,7 +349,7 @@ GO4K_BEGIN_PARAMDEF(Instrument2)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument3)
GO4K_ENV ATTAC(0),DECAY(76),SUSTAIN(0),RELEASE(0),GAIN(32)
GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(64),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(NOISE)
GO4K_FOP OP(FOP_MULP)
GO4K_VCF FREQUENCY(80),RESONANCE(128),VCFTYPE(LOWPASS)
@ -358,10 +358,10 @@ GO4K_BEGIN_PARAMDEF(Instrument3)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument4)
GO4K_ENV ATTAC(0),DECAY(64),SUSTAIN(96),RELEASE(64),GAIN(128)
GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_ENV ATTAC(0),DECAY(70),SUSTAIN(0),RELEASE(0),GAIN(128)
GO4K_DST DRIVE(32), SNHFREQ(128), FLAGS(0)
GO4K_FST AMOUNT(80),DEST(6*MAX_UNIT_SLOTS+1)
; GO4K_FST AMOUNT(80),DEST(6*MAX_UNIT_SLOTS+1) ; TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(46),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(TRISAW)
GO4K_FOP OP(FOP_MULP)
@ -382,10 +382,10 @@ GO4K_BEGIN_PARAMDEF(Instrument5)
GO4K_END_PARAMDEF
GO4K_BEGIN_PARAMDEF(Instrument6)
GO4K_ENV ATTAC(0),DECAY(72),SUSTAIN(0),RELEASE(72),GAIN(128)
GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2)
; GO4K_FST AMOUNT(128),DEST(0*MAX_UNIT_SLOTS+2) ; TODO: convert into new DEST format
GO4K_ENV ATTAC(0),DECAY(56),SUSTAIN(0),RELEASE(0),GAIN(128)
GO4K_FST AMOUNT(108),DEST(6*MAX_UNIT_SLOTS+1)
GO4K_FST AMOUNT(72),DEST(7*MAX_UNIT_SLOTS+1)
; GO4K_FST AMOUNT(108),DEST(6*MAX_UNIT_SLOTS+1) ; TODO: convert into new DEST format
; GO4K_FST AMOUNT(72),DEST(7*MAX_UNIT_SLOTS+1) ; TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_VCO TRANSPOSE(32),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(32),GAIN(64),FLAGS(SINE)
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(80),GAIN(64),FLAGS(SINE)
@ -413,8 +413,8 @@ GO4K_BEGIN_PARAMDEF(Instrument8)
GO4K_ENV ATTAC(0),DECAY(0),SUSTAIN(128),RELEASE(0),GAIN(128)
GO4K_VCO TRANSPOSE(48),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(TRISAW|LFO)
GO4K_FOP OP(FOP_MULP)
GO4K_FSTG AMOUNT(72),DEST(2*go4k_instrument.size*MAX_VOICES+10*MAX_UNIT_SLOTS*4+4*4+go4k_instrument.workspace)
GO4K_FSTG AMOUNT(66),DEST(1*go4k_instrument.size*MAX_VOICES+10*MAX_UNIT_SLOTS*4+4*4+go4k_instrument.workspace)
; GO4K_FSTG AMOUNT(72),DEST(2*go4k_instrument.size*MAX_VOICES+10*MAX_UNIT_SLOTS*4+4*4+go4k_instrument.workspace) ; TODO: convert into new DEST format
; GO4K_FSTG AMOUNT(66),DEST(1*go4k_instrument.size*MAX_VOICES+10*MAX_UNIT_SLOTS*4+4*4+go4k_instrument.workspace) ; TODO: convert into new DEST format
GO4K_FOP OP(FOP_POP)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -7,9 +7,7 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_AM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
@ -69,7 +67,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 5 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,depth,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -7,9 +7,7 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_DM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
@ -69,7 +67,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 3 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,damp,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -5,9 +5,7 @@
%define USE_SECTIONS
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_FM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
@ -67,7 +65,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 1 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,feedback,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -7,9 +7,7 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_IM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
@ -69,7 +67,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 2 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,dry,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -7,9 +7,7 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_PM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_CLIP_OUTPUT ; the original expected data was clipping, and this was on
@ -68,7 +66,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 0 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,pregain,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -7,9 +7,7 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_DLL
%define GO4K_USE_DLL_MOD
%define GO4K_USE_DLL_DAMP
%define GO4K_USE_DLL_MOD_SM
%define GO4K_USE_DLL_DC_FILTER
%define GO4K_USE_DLL_CHORUS
%define GO4K_USE_DLL_CHORUS_CLAMP
@ -69,7 +67,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 4 + FST_POP) ; modulate
GO4K_FST AMOUNT(32),VALUE_MOD(3,DLL,freq,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -4,7 +4,6 @@
%define SINGLE_FILE
%define USE_SECTIONS
%define GO4K_USE_DST
%define GO4K_USE_DST_MOD_DM
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
@ -60,8 +59,8 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128)
GO4K_DST DRIVE(96), SNHFREQ(128), FLAGS(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 2)
GO4K_FST AMOUNT(68),DEST(3*MAX_UNIT_SLOTS + 2 + FST_POP)
GO4K_FST AMOUNT(68),VALUE_MOD(1,DST,drive,0)
GO4K_FST AMOUNT(68),VALUE_MOD(3,DST,drive,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -5,7 +5,6 @@
%define USE_SECTIONS
%define GO4K_USE_DST
%define GO4K_USE_DST_SH
%define GO4K_USE_DST_MOD_SH
%define GO4K_USE_DST_CHECK
%define GO4K_USE_FST
%define GO4K_USE_VCO_PHASE_OFFSET
@ -62,8 +61,8 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128)
GO4K_DST DRIVE(64), SNHFREQ(3), FLAGS(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 3)
GO4K_FST AMOUNT(68),DEST(3*MAX_UNIT_SLOTS + 3 + FST_POP)
GO4K_FST AMOUNT(68),VALUE_MOD(1,DST,snhfreq,0)
GO4K_FST AMOUNT(68),VALUE_MOD(3,DST,snhfreq,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -5,8 +5,6 @@
%define USE_SECTIONS
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_FST
%define GO4K_USE_ENV_MOD_GM
%define GO4K_USE_ENV_MOD_ADR
%define GO4K_USE_ENV_CHECK ; // removing this skips checks if processing is needed
%include "../src/4klang.asm"
@ -59,11 +57,11 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128)
GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128)
GO4K_VCO TRANSPOSE(120),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(96),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(0*MAX_UNIT_SLOTS + 3) ; modulate attack
GO4K_FST AMOUNT(68),DEST(0*MAX_UNIT_SLOTS + 4) ; modulate decay
GO4K_FST AMOUNT(68),VALUE_MOD(0,ENV,attac,0)
GO4K_FST AMOUNT(68),VALUE_MOD(0,ENV,decay,0)
; Sustain modulation seems not to be implemented
GO4K_FST AMOUNT(68),DEST(0*MAX_UNIT_SLOTS + 6) ; modulate release
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 2 + FST_POP) ; modulate gain
GO4K_FST AMOUNT(68),VALUE_MOD(0,ENV,release,0)
GO4K_FST AMOUNT(68),VALUE_MOD(1,ENV,gain,FST_POP)
GO4K_OUT GAIN(110), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -55,8 +55,8 @@ SECT_DATA(g4kmuc4)
EXPORT MANGLE_DATA(go4k_synth_parameter_values)
GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FLD VALUE(128)
GO4K_FSTG AMOUNT(96),DEST((1*go4k_instrument.size*MAX_VOICES/4)+(3*MAX_UNIT_SLOTS+0)+(go4k_instrument.workspace/4)+FST_SET+FST_POP)
GO4K_FLD VALUE(96)
GO4K_FSTG AMOUNT(96),GLOBAL_VALUE_MOD(1,3,FLD,value,FST_SET+FST_POP)
GO4K_FLD VALUE(64)
GO4K_FLD VALUE(64)
GO4K_OUT GAIN(128), AUXSEND(0)
@ -64,8 +64,8 @@ GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)
GO4K_ACC ACCTYPE(OUTPUT)
GO4K_FLD VALUE(0)
GO4K_FSTG AMOUNT(96),DEST((0*go4k_instrument.size*MAX_VOICES/4)+(2*MAX_UNIT_SLOTS+0)+(go4k_instrument.workspace/4)+FST_SET+FST_POP)
GO4K_FLD VALUE(32)
GO4K_FSTG AMOUNT(96),GLOBAL_VALUE_MOD(0,2,FLD,value,FST_SET+FST_POP)
GO4K_FLD VALUE(64)
GO4K_FOP OP(FOP_ADDP)
GO4K_OUT GAIN(128), AUXSEND(0)

View File

@ -10,6 +10,8 @@
#include <sys/stat.h>
#endif
#include <math.h>
extern void __stdcall _4klang_render();
@ -25,6 +27,8 @@ int main(int argc, char* argv[]) {
char actual_output_folder[] = "actual_output/";
long fsize;
long bufsize;
boolean small_difference;
double diff;
#ifndef GO4K_USE_16BIT_OUTPUT
float* buf = NULL;
float* filebuf = NULL;
@ -82,11 +86,26 @@ int main(int argc, char* argv[]) {
fread((void*)filebuf, test_max_samples * 2, sizeof(*filebuf), f);
small_difference = FALSE;
for (n = 0; n < test_max_samples * 2; n++) {
if (buf[n] != filebuf[n]) {
diff = (double)(buf[n]) - (double)(filebuf[n]);
#ifdef GO4K_USE_16BIT_OUTPUT
diff = diff / 32768.0f;
#endif
diff = fabs(diff);
if (diff > 1e-4f) {
printf("4klang rendered different wave than expected\n");
goto fail;
}
else if (diff > 0.0f) {
small_difference = TRUE;
}
}
if (small_difference) {
printf("4klang rendered almost correct wave, but with small errors (< 1e-4)\n");
goto fail;
}
success:

View File

@ -54,11 +54,11 @@ SECT_DATA(g4kmuc4)
EXPORT MANGLE_DATA(go4k_synth_parameter_values)
GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FLD VALUE(0)
GO4K_FST AMOUNT(96),DEST(5*MAX_UNIT_SLOTS + 0)
GO4K_FST AMOUNT(96),DEST(6*MAX_UNIT_SLOTS + 0 + FST_POP)
GO4K_FLD VALUE(32)
GO4K_FST AMOUNT(96),VALUE_MOD(5,FLD,value,0)
GO4K_FST AMOUNT(96),VALUE_MOD(6,FLD,value,FST_POP)
GO4K_FLD VALUE(128)
GO4K_FST AMOUNT(128),DEST(6*MAX_UNIT_SLOTS + 0 + FST_ADD + FST_POP)
GO4K_FST AMOUNT(96),VALUE_MOD(6,FLD,value,FST_ADD + FST_POP)
GO4K_FLD VALUE(64)
GO4K_FLD VALUE(64)
GO4K_OUT GAIN(128), AUXSEND(0)

View File

@ -7,7 +7,6 @@
%define GO4K_USE_PAN
%define GO4K_USE_VCF_BAND
%define GO4K_USE_VCF_CHECK
%define GO4K_USE_VCF_MOD_FM
%define GO4K_USE_VCO_PHASE_OFFSET ; // removing this will skip initial phase offset code
%include "../src/4klang.asm"
@ -64,7 +63,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 4 + FST_POP) ; modulate detune
GO4K_FST AMOUNT(32),VALUE_MOD(3,VCF,freq,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -7,7 +7,6 @@
%define GO4K_USE_PAN
%define GO4K_USE_VCF_BAND
%define GO4K_USE_VCF_CHECK
%define GO4K_USE_VCF_MOD_RM
%define GO4K_USE_VCO_PHASE_OFFSET ; // removing this will skip initial phase offset code
%include "../src/4klang.asm"
@ -64,7 +63,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_PAN PANNING(64)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(32),DEST(3*MAX_UNIT_SLOTS + 5 + FST_POP) ; modulate detune
GO4K_FST AMOUNT(32),VALUE_MOD(3,VCF,res,FST_POP)
GO4K_END_PARAMDEF
;// global parameters
GO4K_BEGIN_PARAMDEF(Global)

View File

@ -6,7 +6,6 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_MOD_CM
%include "../src/4klang.asm"
@ -59,7 +58,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 5 + FST_POP) ; modulate color
GO4K_FST AMOUNT(68),VALUE_MOD(1,VCO,color,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -59,7 +59,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(128),DEST(1*MAX_UNIT_SLOTS + 2 + FST_POP) ; modulate detune
GO4K_FST AMOUNT(128),WRK_MOD(1,VCO,detune_mod,FST_POP) ; modulate detune
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -59,7 +59,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 3 + FST_POP) ; modulate fm
GO4K_FST AMOUNT(68),WRK_MOD(1,VCO,freq_mod,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -6,7 +6,6 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_MOD_GM
%define GO4K_CLIP_OUTPUT ; the original expected data was clipping, and this was on
%include "../src/4klang.asm"
@ -60,7 +59,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 7 + FST_POP) ; modulate gm
GO4K_FST AMOUNT(68),VALUE_MOD(1,VCO,gain,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -6,7 +6,6 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_MOD_PM
%include "../src/4klang.asm"
@ -59,7 +58,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(128),DEST(1*MAX_UNIT_SLOTS + 4 + FST_POP) ; modulate phase
GO4K_FST AMOUNT(128),VALUE_MOD(1,VCO,phaseofs,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -6,7 +6,6 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_MOD_SM
%include "../src/4klang.asm"
@ -59,7 +58,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 6 + FST_POP) ; modulate sm
GO4K_FST AMOUNT(68),VALUE_MOD(1,VCO,shape,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters

View File

@ -6,7 +6,6 @@
%define GO4K_USE_FST
%define GO4K_USE_VCO_SHAPE
%define GO4K_USE_VCO_PHASE_OFFSET
%define GO4K_USE_VCO_MOD_TM
%include "../src/4klang.asm"
@ -59,7 +58,7 @@ GO4K_BEGIN_PARAMDEF(Instrument0)
GO4K_FOP OP(FOP_MULP)
GO4K_FOP OP(FOP_PUSH)
GO4K_VCO TRANSPOSE(70),DETUNE(64),PHASE(64),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 1 + FST_POP) ; modulate transpose
GO4K_FST AMOUNT(68),VALUE_MOD(1,VCO,transpose,FST_POP)
GO4K_OUT GAIN(128), AUXSEND(0)
GO4K_END_PARAMDEF
;// global parameters