diff --git a/src/4klang.asm b/src/4klang.asm new file mode 100644 index 0000000..cc1f064 --- /dev/null +++ b/src/4klang.asm @@ -0,0 +1,1652 @@ +%include "4klang.inc" + +%define WRK ebp ; // alias for unit workspace +%define VAL esi ; // alias for unit values (transformed/untransformed) +%define COM ebx ; // alias for instrument opcodes + +; 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 +%ifndef SINGLE_FILE + extern MANGLE_DATA(go4k_patterns) + extern MANGLE_DATA(go4k_pattern_lists) + extern MANGLE_DATA(go4k_synth_instructions) + + %ifdef GO4K_USE_DLL + ; delay times should also come from the song, but only if the delay is used. + extern MANGLE_DATA(go4k_delay_times) + %endif +%endif SINGLE_FILE + +; //======================================================================================== +; // .bss section +; //======================================================================================== +SECT_BSS(g4kbss1) + +; // the one and only synth object +%if MAX_VOICES > 1 +go4k_voiceindex resd 16 +%endif +go4k_transformed_values resd 16 +go4k_synth_wrk resb go4k_synth.size +EXPORT MANGLE_DATA(go4k_delay_buffer_ofs) + resd 1 +EXPORT MANGLE_DATA(go4k_delay_buffer) + resd 16*16*go4kDLL_wrk.size + +%ifdef AUTHORING +EXPORT MANGLE_DATA(4klang_current_tick) + resd 0 +%endif + +%ifdef GO4K_USE_ENVELOPE_RECORDINGS +EXPORT MANGLE_DATA(4klang_envelope_buffer) + resd ((MAX_SAMPLES)/8) ; // samples every 256 samples and stores 16*2 = 32 values +%endif +%ifdef GO4K_USE_NOTE_RECORDINGS +EXPORT MANGLE_DATA(4klang_note_buffer) + resd ((MAX_SAMPLES)/8) ; // samples every 256 samples and stores 16*2 = 32 values +%endif + +; //======================================================================================== +; // .g4kdat section (initialized data for go4k) +; //======================================================================================== +SECT_DATA(g4kdat1) + +; // some synth constants +go4k_synth_commands dd 0 + dd MANGLE_FUNC(go4kENV_func,0) + dd MANGLE_FUNC(go4kVCO_func,0) + dd MANGLE_FUNC(go4kVCF_func,0) + dd MANGLE_FUNC(go4kDST_func,0) + dd MANGLE_FUNC(go4kDLL_func,0) + dd MANGLE_FUNC(go4kFOP_func,0) + dd MANGLE_FUNC(go4kFST_func,0) + dd MANGLE_FUNC(go4kPAN_func,0) + dd MANGLE_FUNC(go4kOUT_func,0) + dd MANGLE_FUNC(go4kACC_func,0) + dd MANGLE_FUNC(go4kFLD_func,0) +%ifdef GO4K_USE_GLITCH + dd MANGLE_FUNC(go4kGLITCH_func,0) +%endif +%ifdef GO4K_USE_FSTG + dd MANGLE_FUNC(go4kFSTG_func,0) +%endif + +SECT_DATA(g4kdat2) + +%ifdef GO4K_USE_16BIT_OUTPUT +c_32767 dd 32767.0 +%endif +c_i128 dd 0.0078125 +c_RandDiv dd 65536*32768 +c_0_5 dd 0.5 +%ifdef GO4K_USE_VCO_GATE +c_16 dd 16.0 +%endif +%ifdef GO4K_USE_DLL_CHORUS +DLL_DEPTH dd 1024.0 +%endif +%ifdef GO4K_USE_DLL_DC_FILTER +c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate) +%else + %ifdef GO4K_USE_VCO_GATE +c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate) + %endif +%endif +EXPORT MANGLE_DATA(RandSeed) + dd 1 +c_24 dd 24 +c_i12 dd 0x3DAAAAAA +FREQ_NORMALIZE dd 0.000092696138 ; // 220.0/(2^(69/12)) / 44100.0 +EXPORT MANGLE_DATA(LFO_NORMALIZE) + dd DEF_LFO_NORMALIZE +%ifdef GO4K_USE_GROOVE_PATTERN +go4k_groove_pattern dw 0011100111001110b +%endif + +; //======================================================================================== +; // .crtemui section (emulates crt functions) +; //======================================================================================== +SECT_TEXT(crtemui) + +EXPORT MANGLE_FUNC(FloatRandomNumber,0) + push eax + imul eax,dword [MANGLE_DATA(RandSeed)],16007 + mov dword [MANGLE_DATA(RandSeed)], eax + fild dword [MANGLE_DATA(RandSeed)] + fidiv dword [c_RandDiv] + pop eax + ret + +; //======================================================================================== +; // .g4kcod* sections (code for go4k) +; //======================================================================================== + +; //---------------------------------------------------------------------------------------- +; // Waveshaper function +; //---------------------------------------------------------------------------------------- +; // Input : st0 : shaping coeff +; // st1 : input +; // Output: st0 : result +; //---------------------------------------------------------------------------------------- +%ifdef INCLUDE_WAVESHAPER + +SECT_TEXT(g4kcod2) + +go4kWaveshaper: +%ifdef GO4K_USE_WAVESHAPER_CLIP + fxch + fld1 ; // 1 val + fucomi st1 ; // 1 val + jbe short go4kWaveshaper_clip + fchs ; // -1 val + fucomi st1 ; // -1 val + fcmovb st0, st1 ; // val -1 (if val > -1) +go4kWaveshaper_clip: + fstp st1 ; // newval + fxch +%endif + fsub dword [c_0_5] + fadd st0 + fst dword [esp-4] ; // amnt in + fadd st0 ; // 2*amnt in + fld1 ; // 1 2*amnt in + fsub dword [esp-4] ; // 1-amnt 2*amnt in + fdivp st1, st0 ; // k in + fld st1 ; // sin k in + fabs ; // a(in) k in + fmul st1 ; // k*a(in) k in + fld1 + faddp st1, st0 ; // 1+k*a(in) k in + fxch st1 ; // k 1+k*a(in) in + fld1 + faddp st1, st0 ; // 1+k 1+k*a(in) in + fmulp st2 ; // 1+k*a(in) (1+k)*in + fdivp st1, st0 ; // out + ret + +%endif ; INCLUDE_WAVESHAPER + +; //---------------------------------------------------------------------------------------- +; // unit values preparation/transform +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcod3) + +go4kTransformValues: + push ecx + xor ecx, ecx + xor eax, eax + mov edx, go4k_transformed_values +go4kTransformValues_loop: + lodsb + push eax + fild dword [esp] + fmul dword [c_i128] + fstp dword [edx+ecx*4] + pop eax + inc ecx + cmp ecx, dword [esp+8] + jl go4kTransformValues_loop + pop ecx + ret 4 + +; //---------------------------------------------------------------------------------------- +; // Envelope param mapping +; //---------------------------------------------------------------------------------------- +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) +; //---------------------------------------------------------------------------------------- +; // Input : st0 : base +; // st1 : exponent +; // Output: st0 : result +; //---------------------------------------------------------------------------------------- +EXPORT MANGLE_FUNC(Power,0) ; // base exp + fld1 + fadd st0 + fyl2x ; // log2_base + fld1 ; // 1 log2_base + fld st1 ; // log2_base 1 log2_base + fprem ; // (frac)log2_base 1 log2_base + f2xm1 ; // 2 ^ '' - 1 1 log2_base + faddp st1, st0 ; // 2 ^ '' (int)log2_base + fscale + fstp st1 + ret + +; //---------------------------------------------------------------------------------------- +; // ENV Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcoda) + +EXPORT MANGLE_FUNC(go4kENV_func,0) + push 5 + call go4kTransformValues +%ifdef GO4K_USE_ENV_CHECK +; check if current note still active + mov eax, dword [ecx-4] + test eax, eax + jne go4kENV_func_do + fldz + ret +%endif +go4kENV_func_do: + mov eax, dword [ecx-8] ; // is the instrument in release mode (note off)? + test eax, eax + je go4kENV_func_process + mov dword [WRK+go4kENV_wrk.state], ENV_STATE_RELEASE +go4kENV_func_process: + mov eax, dword [WRK+go4kENV_wrk.state] + fld dword [WRK+go4kENV_wrk.level] ; // val - +; // check for sustain state + cmp al, ENV_STATE_SUSTAIN + je short go4kENV_func_leave2 +go4kENV_func_attac: + cmp al, ENV_STATE_ATTAC + jne short go4kENV_func_decay + call go4kENVMap ; // newval + faddp st1, st0 +; // check for end of attac + fld1 ; // 1 newval + fucomi st1 ; // 1 newval + fcmovnb st0, st1 ; // newval 1 (if newval < 1) + jbe short go4kENV_func_statechange +go4kENV_func_decay: + cmp al, ENV_STATE_DECAY + jne short go4kENV_func_release + call go4kENVMap ; // newval + fsubp st1, st0 +; // check for end of decay + fld dword [edx+go4kENV_val.sustain] ; // sustain newval + fucomi st1 ; // sustain newval + fcmovb st0, st1 ; // newval sustain (if newval > sustain) + jnc short go4kENV_func_statechange +go4kENV_func_release: +; // release state? + cmp al, ENV_STATE_RELEASE + jne short go4kENV_func_leave + call go4kENVMap ; // newval + fsubp st1, st0 +; // check for end of release + fldz ; // 0 newval + fucomi st1 ; // 0 newval + fcmovb st0, st1 ; // newval 0 (if newval > 0) + jc short go4kENV_func_leave +go4kENV_func_statechange: ; // newval + inc dword [WRK+go4kENV_wrk.state] +go4kENV_func_leave: ; // newval bla + fstp st1 +; // store new env value + 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 + +; //---------------------------------------------------------------------------------------- +; // VCO Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodp) + +go4kVCO_pulse: + fucomi st1 ; // c p + fld1 + jnc short go4kVCO_func_pulse_up ; // +1 c p + fchs ; // -1 c p +go4kVCO_func_pulse_up: + fstp st1 ; // +-1 p + fstp st1 ; // +-1 + ret + +SECT_TEXT(g4kcodt) + +go4kVCO_trisaw: + fucomi st1 ; // c p + jnc short go4kVCO_func_trisaw_up + fld1 ; // 1 c p + fsubr st2, st0 ; // 1 c 1-p + fsubrp st1, st0 ; // 1-c 1-p +go4kVCO_func_trisaw_up: + fdivp st1, st0 ; // tp'/tc + fadd st0 ; // 2*'' + fld1 ; // 1 2*'' + fsubp st1, st0 ; // 2*''-1 + ret + +SECT_TEXT(g4kcods) + +go4kVCO_sine: + fucomi st1 ; // c p + jnc short go4kVCO_func_sine_do + fstp st1 + fsub st0, st0 ; // 0 + ret +go4kVCO_func_sine_do + fdivp st1, st0 ; // p/c + fldpi ; // pi p + fadd st0 ; // 2*pi p + fmulp st1, st0 ; // 2*pi*p + fsin ; // sin(2*pi*p) + ret + +%ifdef GO4K_USE_VCO_GATE + +SECT_TEXT(g4kcodq) + +go4kVCO_gate: + fxch ; // p c + fstp st1 ; // p + fmul dword [c_16] ; // p' + push eax + push eax + fistp dword [esp] ; // - + fld1 ; // 1 + pop eax + and al, 0xf + bt word [VAL-5],ax + jc go4kVCO_gate_bit + fsub st0, st0 ; // 0 +go4kVCO_gate_bit: + fld dword [WRK+go4kVCO_wrk.cm] ; // 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] + pop eax + ret +%endif + +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 +%ifdef GO4K_USE_VCO_CHECK +; check if current note still active + mov eax, dword [ecx-4] + test eax, eax + jne go4kVCO_func_do +%ifdef GO4K_USE_VCO_STEREO + movzx eax, byte [VAL-1] ; // get flags and check for stereo + test al, byte VCO_STEREO + jz short go4kVCO_func_nostereoout + fldz +go4kVCO_func_nostereoout: +%endif + fldz + ret +go4kVCO_func_do: +%endif + movzx eax, byte [VAL-1] ; // get flags +%ifdef GO4K_USE_VCO_STEREO + test al, byte VCO_STEREO + jz short go4kVCO_func_nopswap + fld dword [WRK+go4kVCO_wrk.phase] ;// swap left/right phase values for first stereo run + fld dword [WRK+go4kVCO_wrk.phase2] + fstp dword [WRK+go4kVCO_wrk.phase] + fstp dword [WRK+go4kVCO_wrk.phase2] +go4kVCO_func_nopswap: +%endif +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] + fadd st0 +%ifdef GO4K_USE_VCO_STEREO + test al, byte VCO_STEREO + jz short go4kVCO_func_nodswap + fchs ;// negate detune for stereo +go4kVCO_func_nodswap: +%endif + faddp st1 +%ifdef GO4K_USE_VCO_MOD_DM + fadd dword [WRK+go4kVCO_wrk.dm] +%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 +go4kVCO_func_skipnote: + fmul dword [c_i12] + call _Power@0 + test al, byte LFO + jz short go4kVCO_func_normalize_note + fmul dword [_LFO_NORMALIZE] ; // st0 is now frequency for lfo + jmp short go4kVCO_func_normalized +go4kVCO_func_normalize_note: + fmul dword [FREQ_NORMALIZE] ; // st0 is now frequency +go4kVCO_func_normalized: + fadd dword [WRK+go4kVCO_wrk.phase] +%ifdef GO4K_USE_VCO_MOD_FM + fadd dword [WRK+go4kVCO_wrk.fm] +%endif + fld1 + fadd st1, st0 + fxch + 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 + fprem + 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 + call go4kVCO_sine +go4kVCO_func_trisaw: + test al, byte TRISAW + jz short go4kVCO_func_pulse + call go4kVCO_trisaw +go4kVCO_func_pulse: + test al, byte PULSE +%ifdef GO4K_USE_VCO_GATE + jz short go4kVCO_func_gate +%else + jz short go4kVCO_func_noise +%endif + call go4kVCO_pulse +%ifdef GO4K_USE_VCO_GATE +go4kVCO_func_gate: + test al, byte GATE + jz short go4kVCO_func_noise + call go4kVCO_gate +%endif +go4kVCO_func_noise: + test al, byte NOISE + jz short go4kVCO_func_end + call MANGLE_FUNC(FloatRandomNumber,0) + fstp st1 + fstp st1 +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 + test al, byte VCO_STEREO + jz short go4kVCO_func_stereodone + sub al, byte VCO_STEREO + fld dword [WRK+go4kVCO_wrk.phase] ;// swap left/right phase values again for second stereo run + fld dword [WRK+go4kVCO_wrk.phase2] + fstp dword [WRK+go4kVCO_wrk.phase] + fstp dword [WRK+go4kVCO_wrk.phase2] + jmp go4kVCO_func_process +go4kVCO_func_stereodone: +%endif + ret + +; //---------------------------------------------------------------------------------------- +; // VCF Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodc) + +EXPORT MANGLE_FUNC(go4kVCF_func,0) + push 3 + call go4kTransformValues +%ifdef GO4K_USE_VCF_CHECK +; check if current note still active + mov eax, dword [ecx-4] + test eax, eax + jne go4kVCF_func_do + ret +go4kVCF_func_do: +%endif + 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 + +%ifdef GO4K_USE_VCF_STEREO + test al, byte STEREO + jz short go4kVCF_func_process + add WRK, go4kVCF_wrk.low2 +go4kVCF_func_stereoloop: ; // switch channels + fxch st1 ; // inr inl +%endif + +go4kVCF_func_process: + fld dword [esp-8] + fld dword [esp-4] + fmul dword [WRK+go4kVCF_wrk.band] ; // f*b r in + fadd dword [WRK+go4kVCF_wrk.low] ; // l' r in + fst dword [WRK+go4kVCF_wrk.low] ; // l' r in + fsubp st2, st0 ; // r in-l' + fmul dword [WRK+go4kVCF_wrk.band] ; // r*b in-l' + fsubp st1, st0 ; // h' + fst dword [WRK+go4kVCF_wrk.high] ; // h' + fmul dword [esp-4] ; // h'*f + fadd dword [WRK+go4kVCF_wrk.band] ; // b' + fstp dword [WRK+go4kVCF_wrk.band] + fldz +go4kVCF_func_low: + test al, byte LOWPASS + jz short go4kVCF_func_high + fadd dword [WRK+go4kVCF_wrk.low] +go4kVCF_func_high: +%ifdef GO4K_USE_VCF_HIGH + test al, byte HIGHPASS + jz short go4kVCF_func_band + fadd dword [WRK+go4kVCF_wrk.high] +%endif +go4kVCF_func_band: +%ifdef GO4K_USE_VCF_BAND + test al, byte BANDPASS + jz short go4kVCF_func_peak + fadd dword [WRK+go4kVCF_wrk.band] +%endif +go4kVCF_func_peak: +%ifdef GO4K_USE_VCF_PEAK + test al, byte PEAK + jz short go4kVCF_func_processdone + fadd dword [WRK+go4kVCF_wrk.low] + fsub dword [WRK+go4kVCF_wrk.high] +%endif +go4kVCF_func_processdone: + +%ifdef GO4K_USE_VCF_STEREO + test al, byte STEREO ; // outr inl + jz short go4kVCF_func_end + sub al, byte STEREO + sub WRK, go4kVCF_wrk.low2 + jmp go4kVCF_func_stereoloop +%endif + +go4kVCF_func_end: ; // value - - - - + ret + +; //---------------------------------------------------------------------------------------- +; // DST Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +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 +%ifdef GO4K_USE_DST_CHECK +; check if current note still active + mov eax, dword [ecx-4] + test eax, eax + jne go4kDST_func_do + ret +go4kDST_func_do: +%endif + 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) + fst dword [WRK+go4kDST_wrk.snhphase] + fldz ; // 0 snh' in (inr) + fucomip st1 ; // snh' in (inr) + fstp dword [esp-4] ; // in (inr) + jc short go4kDST_func_hold + fld1 ; // 1 in (inr) + fadd dword [esp-4] ; // 1+snh' in (inr) + fstp dword [WRK+go4kDST_wrk.snhphase]; // in (inr) +%endif +; // calc pregain and postgain +%ifdef GO4K_USE_DST_STEREO + test al, byte STEREO + 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 +%endif + fxch st1 ; // inl outr +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) +%endif + ret ; // out' (outr) +%ifdef GO4K_USE_DST_SH +go4kDST_func_hold: ; // in (inr) + fstp st0 ; // (inr) +%ifdef GO4K_USE_DST_STEREO + test al, byte STEREO + jz short go4kDST_func_monohold ; // (inr) + fstp st0 ; // + fld dword [WRK+go4kDST_wrk.out2] ; // outr +go4kDST_func_monohold: +%endif + fld dword [WRK+go4kDST_wrk.out] ; // out (outr) + ret +%endif + +%endif + +; //---------------------------------------------------------------------------------------- +; // DLL Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +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 + pushad + movzx ebx, byte [VAL-(go4kDLL_val.size-go4kDLL_val.delay)/4] ;// delay length index +%ifdef GO4K_USE_DLL_NOTE_SYNC + test ebx, ebx + jne go4kDLL_func_process + fld1 + fild dword [ecx-4] ; // load note freq + fmul dword [c_i12] + call _Power@0 + fmul dword [FREQ_NORMALIZE] ; // normalize + fdivp st1, st0 ; // invert to get numer of samples + fistp word [_go4k_delay_times+ebx*2] ; store current comb size +%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] + fadd dword [WRK+go4kDLL_wrk.phase] ;// p' in' out +;// clamp phase to 0,1 (only in editor, since delay can be active quite long) +%ifdef GO4K_USE_DLL_CHORUS_CLAMP + fld1 ;// 1 p' in' out + fadd st1, st0 ;// 1 1+p' in' out + fxch ;// 1+p' 1 in' out + fprem ;// p'' 1 in' out + fstp st1 ;// p'' in' out +%endif + fst dword [WRK+go4kDLL_wrk.phase] +;// get current sine value + fldpi ; // pi p in' out + fadd st0 ; // 2*pi p in' out + fmulp st1, st0 ; // 2*pi*p in' out + fsin ; // sin in' out + fld1 ; // 1 sin in' out + 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] + fmulp st1, st0 + fistp dword [esp-4] ; // in' out +%endif + +go4kDLL_func_loop: + movzx esi, word [_go4k_delay_times+ebx*2] ; fetch comb size + mov eax, dword [WRK+go4kDLL_wrk.index] ;// eax is current comb index + +%ifdef GO4K_USE_DLL_CHORUS + ;// add lfo offset and wrap buffer + add eax, dword [esp-4] + cmp eax, esi + jl short go4kDLL_func_buffer_nowrap1 + sub eax, esi +go4kDLL_func_buffer_nowrap1: +%endif + + fld dword [WRK+eax*4+go4kDLL_wrk.buffer];// cout in' out + +%ifdef GO4K_USE_DLL_CHORUS + mov eax, dword [WRK+go4kDLL_wrk.index] +%endif + + ;// add comb output to current output + fadd st2, st0 ;// cout in' out' +%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' +%else + fsub st0, st1 ;// store in' out' + fstp dword [WRK+eax*4+go4kDLL_wrk.buffer];// in' out' + fneg +%endif + ;// wrap comb buffer pos + inc eax + cmp eax, esi + jl short go4kDLL_func_buffer_nowrap2 +%ifdef GO4K_USE_DLL_CHORUS + sub eax, esi +%else + xor eax, eax +%endif +go4kDLL_func_buffer_nowrap2: + mov dword [WRK+go4kDLL_wrk.index], eax + ;// increment buffer pointer to next buffer + inc ebx ;// go to next delay length index + add WRK, go4kDLL_wrk.size ;// go to next delay + mov dword [MANGLE_DATA(go4k_delay_buffer_ofs)], WRK ;// store next delay offset + loopne go4kDLL_func_loop + fstp st0 ;// out' + ;// process a dc filter to prevent heavy offsets in reverb +%ifdef GO4K_USE_DLL_DC_FILTER +; y(n) = x(n) - x(n-1) + R * y(n-1) + sub WRK, go4kDLL_wrk.size + fld dword [WRK+go4kDLL_wrk.dcout] ;// dco out' + fmul dword [c_dc_const] ;// dcc*dco out' + fsub dword [WRK+go4kDLL_wrk.dcin] ;// dcc*dco-dci out' + fxch ;// out' dcc*dco-dci + fst dword [WRK+go4kDLL_wrk.dcin] ;// out' dcc*dco-dci + faddp st1 ;// out' +%ifdef GO4K_USE_UNDENORMALIZE + fadd dword [c_0_5] ;// add and sub small offset to prevent denormalization + fsub dword [c_0_5] +%endif + fst dword [WRK+go4kDLL_wrk.dcout] +%endif + popad + ret +%endif + +; //---------------------------------------------------------------------------------------- +; // GLITCH Tick +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodu) + +EXPORT MANGLE_FUNC(go4kGLITCH_func,0) +%ifdef GO4K_USE_GLITCH + push 5 + call go4kTransformValues + pushad + + mov edi, WRK + mov WRK, dword [MANGLE_DATA(go4k_delay_buffer_ofs)] ;// ebp is current delay + +; mov eax, dword [edx+go4kGLITCH_val.active] +; or eax, dword [edi+go4kGLITCH_wrk2.am] +; test eax, eax +; 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 + fstp st0 ;// in + jnc go4kGLITCH_func_notactive ;// out + + ;// check for first call and init if so init (using slizesize slot) + mov eax, dword [WRK+go4kGLITCH_wrk.slizesize] + and eax, eax + jnz go4kGLITCH_func_process + mov dword [WRK+go4kGLITCH_wrk.index], eax + mov dword [WRK+go4kGLITCH_wrk.store], eax + movzx ebx, byte [VAL-(go4kGLITCH_val.size-go4kGLITCH_val.slicesize)/4] ;// slicesize index + movzx eax, word [_go4k_delay_times+ebx*2] ;// fetch slicesize + push eax + fld1 + fild dword [esp] + fstp dword [WRK+go4kGLITCH_wrk.slizesize] + fstp dword [WRK+go4kGLITCH_wrk.slicepitch] + pop eax +go4kGLITCH_func_process: + ;// fill buffer until full + mov eax, dword [WRK+go4kGLITCH_wrk.store] + cmp eax, MAX_DELAY + jae go4kGLITCH_func_filldone + fst dword [WRK+eax*4+go4kDLL_wrk.buffer] ;// in + inc dword [WRK+go4kGLITCH_wrk.store] +go4kGLITCH_func_filldone: + ;// save input + push eax + fstp dword [esp] ;// - + + ;// read from buffer + push eax + fld dword [WRK+go4kGLITCH_wrk.index] ;// idx + fist dword [esp] + pop eax + fld dword [WRK+eax*4+go4kDLL_wrk.buffer] ;// out idx + fxch ;// idx out + ;// progress readindex with current play speed + fadd dword [WRK+go4kGLITCH_wrk.slicepitch] ;// idx' out + fst dword [WRK+go4kGLITCH_wrk.index] + + ;// check for slice done + fld dword [WRK+go4kGLITCH_wrk.slizesize] ;// size idx' out + fxch ;// idx' size out + fucomip st1 ;// idx' out + fstp st0 ;// out + jc go4kGLITCH_func_process_done + ;// reinit for next loop + xor eax, eax + 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) + fmul dword [WRK+go4kGLITCH_wrk.slizesize] + 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) + fmul dword [WRK+go4kGLITCH_wrk.slicepitch] + fstp dword [WRK+go4kGLITCH_wrk.slicepitch] +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' + fmul dword [esp] ;// in' out' + faddp st1, st0 ;// out' + + pop eax + jmp go4kGLITCH_func_leave +go4kGLITCH_func_notactive: + ;// mark as uninitialized again (using slizesize slot) + xor eax,eax + mov dword [WRK+go4kGLITCH_wrk.slizesize], eax +go4kGLITCH_func_leave: + add WRK, go4kDLL_wrk.size ;// go to next delay + mov dword [MANGLE_DATA(go4k_delay_buffer_ofs)], WRK ;// store next delay offset + popad + ret +%endif + +; //---------------------------------------------------------------------------------------- +; // FOP Tick (various fp stack based operations) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodg) + +EXPORT MANGLE_FUNC(go4kFOP_func,0) + push 1 + call go4kTransformValues +go4kFOP_func_pop: + dec eax + jnz go4kFOP_func_addp + fstp st0 + ret +go4kFOP_func_addp: + dec eax + jnz go4kFOP_func_mulp + faddp st1, st0 + ret +go4kFOP_func_mulp: + dec eax + jnz go4kFOP_func_push + fmulp st1, st0 + ret +go4kFOP_func_push: + dec eax + jnz go4kFOP_func_xch + fld st0 + ret +go4kFOP_func_xch: + dec eax + jnz go4kFOP_func_add + fxch + ret +go4kFOP_func_add: + dec eax + jnz go4kFOP_func_mul + fadd st1 + ret +go4kFOP_func_mul: + dec eax + jnz go4kFOP_func_addp2 + fmul st1 + ret +go4kFOP_func_addp2: + dec eax + jnz go4kFOP_func_loadnote + faddp st2, st0 + faddp st2, st0 + ret +go4kFOP_func_loadnote: + dec eax + jnz go4kFOP_func_mulp2 + fild dword [ecx-4] + fmul dword [c_i128] + ret +go4kFOP_func_mulp2: + fmulp st2, st0 + fmulp st2, st0 + ret + +; //---------------------------------------------------------------------------------------- +; // FST Tick (stores a value somewhere in the local workspace) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodh) + +EXPORT MANGLE_FUNC(go4kFST_func,0) + push 1 + call go4kTransformValues + fld dword [edx+go4kFST_val.amount] + fsub dword [c_0_5] + fadd st0 + fmul st1 + lodsw + and eax, 0x00003fff ; // eax is destination slot + test word [VAL-2], FST_ADD + jz go4kFST_func_set + fadd dword [ecx+eax*4] +go4kFST_func_set: + fstp dword [ecx+eax*4] + test word [VAL-2], FST_POP + jz go4kFST_func_done + fstp st0 +go4kFST_func_done: + ret + +; //---------------------------------------------------------------------------------------- +; // FLD Tick (load a value on stack, optionally add a modulation signal beforehand) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : signal-signal*pan , signal*pan +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodm) + +EXPORT MANGLE_FUNC(go4kFLD_func,0) ;// in main env +%ifdef GO4K_USE_FLD + push 1 + call go4kTransformValues + 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 + +; //---------------------------------------------------------------------------------------- +; // FSTG Tick (stores a value anywhere in the synth (and in each voice)) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +%ifdef GO4K_USE_FSTG + +SECT_TEXT(g4kcodi) + +EXPORT MANGLE_FUNC(go4kFSTG_func,0) + push 1 + call go4kTransformValues +%ifdef GO4K_USE_FSTG_CHECK +; check if current note still active + mov eax, dword [ecx-4] + test eax, eax + jne go4kFSTG_func_do + lodsw + jmp go4kFSTG_func_testpop +go4kFSTG_func_do: +%endif + fld dword [edx+go4kFST_val.amount] + fsub dword [c_0_5] + fadd st0 + fmul st1 + lodsw + and eax, 0x00003fff ; // eax is destination slot + test word [VAL-2], FST_ADD + jz go4kFSTG_func_set + fadd dword [go4k_synth_wrk+eax*4] +go4kFSTG_func_set: +%if MAX_VOICES > 1 + fst dword [go4k_synth_wrk+eax*4] + fstp dword [go4k_synth_wrk+eax*4+go4k_instrument.size] +%else + fstp dword [go4k_synth_wrk+eax*4] +%endif +go4kFSTG_func_testpop: + test word [VAL-2], FST_POP + jz go4kFSTG_func_done + fstp st0 +go4kFSTG_func_done: + ret +%endif + +; //---------------------------------------------------------------------------------------- +; // PAN Tick (multiplies signal with main envelope and converts to stereo) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : signal-signal*pan , signal*pan +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodj) + +EXPORT MANGLE_FUNC(go4kPAN_func,0) ;// in main env +%ifdef GO4K_USE_PAN + push 1 + call go4kTransformValues + 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 +%else + fmul dword [c_0_5] + fld st0 +%endif + ret + +; //---------------------------------------------------------------------------------------- +; // OUT Tick ( stores stereo signal pair in temp buffers of the instrument) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodk) + +EXPORT MANGLE_FUNC(go4kOUT_func,0) ;// l r +%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] ;// - + +%endif + ret + +; //---------------------------------------------------------------------------------------- +; // ACC Tick (stereo signal accumulation for synth commands only -> dont use in instrument commands) +; //---------------------------------------------------------------------------------------- +; // IN : WRK = unit workspace +; // IN : VAL = unit values +; // IN : ecx = global workspace +; // OUT : +; // DIRTY : eax +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodl) + +EXPORT MANGLE_FUNC(go4kACC_func,0) + push 1 + call go4kTransformValues + pushad + mov edi, go4k_synth_wrk + add edi, go4k_instrument.size + sub edi, eax ; // eax already contains the accumulation offset from the go4kTransformValues call + mov cl, MAX_INSTRUMENTS*MAX_VOICES + fldz ;// 0 + fldz ;// 0 0 +go4kACC_func_loop: + fadd dword [edi-8] ;// l 0 + fxch ;// 0 l + fadd dword [edi-4] ;// r l + fxch ;// l r + add edi, go4k_instrument.size + dec cl + jnz go4kACC_func_loop + popad + ret + +; //---------------------------------------------------------------------------------------- +; // Update Instrument (allocate voices, set voice to release) +; //---------------------------------------------------------------------------------------- +; // IN : +; // IN : +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodw) + +go4kUpdateInstrument: +; // get new note + mov eax, dword [esp+4+4] ; // eax = current tick + shr eax, PATTERN_SIZE_SHIFT ; // eax = current pattern + imul edx, ecx, dword MAX_PATTERNS ; // edx = instrument pattern list index + movzx edx, byte [edx+eax+MANGLE_DATA(go4k_pattern_lists)] ; // edx = pattern index + mov eax, dword [esp+4+4] ; // eax = current tick + shl edx, PATTERN_SIZE_SHIFT + and eax, PATTERN_SIZE-1 + movzx edx, byte [edx+eax+MANGLE_DATA(go4k_patterns)] ; // edx = requested note in new patterntick +; // apply note changes + cmp dl, HLD ; // anything but hold causes action + je short go4kUpdateInstrument_done + inc dword [edi] ; // set release flag if needed +%if MAX_VOICES > 1 + inc dword [edi+go4k_instrument.size] ; // set release flag if needed +%endif + cmp dl, HLD ; // check for new note + jl short go4kUpdateInstrument_done +%if MAX_VOICES > 1 + pushad + xchg eax, dword [go4k_voiceindex + ecx*4] + test eax, eax + je go4kUpdateInstrument_newNote + add edi, go4k_instrument.size +go4kUpdateInstrument_newNote: + xor al,1 + xchg dword [go4k_voiceindex + ecx*4], eax +%endif + pushad + xor eax, eax + mov ecx, (8+MAX_UNITS*MAX_UNIT_SLOTS*4)/4 ; // clear only relase, note and workspace + rep stosd + popad + mov dword [edi+4], edx ; // set requested note as current note +%if MAX_VOICES > 1 + popad +%endif + jmp short go4kUpdateInstrument_done +go4kUpdateInstrument_done: + ret + +; //---------------------------------------------------------------------------------------- +; // Render Voices +; //---------------------------------------------------------------------------------------- +; // IN : +; // IN : +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodx) + +go4kRenderVoices: + push ecx ; // save current instrument counter +%if MAX_VOICES > 1 + push COM ; // save current instrument command index + push VAL ; // save current instrument values index +%endif + call go4k_VM_process ; // call synth vm for instrument voices + mov eax, dword [ecx+go4kENV_wrk.state] + cmp al, byte ENV_STATE_OFF + jne go4kRenderVoices_next + xor eax, eax + mov dword [ecx-4], eax ; // kill note if voice is done +go4kRenderVoices_next: +%if MAX_VOICES > 1 + pop VAL ; // restore instrument value index + pop COM ; // restore instrument command index +%endif + +%ifdef GO4K_USE_BUFFER_RECORDINGS + mov eax, dword [esp+16] ; // get current tick + shr eax, 8 ; // every 256th sample = ~ 172 hz + shl eax, 5 ; // for 16 instruments a 2 voices + add eax, dword [esp] + add eax, dword [esp] ; // + 2*currentinstrument+0 +%ifdef GO4K_USE_ENVELOPE_RECORDINGS + mov edx, dword [ecx+go4kENV_wrk.level] + mov dword [__4klang_envelope_buffer+eax*4], edx +%endif +%ifdef GO4K_USE_NOTE_RECORDINGS + mov edx, dword [ecx-4] + mov dword [__4klang_note_buffer+eax*4], edx +%endif +%endif + +%if MAX_VOICES > 1 + call go4k_VM_process ; // call synth vm for instrument voices + mov eax, dword [ecx+go4kENV_wrk.state] + cmp al, byte ENV_STATE_OFF + jne go4k_render_instrument_next2 + xor eax, eax + mov dword [ecx-4], eax ; // kill note if voice is done +go4k_render_instrument_next2: + +%ifdef GO4K_USE_BUFFER_RECORDINGS + mov eax, dword [esp+16] ; // get current tick + shr eax, 8 ; // every 256th sample = ~ 172 hz + shl eax, 5 ; // for 16 instruments a 2 voices + add eax, dword [esp] + add eax, dword [esp] ; // + 2*currentinstrument+0 +%ifdef GO4K_USE_ENVELOPE_RECORDINGS + mov edx, dword [ecx+go4kENV_wrk.level] + mov dword [__4klang_envelope_buffer+eax*4+4], edx +%endif +%ifdef GO4K_USE_NOTE_RECORDINGS + mov edx, dword [ecx-4] + mov dword [__4klang_note_buffer+eax*4+4], edx +%endif +%endif + +%endif + pop ecx ; // restore instrument counter + ret + +; //---------------------------------------------------------------------------------------- +; // the entry point for the synth +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcody) + +EXPORT MANGLE_FUNC(_4klang_render,4) + pushad + xor ecx, ecx +%ifdef GO4K_USE_BUFFER_RECORDINGS + push ecx +%endif +; loop all ticks +go4k_render_tickloop: + push ecx + xor ecx, ecx +; loop all samples per tick +go4k_render_sampleloop: + push ecx + xor ecx, ecx + mov ebx, MANGLE_DATA(go4k_synth_instructions) ; // ebx = instrument command index + mov VAL, MANGLE_DATA(go4k_synth_parameter_values); // VAL = instrument values index + mov edi, _go4k_delay_buffer ; // get offset of first delay buffer + mov dword [MANGLE_DATA(go4k_delay_buffer_ofs)], edi ; // store offset in delaybuffer offset variable + mov edi, go4k_synth_wrk ; // edi = first instrument +; loop all instruments +go4k_render_instrumentloop: + mov eax, dword [esp] ; // eax = current tick sample + and eax, eax + jnz go4k_render_instrument_process ; // tick change? (first sample in current tick) + call go4kUpdateInstrument ; // update instrument state +; process instrument +go4k_render_instrument_process: + call go4kRenderVoices + inc ecx + cmp cl, byte MAX_INSTRUMENTS + jl go4k_render_instrumentloop + mov dword [edi+4], ecx ; // move a value != 0 into note slot, so processing will be done + call go4k_VM_process ; // call synth vm for synth +go4k_render_output_sample: +%ifdef GO4K_USE_BUFFER_RECORDINGS + inc dword [esp+8] + xchg esi, dword [esp+48] ; // edx = destbuffer +%else + xchg esi, dword [esp+44] ; // edx = destbuffer +%endif +%ifdef GO4K_CLIP_OUTPUT + fld dword [edi-8] + fld1 ; // 1 val + fucomi st1 ; // 1 val + jbe short go4k_render_clip1 + fchs ; // -1 val + fucomi st1 ; // -1 val + fcmovb st0, st1 ; // val -1 (if val > -1) +go4k_render_clip1: + fstp st1 ; // newval +%ifdef GO4K_USE_16BIT_OUTPUT + push eax + fmul dword [c_32767] + fistp dword [esp] + pop eax + mov word [esi],ax ; // store integer converted left sample + lodsw +%else + fstp dword [esi] ; // store left sample + lodsd +%endif + fld dword [edi-4] + fld1 ; // 1 val + fucomi st1 ; // 1 val + jbe short go4k_render_clip2 + fchs ; // -1 val + fucomi st1 ; // -1 val + fcmovb st0, st1 ; // val -1 (if val > -1) +go4k_render_clip2: + fstp st1 ; // newval +%ifdef GO4K_USE_16BIT_OUTPUT + push eax + fmul dword [c_32767] + fistp dword [esp] + pop eax + mov word [esi],ax ; // store integer converted right sample + lodsw +%else + fstp dword [esi] ; // store right sample + lodsd +%endif +%else + fld dword [edi-8] +%ifdef GO4K_USE_16BIT_OUTPUT + push eax + fmul dword [c_32767] + fistp dword [esp] + pop eax + mov word [esi],ax ; // store integer converted left sample + lodsw +%else + fstp dword [esi] ; // store left sample + lodsd +%endif + fld dword [edi-4] +%ifdef GO4K_USE_16BIT_OUTPUT + push eax + fmul dword [c_32767] + fistp dword [esp] + pop eax + mov word [esi],ax ; // store integer converted right sample + lodsw +%else + fstp dword [esi] ; // store right sample + lodsd +%endif +%endif +%ifdef GO4K_USE_BUFFER_RECORDINGS + xchg esi, dword [esp+48] +%else + xchg esi, dword [esp+44] +%endif + pop ecx + inc ecx +%ifdef GO4K_USE_GROOVE_PATTERN + mov ebx, dword SAMPLES_PER_TICK + mov eax, dword [esp] + and eax, 0x0f + bt dword [go4k_groove_pattern],eax + jnc go4k_render_nogroove + sub ebx, dword 3000 +go4k_render_nogroove: + cmp ecx, ebx +%else + cmp ecx, dword SAMPLES_PER_TICK +%endif + jl go4k_render_sampleloop + pop ecx + inc ecx +%ifdef AUTHORING + mov dword[__4klang_current_tick], ecx +%endif + cmp ecx, dword MAX_TICKS + jl go4k_render_tickloop +%ifdef GO4K_USE_BUFFER_RECORDINGS + pop ecx +%endif + popad + ret 4 + +; //---------------------------------------------------------------------------------------- +; // the magic behind it :) +; //---------------------------------------------------------------------------------------- +; // IN : edi = instrument pointer +; // IN : esi = instrumet values +; // IN : ebx = instrument instructions +; // OUT : +; // DIRTY : +; //---------------------------------------------------------------------------------------- +SECT_TEXT(g4kcodz) + +go4k_VM_process: + lea WRK, [edi+8] ; // get current workspace pointer + mov ecx, WRK ; // ecx = workspace start +go4k_VM_process_loop: + movzx eax, byte [ebx] ; // get command byte + inc ebx + test eax, eax + je go4k_VM_process_done ; // command byte = 0? so done + call dword [eax*4+go4k_synth_commands] + add WRK, MAX_UNIT_SLOTS*4 ; // go to next workspace slot + jmp short go4k_VM_process_loop +go4k_VM_process_done: + add edi, go4k_instrument.size ; // go to next instrument voice + ret \ No newline at end of file diff --git a/src/4klang.inc b/src/4klang.inc index 084c54e..233a038 100644 --- a/src/4klang.inc +++ b/src/4klang.inc @@ -1,1752 +1,657 @@ -%define WRK ebp ; // alias for unit workspace -%define VAL esi ; // alias for unit values (transformed/untransformed) -%define COM ebx ; // alias for instrument opcodes +%ifndef _4KLANG_INC +%define _4KLANG_INC -;// conditional defines +; Following defines have to be defined before this include: +; MAX_INSTRUMENTS e.g. %define MAX_INSTRUMENTS 10 +; BPM e.g. %define BPM 100 +; MAX_PATTERNS e.g. %define MAX_PATTERNS 1 +; +; Optionally: +; PATTERN_SIZE_SHIFT e.g. %define PATTERN_SIZE_SHIFT 4 <- this is the default + +%macro EXPORT 1 + global %1 + %1 +%endmacro + +%ifidn __OUTPUT_FORMAT__,win32 + ; on win32, function f with n parameters is mangled as "_f@n" + %define MANGLE_FUNC(f,n) _ %+ f %+ @ %+ n + %define WIN_OR_MAC +%endif + +%ifidn __OUTPUT_FORMAT__,elf32 + ; on linux, function f with n parameters is mangled as "f" + %define MANGLE_FUNC(f,n) f +%endif + +%ifidn __OUTPUT_FORMAT__,macho32 + ; on mac, function f with x parameters is mangled as "_f" + %define MANGLE_FUNC(f,n) _f + %define WIN_OR_MAC +%endif + +%ifdef WIN_OR_MAC + ; Windows has crinkler so one may USE_SECTIONS to put everything in custom sections to aid crinkler. + ; Maybe mac users need it too + %ifdef USE_SECTIONS + %define SECT_BSS(n) section . %+ n bss align=1 + %define SECT_DATA(n) section . %+ n data align=1 + %define SECT_TEXT(n) section . %+ n code align=1 + %else + %define SECT_BSS(n) section .bss align=1 + %define SECT_DATA(n) section .data align=1 + %define SECT_TEXT(n) section .code align=1 + %endif + ; On windows and mac, data label d is mangled as "_d" + %define MANGLE_DATA(d) _ %+ d +%else + ; Linux + %ifdef USE_SECTIONS + %define SECT_BSS(n) section .bss. %+ n nobits alloc noexec write align=1 + %define SECT_DATA(n) section .data. %+ n progbits alloc noexec write align=1 + %define SECT_TEXT(n) section .text. %+ n progbits alloc exec nowrite align=1 + %else + %define SECT_BSS(n) section .bss. nobits alloc noexec write align=1 + %define SECT_DATA(n) section .data. progbits alloc noexec write align=1 + %define SECT_TEXT(n) section .text. progbits alloc exec nowrite align=1 + %endif + ; On linux, data label d is mangled as "d" + %define MANGLE_DATA(d) d +%endif + +%ifdef GO4K_USE_ALL + ; GO4K_USE_ALL is convenience way to enable almost all features of the synth, for vsti plugins and such which + ; do not have any size constraints. However, GO4K_USE_ALL should only enable features that absolutely do not + ; change the functioning of the synth in any way, just add features. Clipping, 16 bit output etc. should still + ; be enabled only whent they are actually needed + + ; Things that are NOT defined by GO4K_USE_ALL + ;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer + ;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code + ;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code + ;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code + ;%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units + ;%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output + + %define GO4K_USE_DST ; // removing this will skip DST unit + %define GO4K_USE_DLL ; // removing this will skip DLL unit + %define GO4K_USE_PAN ; // removing this will skip PAN unit + %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 + %define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping + %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 - %define INCLUDE_WAVESHAPER + %define INCLUDE_WAVESHAPER %endif %ifdef GO4K_USE_DST - %define INCLUDE_WAVESHAPER + %define INCLUDE_WAVESHAPER %endif %ifdef GO4K_USE_VCO_MOD_PM - %define PHASE_RENORMALIZE + %define PHASE_RENORMALIZE %endif %ifdef GO4K_USE_VCO_PHASE_OFFSET - %define PHASE_RENORMALIZE + %define PHASE_RENORMALIZE %endif %ifdef GO4K_USE_ENVELOPE_RECORDINGS - %define GO4K_USE_BUFFER_RECORDINGS + %define GO4K_USE_BUFFER_RECORDINGS %endif %ifdef GO4K_USE_NOTE_RECORDINGS - %define GO4K_USE_BUFFER_RECORDINGS + %define GO4K_USE_BUFFER_RECORDINGS %endif -; //======================================================================================== -; // .bss section -; //======================================================================================== -%ifdef USE_SECTIONS -section .g4kbss1 bss align=1 -%else -section .bss +; //---------------------------------------------------------------------------------------- +; // synth defines +; //---------------------------------------------------------------------------------------- + +%define MAX_DELAY 65536 +%define MAX_UNITS 64 +%define MAX_UNIT_SLOTS 16 + +%ifndef SAMPLE_RATE +%define SAMPLE_RATE 44100 +%endif + +%ifndef MAX_VOICES +%define MAX_VOICES 1 +%endif + +%ifndef HLD +%define HLD 1 +%endif + +%ifndef PATTERN_SIZE_SHIFT +%define PATTERN_SIZE_SHIFT 4 %endif -; // the one and only synth object -%if MAX_VOICES > 1 -go4k_voiceindex resd 16 -%endif -go4k_transformed_values resd 16 -go4k_synth_wrk resb go4k_synth.size -global _go4k_delay_buffer_ofs -_go4k_delay_buffer_ofs resd 1 -global _go4k_delay_buffer -_go4k_delay_buffer resd 16*16*go4kDLL_wrk.size +%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) +%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) +%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) +%define DEF_LFO_NORMALIZE 0.000038 +%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -%ifdef AUTHORING -global __4klang_current_tick -__4klang_current_tick resd 0 -%endif +%define GO4K_BEGIN_CMDDEF(def_name) +%define GO4K_END_CMDDEF db 0 +%define GO4K_BEGIN_PARAMDEF(def_name) +%define GO4K_END_PARAMDEF -%ifdef GO4K_USE_ENVELOPE_RECORDINGS -global __4klang_envelope_buffer -__4klang_envelope_buffer resd ((MAX_SAMPLES)/8) ; // samples every 256 samples and stores 16*2 = 32 values -%endif -%ifdef GO4K_USE_NOTE_RECORDINGS -global __4klang_note_buffer -__4klang_note_buffer resd ((MAX_SAMPLES)/8) ; // samples every 256 samples and stores 16*2 = 32 values -%endif +; //---------------------------------------------------------------------------------------- +; // ENV structs +; //---------------------------------------------------------------------------------------- +GO4K_ENV_ID equ 1 +%macro GO4K_ENV 5 + db %1 + db %2 + db %3 + db %4 + db %5 +%endmacro +%define ATTAC(val) val +%define DECAY(val) val +%define SUSTAIN(val) val +%define RELEASE(val) val +%define GAIN(val) val +struc go4kENV_val +;// unit paramters + .attac resd 1 + .decay resd 1 + .sustain resd 1 + .release resd 1 + .gain resd 1 + .size +endstruc +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 +%define ENV_STATE_DECAY 1 +%define ENV_STATE_SUSTAIN 2 +%define ENV_STATE_RELEASE 3 +%define ENV_STATE_OFF 4 +; //---------------------------------------------------------------------------------------- +; // VCO structs +; //---------------------------------------------------------------------------------------- +GO4K_VCO_ID equ 2 -; //======================================================================================== -; // .g4kdat section (initialized data for go4k) -; //======================================================================================== -%ifdef USE_SECTIONS -section .g4kdat1 data align=1 -%else -section .data +%macro GO4K_VCO 8 + db %1 + db %2 +%ifdef GO4K_USE_VCO_PHASE_OFFSET + db %3 %endif - -; // some synth constants -go4k_synth_commands dd 0 - dd _go4kENV_func@0 - dd _go4kVCO_func@0 - dd _go4kVCF_func@0 - dd _go4kDST_func@0 - dd _go4kDLL_func@0 - dd _go4kFOP_func@0 - dd _go4kFST_func@0 - dd _go4kPAN_func@0 - dd _go4kOUT_func@0 - dd _go4kACC_func@0 - dd _go4kFLD_func@0 -%ifdef GO4K_USE_GLITCH - dd _go4kGLITCH_func@0 -%endif -%ifdef GO4K_USE_FSTG - dd _go4kFSTG_func@0 -%endif - -%ifdef USE_SECTIONS -section .g4kdat2 data align=1 -%else -section .data -%endif - -%ifdef GO4K_USE_16BIT_OUTPUT -c_32767 dd 32767.0 -%endif -c_i128 dd 0.0078125 -c_RandDiv dd 65536*32768 -c_0_5 dd 0.5 %ifdef GO4K_USE_VCO_GATE -c_16 dd 16.0 -%endif -%ifdef GO4K_USE_DLL_CHORUS -DLL_DEPTH dd 1024.0 -%endif -%ifdef GO4K_USE_DLL_DC_FILTER -c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate) -%else - %ifdef GO4K_USE_VCO_GATE -c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate) - %endif -%endif -global _RandSeed -_RandSeed dd 1 -c_24 dd 24 -c_i12 dd 0x3DAAAAAA -FREQ_NORMALIZE dd 0.000092696138 ; // 220.0/(2^(69/12)) / 44100.0 -global _LFO_NORMALIZE -_LFO_NORMALIZE dd DEF_LFO_NORMALIZE -%ifdef GO4K_USE_GROOVE_PATTERN -go4k_groove_pattern dw 0011100111001110b -%endif - -; //======================================================================================== -; // .crtemui section (emulates crt functions) -; //======================================================================================== -%ifdef USE_SECTIONS -section .crtemui code align=1 -%else -section .text -%endif - -export_func FloatRandomNumber@0 - push eax - imul eax,dword [_RandSeed],16007 - mov dword [_RandSeed], eax - fild dword [_RandSeed] - fidiv dword [c_RandDiv] - pop eax - ret - -; //======================================================================================== -; // .g4kcod* sections (code for go4k) -; //======================================================================================== - -%ifdef INCLUDE_WAVESHAPER - -%ifdef USE_SECTIONS -section .g4kcod2 code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // Waveshaper function -; //---------------------------------------------------------------------------------------- -; // Input : st0 : shaping coeff -; // st1 : input -; // Output: st0 : result -; //---------------------------------------------------------------------------------------- - -go4kWaveshaper: -%ifdef GO4K_USE_WAVESHAPER_CLIP - fxch - fld1 ; // 1 val - fucomi st1 ; // 1 val - jbe short go4kWaveshaper_clip - fchs ; // -1 val - fucomi st1 ; // -1 val - fcmovb st0, st1 ; // val -1 (if val > -1) -go4kWaveshaper_clip: - fstp st1 ; // newval - fxch + db %4 %endif - fsub dword [c_0_5] - fadd st0 - fst dword [esp-4] ; // amnt in - fadd st0 ; // 2*amnt in - fld1 ; // 1 2*amnt in - fsub dword [esp-4] ; // 1-amnt 2*amnt in - fdivp st1, st0 ; // k in - fld st1 ; // sin k in - fabs ; // a(in) k in - fmul st1 ; // k*a(in) k in - fld1 - faddp st1, st0 ; // 1+k*a(in) k in - fxch st1 ; // k 1+k*a(in) in - fld1 - faddp st1, st0 ; // 1+k 1+k*a(in) in - fmulp st2 ; // 1+k*a(in) (1+k)*in - fdivp st1, st0 ; // out - ret - -%endif - -%ifdef USE_SECTIONS -section .g4kcod3 code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // unit values preparation/transform -; //---------------------------------------------------------------------------------------- -go4kTransformValues: - push ecx - xor ecx, ecx - xor eax, eax - mov edx, go4k_transformed_values -go4kTransformValues_loop: - lodsb - push eax - fild dword [esp] - fmul dword [c_i128] - fstp dword [edx+ecx*4] - pop eax - inc ecx - cmp ecx, dword [esp+8] - jl go4kTransformValues_loop - pop ecx - ret 4 - -%ifdef USE_SECTIONS -section .g4kcod4 code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // Envelope param mapping -; //---------------------------------------------------------------------------------------- -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) -; //---------------------------------------------------------------------------------------- -; // Input : st0 : base -; // st1 : exponent -; // Output: st0 : result -; //---------------------------------------------------------------------------------------- -export_func Power@0 ; // base exp - fld1 - fadd st0 - fyl2x ; // log2_base - fld1 ; // 1 log2_base - fld st1 ; // log2_base 1 log2_base - fprem ; // (frac)log2_base 1 log2_base - f2xm1 ; // 2 ^ '' - 1 1 log2_base - faddp st1, st0 ; // 2 ^ '' (int)log2_base - fscale - fstp st1 - ret - -%ifdef USE_SECTIONS -section .g4kcoda code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // ENV Tick -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -export_func go4kENV_func@0 - push 5 - call go4kTransformValues -%ifdef GO4K_USE_ENV_CHECK -; check if current note still active - mov eax, dword [ecx-4] - test eax, eax - jne go4kENV_func_do - fldz - ret -%endif -go4kENV_func_do: - mov eax, dword [ecx-8] ; // is the instrument in release mode (note off)? - test eax, eax - je go4kENV_func_process - mov dword [WRK+go4kENV_wrk.state], ENV_STATE_RELEASE -go4kENV_func_process: - mov eax, dword [WRK+go4kENV_wrk.state] - fld dword [WRK+go4kENV_wrk.level] ; // val - -; // check for sustain state - cmp al, ENV_STATE_SUSTAIN - je short go4kENV_func_leave2 -go4kENV_func_attac: - cmp al, ENV_STATE_ATTAC - jne short go4kENV_func_decay - call go4kENVMap ; // newval - faddp st1, st0 -; // check for end of attac - fld1 ; // 1 newval - fucomi st1 ; // 1 newval - fcmovnb st0, st1 ; // newval 1 (if newval < 1) - jbe short go4kENV_func_statechange -go4kENV_func_decay: - cmp al, ENV_STATE_DECAY - jne short go4kENV_func_release - call go4kENVMap ; // newval - fsubp st1, st0 -; // check for end of decay - fld dword [edx+go4kENV_val.sustain] ; // sustain newval - fucomi st1 ; // sustain newval - fcmovb st0, st1 ; // newval sustain (if newval > sustain) - jnc short go4kENV_func_statechange -go4kENV_func_release: -; // release state? - cmp al, ENV_STATE_RELEASE - jne short go4kENV_func_leave - call go4kENVMap ; // newval - fsubp st1, st0 -; // check for end of release - fldz ; // 0 newval - fucomi st1 ; // 0 newval - fcmovb st0, st1 ; // newval 0 (if newval > 0) - jc short go4kENV_func_leave -go4kENV_func_statechange: ; // newval - inc dword [WRK+go4kENV_wrk.state] -go4kENV_func_leave: ; // newval bla - fstp st1 -; // store new env value - 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 - - -; //---------------------------------------------------------------------------------------- -; // VCO Tick -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kcodp code align=1 -%else -section .text -%endif -go4kVCO_pulse: - fucomi st1 ; // c p - fld1 - jnc short go4kVCO_func_pulse_up ; // +1 c p - fchs ; // -1 c p -go4kVCO_func_pulse_up: - fstp st1 ; // +-1 p - fstp st1 ; // +-1 - ret - -%ifdef USE_SECTIONS -section .g4kcodt code align=1 -%else -section .text -%endif -go4kVCO_trisaw: - fucomi st1 ; // c p - jnc short go4kVCO_func_trisaw_up - fld1 ; // 1 c p - fsubr st2, st0 ; // 1 c 1-p - fsubrp st1, st0 ; // 1-c 1-p -go4kVCO_func_trisaw_up: - fdivp st1, st0 ; // tp'/tc - fadd st0 ; // 2*'' - fld1 ; // 1 2*'' - fsubp st1, st0 ; // 2*''-1 - ret - -%ifdef USE_SECTIONS -section .g4kcods code align=1 -%else -section .text -%endif -go4kVCO_sine: - fucomi st1 ; // c p - jnc short go4kVCO_func_sine_do - fstp st1 - fsub st0, st0 ; // 0 - ret -go4kVCO_func_sine_do - fdivp st1, st0 ; // p/c - fldpi ; // pi p - fadd st0 ; // 2*pi p - fmulp st1, st0 ; // 2*pi*p - fsin ; // sin(2*pi*p) - ret - -%ifdef GO4K_USE_VCO_GATE -%ifdef USE_SECTIONS -section .g4kcodq code align=1 -%else -section .text -%endif -go4kVCO_gate: - fxch ; // p c - fstp st1 ; // p - fmul dword [c_16] ; // p' - push eax - push eax - fistp dword [esp] ; // - - fld1 ; // 1 - pop eax - and al, 0xf - bt word [VAL-5],ax - jc go4kVCO_gate_bit - fsub st0, st0 ; // 0 -go4kVCO_gate_bit: - fld dword [WRK+go4kVCO_wrk.cm] ; // 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] - pop eax - ret -%endif - -%ifdef USE_SECTIONS -section .g4kcodb code align=1 -%else -section .text -%endif -export_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 -%ifdef GO4K_USE_VCO_CHECK -; check if current note still active - mov eax, dword [ecx-4] - test eax, eax - jne go4kVCO_func_do -%ifdef GO4K_USE_VCO_STEREO - movzx eax, byte [VAL-1] ; // get flags and check for stereo - test al, byte VCO_STEREO - jz short go4kVCO_func_nostereoout - fldz -go4kVCO_func_nostereoout: -%endif - fldz - ret -go4kVCO_func_do: -%endif - movzx eax, byte [VAL-1] ; // get flags -%ifdef GO4K_USE_VCO_STEREO - test al, byte VCO_STEREO - jz short go4kVCO_func_nopswap - fld dword [WRK+go4kVCO_wrk.phase] ;// swap left/right phase values for first stereo run - fld dword [WRK+go4kVCO_wrk.phase2] - fstp dword [WRK+go4kVCO_wrk.phase] - fstp dword [WRK+go4kVCO_wrk.phase2] -go4kVCO_func_nopswap: -%endif -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] - fadd st0 -%ifdef GO4K_USE_VCO_STEREO - test al, byte VCO_STEREO - jz short go4kVCO_func_nodswap - fchs ;// negate detune for stereo -go4kVCO_func_nodswap: -%endif - faddp st1 -%ifdef GO4K_USE_VCO_MOD_DM - fadd dword [WRK+go4kVCO_wrk.dm] -%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 -go4kVCO_func_skipnote: - fmul dword [c_i12] - call _Power@0 - test al, byte LFO - jz short go4kVCO_func_normalize_note - fmul dword [_LFO_NORMALIZE] ; // st0 is now frequency for lfo - jmp short go4kVCO_func_normalized -go4kVCO_func_normalize_note: - fmul dword [FREQ_NORMALIZE] ; // st0 is now frequency -go4kVCO_func_normalized: - fadd dword [WRK+go4kVCO_wrk.phase] -%ifdef GO4K_USE_VCO_MOD_FM - fadd dword [WRK+go4kVCO_wrk.fm] -%endif - fld1 - fadd st1, st0 - fxch - 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 - fprem - 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 - call go4kVCO_sine -go4kVCO_func_trisaw: - test al, byte TRISAW - jz short go4kVCO_func_pulse - call go4kVCO_trisaw -go4kVCO_func_pulse: - test al, byte PULSE -%ifdef GO4K_USE_VCO_GATE - jz short go4kVCO_func_gate -%else - jz short go4kVCO_func_noise -%endif - call go4kVCO_pulse -%ifdef GO4K_USE_VCO_GATE -go4kVCO_func_gate: - test al, byte GATE - jz short go4kVCO_func_noise - call go4kVCO_gate -%endif -go4kVCO_func_noise: - test al, byte NOISE - jz short go4kVCO_func_end - call _FloatRandomNumber@0 - fstp st1 - fstp st1 -go4kVCO_func_end: + db %5 %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 + db %6 +%else %endif - fld dword [edx+go4kVCO_val.gain] -%ifdef GO4K_USE_VCO_MOD_GM - fadd dword [WRK+go4kVCO_wrk.gm] + db %7 + db %8 +%endmacro +%define TRANSPOSE(val) val +%define DETUNE(val) val +%define PHASE(val) val +%define GATES(val) val +%define COLOR(val) val +%define SHAPE(val) val +%define FLAGS(val) val +%define SINE 0x01 +%define TRISAW 0x02 +%define PULSE 0x04 +%define NOISE 0x08 +%define LFO 0x10 +%define GATE 0x20 +%define VCO_STEREO 0x40 +struc go4kVCO_val +;// unit paramters + .transpose resd 1 + .detune resd 1 +%ifdef GO4K_USE_VCO_PHASE_OFFSET + .phaseofs resd 1 +%endif +%ifdef GO4K_USE_VCO_GATE + .gate resd 1 +%endif + .color resd 1 +%ifdef GO4K_USE_VCO_SHAPE + .shape resd 1 %endif - fmulp st1, st0 - -%ifdef GO4K_USE_VCO_STEREO - test al, byte VCO_STEREO - jz short go4kVCO_func_stereodone - sub al, byte VCO_STEREO - fld dword [WRK+go4kVCO_wrk.phase] ;// swap left/right phase values again for second stereo run - fld dword [WRK+go4kVCO_wrk.phase2] - fstp dword [WRK+go4kVCO_wrk.phase] - fstp dword [WRK+go4kVCO_wrk.phase2] - jmp go4kVCO_func_process -go4kVCO_func_stereodone: + .gain resd 1 + .flags resd 1 + .size +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 + .size +endstruc +; //---------------------------------------------------------------------------------------- +; // VCF structs +; //---------------------------------------------------------------------------------------- +GO4K_VCF_ID equ 3 +%macro GO4K_VCF 3 + db %1 + db %2 + db %3 +%endmacro +%define LOWPASS 0x1 +%define HIGHPASS 0x2 +%define BANDPASS 0x4 +%define BANDSTOP 0x3 +%define ALLPASS 0x7 +%define PEAK 0x8 +%define STEREO 0x10 +%define FREQUENCY(val) val +%define RESONANCE(val) val +%define VCFTYPE(val) val +struc go4kVCF_val +;// unit paramters + .freq resd 1 + .res resd 1 + .type resd 1 + .size +endstruc +struc go4kVCF_wrk +;// work variables + .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 +;// stereo variables + .low2 resd 1 + .high2 resd 1 + .band2 resd 1 + .size +endstruc +; //---------------------------------------------------------------------------------------- +; // DST structs +; //---------------------------------------------------------------------------------------- +GO4K_DST_ID equ 4 +%macro GO4K_DST 3 + 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 +%endmacro +%define DRIVE(val) val +%define SNHFREQ(val) val +%define FLAGS(val) val +struc go4kDST_val +;// unit paramters + .drive resd 1 +%ifdef GO4K_USE_DST_SH + .snhfreq resd 1 +%endif + .flags resd 1 + .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 +endstruc +; //---------------------------------------------------------------------------------------- +; // DLL structs +; //---------------------------------------------------------------------------------------- +GO4K_DLL_ID equ 5 +%macro GO4K_DLL 8 + db %1 + db %2 + db %3 +%ifdef GO4K_USE_DLL_DAMP + db %4 %endif - ret - -%ifdef USE_SECTIONS -section .g4kcodc code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // VCF Tick -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -export_func go4kVCF_func@0 - push 3 - call go4kTransformValues -%ifdef GO4K_USE_VCF_CHECK -; check if current note still active - mov eax, dword [ecx-4] - test eax, eax - jne go4kVCF_func_do - ret -go4kVCF_func_do: -%endif - 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 - -%ifdef GO4K_USE_VCF_STEREO - test al, byte STEREO - jz short go4kVCF_func_process - add WRK, go4kVCF_wrk.low2 -go4kVCF_func_stereoloop: ; // switch channels - fxch st1 ; // inr inl -%endif - -go4kVCF_func_process: - fld dword [esp-8] - fld dword [esp-4] - fmul dword [WRK+go4kVCF_wrk.band] ; // f*b r in - fadd dword [WRK+go4kVCF_wrk.low] ; // l' r in - fst dword [WRK+go4kVCF_wrk.low] ; // l' r in - fsubp st2, st0 ; // r in-l' - fmul dword [WRK+go4kVCF_wrk.band] ; // r*b in-l' - fsubp st1, st0 ; // h' - fst dword [WRK+go4kVCF_wrk.high] ; // h' - fmul dword [esp-4] ; // h'*f - fadd dword [WRK+go4kVCF_wrk.band] ; // b' - fstp dword [WRK+go4kVCF_wrk.band] - fldz -go4kVCF_func_low: - test al, byte LOWPASS - jz short go4kVCF_func_high - fadd dword [WRK+go4kVCF_wrk.low] -go4kVCF_func_high: -%ifdef GO4K_USE_VCF_HIGH - test al, byte HIGHPASS - jz short go4kVCF_func_band - fadd dword [WRK+go4kVCF_wrk.high] -%endif -go4kVCF_func_band: -%ifdef GO4K_USE_VCF_BAND - test al, byte BANDPASS - jz short go4kVCF_func_peak - fadd dword [WRK+go4kVCF_wrk.band] -%endif -go4kVCF_func_peak: -%ifdef GO4K_USE_VCF_PEAK - test al, byte PEAK - jz short go4kVCF_func_processdone - fadd dword [WRK+go4kVCF_wrk.low] - fsub dword [WRK+go4kVCF_wrk.high] -%endif -go4kVCF_func_processdone: - -%ifdef GO4K_USE_VCF_STEREO - test al, byte STEREO ; // outr inl - jz short go4kVCF_func_end - sub al, byte STEREO - sub WRK, go4kVCF_wrk.low2 - jmp go4kVCF_func_stereoloop -%endif - -go4kVCF_func_end: ; // value - - - - - ret - -%ifdef USE_SECTIONS -section .g4kcodd code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // DST Tick -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -export_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 -%ifdef GO4K_USE_DST_CHECK -; check if current note still active - mov eax, dword [ecx-4] - test eax, eax - jne go4kDST_func_do - ret -go4kDST_func_do: -%endif - 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) - fst dword [WRK+go4kDST_wrk.snhphase] - fldz ; // 0 snh' in (inr) - fucomip st1 ; // snh' in (inr) - fstp dword [esp-4] ; // in (inr) - jc short go4kDST_func_hold - fld1 ; // 1 in (inr) - fadd dword [esp-4] ; // 1+snh' in (inr) - fstp dword [WRK+go4kDST_wrk.snhphase]; // in (inr) -%endif -; // calc pregain and postgain -%ifdef GO4K_USE_DST_STEREO - test al, byte STEREO - 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 -%endif - fxch st1 ; // inl outr -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) -%endif - ret ; // out' (outr) -%ifdef GO4K_USE_DST_SH -go4kDST_func_hold: ; // in (inr) - fstp st0 ; // (inr) -%ifdef GO4K_USE_DST_STEREO - test al, byte STEREO - jz short go4kDST_func_monohold ; // (inr) - fstp st0 ; // - fld dword [WRK+go4kDST_wrk.out2] ; // outr -go4kDST_func_monohold: -%endif - fld dword [WRK+go4kDST_wrk.out] ; // out (outr) - ret -%endif - -%endif - -%ifdef USE_SECTIONS -section .g4kcodf code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // DLL Tick -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -export_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 - pushad - movzx ebx, byte [VAL-(go4kDLL_val.size-go4kDLL_val.delay)/4] ;// delay length index -%ifdef GO4K_USE_DLL_NOTE_SYNC - test ebx, ebx - jne go4kDLL_func_process - fld1 - fild dword [ecx-4] ; // load note freq - fmul dword [c_i12] - call _Power@0 - fmul dword [FREQ_NORMALIZE] ; // normalize - fdivp st1, st0 ; // invert to get numer of samples - fistp word [_go4k_delay_times+ebx*2] ; store current comb size -%endif -go4kDLL_func_process: - mov ecx, eax ;// ecx is delay counter -%ifdef GO4K_USE_DLL_MOD - mov edi, WRK ;// edi is modulation workspace + db %5 + db %6 %endif - mov WRK, dword [_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] - fadd dword [WRK+go4kDLL_wrk.phase] ;// p' in' out -;// clamp phase to 0,1 (only in editor, since delay can be active quite long) -%ifdef GO4K_USE_DLL_CHORUS_CLAMP - fld1 ;// 1 p' in' out - fadd st1, st0 ;// 1 1+p' in' out - fxch ;// 1+p' 1 in' out - fprem ;// p'' 1 in' out - fstp st1 ;// p'' in' out + db %7 + db %8 +%endmacro +%define PREGAIN(val) val +%define DRY(val) val +%define FEEDBACK(val) val +%define DEPTH(val) val +%define DAMP(val) val +%define DELAY(val) val +%define COUNT(val) val +struc go4kDLL_val +;// unit paramters + .pregain resd 1 + .dry resd 1 + .feedback resd 1 +%ifdef GO4K_USE_DLL_DAMP + .damp resd 1 %endif - fst dword [WRK+go4kDLL_wrk.phase] -;// get current sine value - fldpi ; // pi p in' out - fadd st0 ; // 2*pi p in' out - fmulp st1, st0 ; // 2*pi*p in' out - fsin ; // sin in' out - fld1 ; // 1 sin in' out - 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 +%ifdef GO4K_USE_DLL_CHORUS + .freq resd 1 + .depth %endif - fmul st0, st0 - fmul st0, st0 - fmul dword [DLL_DEPTH] - fmulp st1, st0 - fistp dword [esp-4] ; // in' out -%endif - -go4kDLL_func_loop: - movzx esi, word [_go4k_delay_times+ebx*2] ; fetch comb size - mov eax, dword [WRK+go4kDLL_wrk.index] ;// eax is current comb index - -%ifdef GO4K_USE_DLL_CHORUS - ;// add lfo offset and wrap buffer - add eax, dword [esp-4] - cmp eax, esi - jl short go4kDLL_func_buffer_nowrap1 - sub eax, esi -go4kDLL_func_buffer_nowrap1: -%endif - - fld dword [WRK+eax*4+go4kDLL_wrk.buffer];// cout in' out - -%ifdef GO4K_USE_DLL_CHORUS - mov eax, dword [WRK+go4kDLL_wrk.index] -%endif - - ;// add comb output to current output - fadd st2, st0 ;// cout in' out' -%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' -%else - fsub st0, st1 ;// store in' out' - fstp dword [WRK+eax*4+go4kDLL_wrk.buffer];// in' out' - fneg -%endif - ;// wrap comb buffer pos - inc eax - cmp eax, esi - jl short go4kDLL_func_buffer_nowrap2 -%ifdef GO4K_USE_DLL_CHORUS - sub eax, esi -%else - xor eax, eax -%endif -go4kDLL_func_buffer_nowrap2: - mov dword [WRK+go4kDLL_wrk.index], eax - ;// increment buffer pointer to next buffer - inc ebx ;// go to next delay length index - add WRK, go4kDLL_wrk.size ;// go to next delay - mov dword [_go4k_delay_buffer_ofs], WRK ;// store next delay offset - loopne go4kDLL_func_loop - fstp st0 ;// out' - ;// process a dc filter to prevent heavy offsets in reverb -%ifdef GO4K_USE_DLL_DC_FILTER -; y(n) = x(n) - x(n-1) + R * y(n-1) - sub WRK, go4kDLL_wrk.size - fld dword [WRK+go4kDLL_wrk.dcout] ;// dco out' - fmul dword [c_dc_const] ;// dcc*dco out' - fsub dword [WRK+go4kDLL_wrk.dcin] ;// dcc*dco-dci out' - fxch ;// out' dcc*dco-dci - fst dword [WRK+go4kDLL_wrk.dcin] ;// out' dcc*dco-dci - faddp st1 ;// out' -%ifdef GO4K_USE_UNDENORMALIZE - fadd dword [c_0_5] ;// add and sub small offset to prevent denormalization - fsub dword [c_0_5] -%endif - fst dword [WRK+go4kDLL_wrk.dcout] -%endif - popad - ret -%endif - - -%ifdef USE_SECTIONS -section .g4kcodu code align=1 -%else -section .text -%endif + .delay resd 1 + .count resd 1 + .size +endstruc +struc go4kDLL_wrk +;// work variables + .index resd 1 + .store resd 1 + .dcin resd 1 + .dcout resd 1 + .phase resd 1 +;// the delay buffer + .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 ; //---------------------------------------------------------------------------------------- -; // GLITCH Tick +; // FOP structs ; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax +GO4K_FOP_ID equ 6 +%macro GO4K_FOP 1 + db %1 +%endmacro +%define OP(val) val +%define FOP_POP 0x1 +%define FOP_ADDP 0x2 +%define FOP_MULP 0x3 +%define FOP_PUSH 0x4 +%define FOP_XCH 0x5 +%define FOP_ADD 0x6 +%define FOP_MUL 0x7 +%define FOP_ADDP2 0x8 +%define FOP_LOADNOTE 0x9 +%define FOP_MULP2 0xa +struc go4kFOP_val + .flags resd 1 + .size +endstruc +struc go4kFOP_wrk + .size +endstruc ; //---------------------------------------------------------------------------------------- -export_func go4kGLITCH_func@0 -%ifdef GO4K_USE_GLITCH - push 5 - call go4kTransformValues - pushad - - mov edi, WRK - mov WRK, dword [_go4k_delay_buffer_ofs] ;// ebp is current delay - -; mov eax, dword [edx+go4kGLITCH_val.active] -; or eax, dword [edi+go4kGLITCH_wrk2.am] -; test eax, eax -; 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 - fstp st0 ;// in - jnc go4kGLITCH_func_notactive ;// out - - ;// check for first call and init if so init (using slizesize slot) - mov eax, dword [WRK+go4kGLITCH_wrk.slizesize] - and eax, eax - jnz go4kGLITCH_func_process - mov dword [WRK+go4kGLITCH_wrk.index], eax - mov dword [WRK+go4kGLITCH_wrk.store], eax - movzx ebx, byte [VAL-(go4kGLITCH_val.size-go4kGLITCH_val.slicesize)/4] ;// slicesize index - movzx eax, word [_go4k_delay_times+ebx*2] ;// fetch slicesize - push eax - fld1 - fild dword [esp] - fstp dword [WRK+go4kGLITCH_wrk.slizesize] - fstp dword [WRK+go4kGLITCH_wrk.slicepitch] - pop eax -go4kGLITCH_func_process: - ;// fill buffer until full - mov eax, dword [WRK+go4kGLITCH_wrk.store] - cmp eax, MAX_DELAY - jae go4kGLITCH_func_filldone - fst dword [WRK+eax*4+go4kDLL_wrk.buffer] ;// in - inc dword [WRK+go4kGLITCH_wrk.store] -go4kGLITCH_func_filldone: - ;// save input - push eax - fstp dword [esp] ;// - - - ;// read from buffer - push eax - fld dword [WRK+go4kGLITCH_wrk.index] ;// idx - fist dword [esp] - pop eax - fld dword [WRK+eax*4+go4kDLL_wrk.buffer] ;// out idx - fxch ;// idx out - ;// progress readindex with current play speed - fadd dword [WRK+go4kGLITCH_wrk.slicepitch] ;// idx' out - fst dword [WRK+go4kGLITCH_wrk.index] - - ;// check for slice done - fld dword [WRK+go4kGLITCH_wrk.slizesize] ;// size idx' out - fxch ;// idx' size out - fucomip st1 ;// idx' out - fstp st0 ;// out - jc go4kGLITCH_func_process_done - ;// reinit for next loop - xor eax, eax - 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 _Power@0 - fmul dword [WRK+go4kGLITCH_wrk.slizesize] - 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 _Power@0 - fmul dword [WRK+go4kGLITCH_wrk.slicepitch] - fstp dword [WRK+go4kGLITCH_wrk.slicepitch] -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' - fmul dword [esp] ;// in' out' - faddp st1, st0 ;// out' - - pop eax - jmp go4kGLITCH_func_leave -go4kGLITCH_func_notactive: - ;// mark as uninitialized again (using slizesize slot) - xor eax,eax - mov dword [WRK+go4kGLITCH_wrk.slizesize], eax -go4kGLITCH_func_leave: - add WRK, go4kDLL_wrk.size ;// go to next delay - mov dword [_go4k_delay_buffer_ofs], WRK ;// store next delay offset - popad - ret -%endif - -%ifdef USE_SECTIONS -section .g4kcodg code align=1 -%else -section .text -%endif +; // FST structs ; //---------------------------------------------------------------------------------------- -; // FOP Tick (various fp stack based operations) +GO4K_FST_ID equ 7 +%macro GO4K_FST 2 + db %1 + dw %2 +%endmacro +%define AMOUNT(val) val +%define DEST(val) val +%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 + .size +endstruc ; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : +; // PAN structs ; //---------------------------------------------------------------------------------------- -export_func go4kFOP_func@0 - push 1 - call go4kTransformValues -go4kFOP_func_pop: - dec eax - jnz go4kFOP_func_addp - fstp st0 - ret -go4kFOP_func_addp: - dec eax - jnz go4kFOP_func_mulp - faddp st1, st0 - ret -go4kFOP_func_mulp: - dec eax - jnz go4kFOP_func_push - fmulp st1, st0 - ret -go4kFOP_func_push: - dec eax - jnz go4kFOP_func_xch - fld st0 - ret -go4kFOP_func_xch: - dec eax - jnz go4kFOP_func_add - fxch - ret -go4kFOP_func_add: - dec eax - jnz go4kFOP_func_mul - fadd st1 - ret -go4kFOP_func_mul: - dec eax - jnz go4kFOP_func_addp2 - fmul st1 - ret -go4kFOP_func_addp2: - dec eax - jnz go4kFOP_func_loadnote - faddp st2, st0 - faddp st2, st0 - ret -go4kFOP_func_loadnote: - dec eax - jnz go4kFOP_func_mulp2 - fild dword [ecx-4] - fmul dword [c_i128] - ret -go4kFOP_func_mulp2: - fmulp st2, st0 - fmulp st2, st0 - ret - -%ifdef USE_SECTIONS -section .g4kcodh code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // FST Tick (stores a value somewhere in the local workspace) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -export_func go4kFST_func@0 - push 1 - call go4kTransformValues - fld dword [edx+go4kFST_val.amount] - fsub dword [c_0_5] - fadd st0 - fmul st1 - lodsw - and eax, 0x00003fff ; // eax is destination slot - test word [VAL-2], FST_ADD - jz go4kFST_func_set - fadd dword [ecx+eax*4] -go4kFST_func_set: - fstp dword [ecx+eax*4] - test word [VAL-2], FST_POP - jz go4kFST_func_done - fstp st0 -go4kFST_func_done: - ret - -%ifdef USE_SECTIONS -section .g4kcodm code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // FLD Tick (load a value on stack, optionally add a modulation signal beforehand) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : signal-signal*pan , signal*pan -; // DIRTY : -; //---------------------------------------------------------------------------------------- -export_func go4kFLD_func@0 ;// in main env -%ifdef GO4K_USE_FLD - push 1 - call go4kTransformValues - 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 - -%ifdef GO4K_USE_FSTG -%ifdef USE_SECTIONS -section .g4kcodi code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // FSTG Tick (stores a value anywhere in the synth (and in each voice)) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -export_func go4kFSTG_func@0 - push 1 - call go4kTransformValues -%ifdef GO4K_USE_FSTG_CHECK -; check if current note still active - mov eax, dword [ecx-4] - test eax, eax - jne go4kFSTG_func_do - lodsw - jmp go4kFSTG_func_testpop -go4kFSTG_func_do: -%endif - fld dword [edx+go4kFST_val.amount] - fsub dword [c_0_5] - fadd st0 - fmul st1 - lodsw - and eax, 0x00003fff ; // eax is destination slot - test word [VAL-2], FST_ADD - jz go4kFSTG_func_set - fadd dword [go4k_synth_wrk+eax*4] -go4kFSTG_func_set: -%if MAX_VOICES > 1 - fst dword [go4k_synth_wrk+eax*4] - fstp dword [go4k_synth_wrk+eax*4+go4k_instrument.size] -%else - fstp dword [go4k_synth_wrk+eax*4] -%endif -go4kFSTG_func_testpop: - test word [VAL-2], FST_POP - jz go4kFSTG_func_done - fstp st0 -go4kFSTG_func_done: - ret -%endif - -%ifdef USE_SECTIONS -section .g4kcodj code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // PAN Tick (multiplies signal with main envelope and converts to stereo) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : signal-signal*pan , signal*pan -; // DIRTY : -; //---------------------------------------------------------------------------------------- -export_func go4kPAN_func@0 ;// in main env +GO4K_PAN_ID equ 8 +%macro GO4K_PAN 1 %ifdef GO4K_USE_PAN - push 1 - call go4kTransformValues - fld dword [edx+go4kPAN_val.panning] ;// pan in -%ifdef GO4K_USE_PAN_MOD - fadd dword [WRK+go4kPAN_wrk.pm] ;// pan in + db %1 %endif - fmul st1 ;// r in - fsub st1, st0 ;// r l - fxch ;// l r -%else - fmul dword [c_0_5] - fld st0 +%endmacro +%define PANNING(val) val +struc go4kPAN_val +%ifdef GO4K_USE_PAN + .panning resd 1 +%endif + .size +endstruc +struc go4kPAN_wrk +;// modulation targets + .pm resd 1 + .size +endstruc +; //---------------------------------------------------------------------------------------- +; // OUT structs +; //---------------------------------------------------------------------------------------- +GO4K_OUT_ID equ 9 +%macro GO4K_OUT 2 + db %1 +%ifdef GO4K_USE_GLOBAL_DLL + db %2 %endif - ret +%endmacro +%define AUXSEND(val) val +struc go4kOUT_val + .gain resd 1 +%ifdef GO4K_USE_GLOBAL_DLL + .auxsend resd 1 +%endif + .size +endstruc +struc go4kOUT_wrk +;// modulation targets + .am resd 1 + .gm resd 1 + .size +endstruc +; //---------------------------------------------------------------------------------------- +; // ACC structs (this is for the synth def only) +; //---------------------------------------------------------------------------------------- +GO4K_ACC_ID equ 10 +%macro GO4K_ACC 1 + db %1 +%endmacro +%define OUTPUT 0 +%define AUX 8 +%define ACCTYPE(val) val +struc go4kACC_val + .acctype resd 1 + .size +endstruc +struc go4kACC_wrk + .size +endstruc +%ifdef GO4K_USE_FLD +; //---------------------------------------------------------------------------------------- +; // FLD structs +; //---------------------------------------------------------------------------------------- +GO4K_FLD_ID equ 11 +%macro GO4K_FLD 1 + db %1 +%endmacro +%define VALUE(val) val +struc go4kFLD_val + .value resd 1 + .size +endstruc +struc go4kFLD_wrk +;// modulation targets + .vm resd 1 + .size +endstruc +%endif +%ifdef GO4K_USE_GLITCH +; //---------------------------------------------------------------------------------------- +; // GLITCH structs +; //---------------------------------------------------------------------------------------- +GO4K_GLITCH_ID equ 12 +%macro GO4K_GLITCH 5 + db %1 + db %2 + db %3 + db %4 + db %5 +%endmacro +%define ACTIVE(val) val +%define SLICEFACTOR(val)val +%define PITCHFACTOR(val)val +%define SLICESIZE(val) val +struc go4kGLITCH_val +;// unit paramters + .active resd 1 + .dry resd 1 + .dsize resd 1 + .dpitch resd 1 + .slicesize resd 1 + .size +endstruc +struc go4kGLITCH_wrk +;// work variables + .index resd 1 + .store resd 1 + .slizesize resd 1 + .slicepitch resd 1 + .unused resd 1 +;// the delay buffer + .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 +; //---------------------------------------------------------------------------------------- +; // FSTG structs +; //---------------------------------------------------------------------------------------- +%ifdef GO4K_USE_GLITCH +GO4K_FSTG_ID equ 13 +%else +GO4K_FSTG_ID equ 12 +%endif +%macro GO4K_FSTG 2 + db %1 + dw %2 +%endmacro +struc go4kFSTG_val + .amount resd 1 + .op1 resd 1 + .size +endstruc +struc go4kFSTG_wrk + .size +endstruc +%endif +; //---------------------------------------------------------------------------------------- +; // Voice struct +; //---------------------------------------------------------------------------------------- +struc go4k_instrument + .release resd 1 + .note resd 1 + .workspace resd MAX_UNITS*MAX_UNIT_SLOTS + .dlloutl resd 1 + .dlloutr resd 1 + .outl resd 1 + .outr resd 1 + .size +endstruc +; //---------------------------------------------------------------------------------------- +; // Synth struct +; //---------------------------------------------------------------------------------------- +struc go4k_synth + .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES + .global resb go4k_instrument.size * MAX_VOICES + .size +endstruc -%ifdef USE_SECTIONS -section .g4kcodk code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // OUT Tick ( stores stereo signal pair in temp buffers of the instrument) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -export_func go4kOUT_func@0 ;// l r -%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+0] ;// 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+4] ;// - - -%endif - ret - -%ifdef USE_SECTIONS -section .g4kcodl code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // ACC Tick (stereo signal accumulation for synth commands only -> dont use in instrument commands) -; //---------------------------------------------------------------------------------------- -; // IN : WRK = unit workspace -; // IN : VAL = unit values -; // IN : ecx = global workspace -; // OUT : -; // DIRTY : eax -; //---------------------------------------------------------------------------------------- -export_func go4kACC_func@0 - push 1 - call go4kTransformValues - pushad - mov edi, go4k_synth_wrk - add edi, go4k_instrument.size - sub edi, eax ; // eax already contains the accumulation offset from the go4kTransformValues call - mov cl, MAX_INSTRUMENTS*MAX_VOICES - fldz ;// 0 - fldz ;// 0 0 -go4kACC_func_loop: - fadd dword [edi-8] ;// l 0 - fxch ;// 0 l - fadd dword [edi-4] ;// r l - fxch ;// l r - add edi, go4k_instrument.size - dec cl - jnz go4kACC_func_loop - popad - ret - -%ifdef USE_SECTIONS -section .g4kcodw code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // Update Instrument (allocate voices, set voice to release) -; //---------------------------------------------------------------------------------------- -; // IN : -; // IN : -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -go4kUpdateInstrument: -; // get new note - mov eax, dword [esp+4+4] ; // eax = current tick - shr eax, PATTERN_SIZE_SHIFT ; // eax = current pattern - imul edx, ecx, dword MAX_PATTERNS ; // edx = instrument pattern list index - movzx edx, byte [edx+eax+go4k_pattern_lists] ; // edx = pattern index - mov eax, dword [esp+4+4] ; // eax = current tick - shl edx, PATTERN_SIZE_SHIFT - and eax, PATTERN_SIZE-1 - movzx edx, byte [edx+eax+go4k_patterns] ; // edx = requested note in new patterntick -; // apply note changes - cmp dl, HLD ; // anything but hold causes action - je short go4kUpdateInstrument_done - inc dword [edi] ; // set release flag if needed -%if MAX_VOICES > 1 - inc dword [edi+go4k_instrument.size] ; // set release flag if needed -%endif - cmp dl, HLD ; // check for new note - jl short go4kUpdateInstrument_done -%if MAX_VOICES > 1 - pushad - xchg eax, dword [go4k_voiceindex + ecx*4] - test eax, eax - je go4kUpdateInstrument_newNote - add edi, go4k_instrument.size -go4kUpdateInstrument_newNote: - xor al,1 - xchg dword [go4k_voiceindex + ecx*4], eax -%endif - pushad - xor eax, eax - mov ecx, (8+MAX_UNITS*MAX_UNIT_SLOTS*4)/4 ; // clear only relase, note and workspace - rep stosd - popad - mov dword [edi+4], edx ; // set requested note as current note -%if MAX_VOICES > 1 - popad -%endif - jmp short go4kUpdateInstrument_done -go4kUpdateInstrument_done: - ret - -%ifdef USE_SECTIONS -section .g4kcodx code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // Render Voices -; //---------------------------------------------------------------------------------------- -; // IN : -; // IN : -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -go4kRenderVoices: - push ecx ; // save current instrument counter -%if MAX_VOICES > 1 - push COM ; // save current instrument command index - push VAL ; // save current instrument values index -%endif - call go4k_VM_process ; // call synth vm for instrument voices - mov eax, dword [ecx+go4kENV_wrk.state] - cmp al, byte ENV_STATE_OFF - jne go4kRenderVoices_next - xor eax, eax - mov dword [ecx-4], eax ; // kill note if voice is done -go4kRenderVoices_next: -%if MAX_VOICES > 1 - pop VAL ; // restore instrument value index - pop COM ; // restore instrument command index -%endif - -%ifdef GO4K_USE_BUFFER_RECORDINGS - mov eax, dword [esp+16] ; // get current tick - shr eax, 8 ; // every 256th sample = ~ 172 hz - shl eax, 5 ; // for 16 instruments a 2 voices - add eax, dword [esp] - add eax, dword [esp] ; // + 2*currentinstrument+0 -%ifdef GO4K_USE_ENVELOPE_RECORDINGS - mov edx, dword [ecx+go4kENV_wrk.level] - mov dword [__4klang_envelope_buffer+eax*4], edx -%endif -%ifdef GO4K_USE_NOTE_RECORDINGS - mov edx, dword [ecx-4] - mov dword [__4klang_note_buffer+eax*4], edx -%endif -%endif - -%if MAX_VOICES > 1 - call go4k_VM_process ; // call synth vm for instrument voices - mov eax, dword [ecx+go4kENV_wrk.state] - cmp al, byte ENV_STATE_OFF - jne go4k_render_instrument_next2 - xor eax, eax - mov dword [ecx-4], eax ; // kill note if voice is done -go4k_render_instrument_next2: - -%ifdef GO4K_USE_BUFFER_RECORDINGS - mov eax, dword [esp+16] ; // get current tick - shr eax, 8 ; // every 256th sample = ~ 172 hz - shl eax, 5 ; // for 16 instruments a 2 voices - add eax, dword [esp] - add eax, dword [esp] ; // + 2*currentinstrument+0 -%ifdef GO4K_USE_ENVELOPE_RECORDINGS - mov edx, dword [ecx+go4kENV_wrk.level] - mov dword [__4klang_envelope_buffer+eax*4+4], edx -%endif -%ifdef GO4K_USE_NOTE_RECORDINGS - mov edx, dword [ecx-4] - mov dword [__4klang_note_buffer+eax*4+4], edx -%endif -%endif - -%endif - pop ecx ; // restore instrument counter - ret - -%ifdef USE_SECTIONS -section .g4kcody code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // the entry point for the synth -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -export_func _4klang_render@4 -%else -export_func _4klang_render -%endif - pushad - xor ecx, ecx -%ifdef GO4K_USE_BUFFER_RECORDINGS - push ecx -%endif -; loop all ticks -go4k_render_tickloop: - push ecx - xor ecx, ecx -; loop all samples per tick -go4k_render_sampleloop: - push ecx - xor ecx, ecx - mov ebx, go4k_synth_instructions ; // ebx = instrument command index - mov VAL, go4k_synth_parameter_values; // VAL = instrument values index - mov edi, _go4k_delay_buffer ; // get offset of first delay buffer - mov dword [_go4k_delay_buffer_ofs], edi ; // store offset in delaybuffer offset variable - mov edi, go4k_synth_wrk ; // edi = first instrument -; loop all instruments -go4k_render_instrumentloop: - mov eax, dword [esp] ; // eax = current tick sample - and eax, eax - jnz go4k_render_instrument_process ; // tick change? (first sample in current tick) - call go4kUpdateInstrument ; // update instrument state -; process instrument -go4k_render_instrument_process: - call go4kRenderVoices - inc ecx - cmp cl, byte MAX_INSTRUMENTS - jl go4k_render_instrumentloop - mov dword [edi+4], ecx ; // move a value != 0 into note slot, so processing will be done - call go4k_VM_process ; // call synth vm for synth -go4k_render_output_sample: -%ifdef GO4K_USE_BUFFER_RECORDINGS - inc dword [esp+8] - xchg esi, dword [esp+48] ; // edx = destbuffer -%else - xchg esi, dword [esp+44] ; // edx = destbuffer -%endif -%ifdef GO4K_CLIP_OUTPUT - fld dword [edi-8] - fld1 ; // 1 val - fucomi st1 ; // 1 val - jbe short go4k_render_clip1 - fchs ; // -1 val - fucomi st1 ; // -1 val - fcmovb st0, st1 ; // val -1 (if val > -1) -go4k_render_clip1: - fstp st1 ; // newval -%ifdef GO4K_USE_16BIT_OUTPUT - push eax - fmul dword [c_32767] - fistp dword [esp] - pop eax - mov word [esi],ax ; // store integer converted left sample - lodsw -%else - fstp dword [esi] ; // store left sample - lodsd -%endif - fld dword [edi-4] - fld1 ; // 1 val - fucomi st1 ; // 1 val - jbe short go4k_render_clip2 - fchs ; // -1 val - fucomi st1 ; // -1 val - fcmovb st0, st1 ; // val -1 (if val > -1) -go4k_render_clip2: - fstp st1 ; // newval -%ifdef GO4K_USE_16BIT_OUTPUT - push eax - fmul dword [c_32767] - fistp dword [esp] - pop eax - mov word [esi],ax ; // store integer converted right sample - lodsw -%else - fstp dword [esi] ; // store right sample - lodsd -%endif -%else - fld dword [edi-8] -%ifdef GO4K_USE_16BIT_OUTPUT - push eax - fmul dword [c_32767] - fistp dword [esp] - pop eax - mov word [esi],ax ; // store integer converted left sample - lodsw -%else - fstp dword [esi] ; // store left sample - lodsd -%endif - fld dword [edi-4] -%ifdef GO4K_USE_16BIT_OUTPUT - push eax - fmul dword [c_32767] - fistp dword [esp] - pop eax - mov word [esi],ax ; // store integer converted right sample - lodsw -%else - fstp dword [esi] ; // store right sample - lodsd -%endif -%endif -%ifdef GO4K_USE_BUFFER_RECORDINGS - xchg esi, dword [esp+48] -%else - xchg esi, dword [esp+44] -%endif - pop ecx - inc ecx -%ifdef GO4K_USE_GROOVE_PATTERN - mov ebx, dword SAMPLES_PER_TICK - mov eax, dword [esp] - and eax, 0x0f - bt dword [go4k_groove_pattern],eax - jnc go4k_render_nogroove - sub ebx, dword 3000 -go4k_render_nogroove: - cmp ecx, ebx -%else - cmp ecx, dword SAMPLES_PER_TICK -%endif - jl go4k_render_sampleloop - pop ecx - inc ecx -%ifdef AUTHORING - mov dword[__4klang_current_tick], ecx -%endif - cmp ecx, dword MAX_TICKS - jl go4k_render_tickloop -%ifdef GO4K_USE_BUFFER_RECORDINGS - pop ecx -%endif - popad - ret 4 - -%ifdef USE_SECTIONS -section .g4kcodz code align=1 -%else -section .text -%endif -; //---------------------------------------------------------------------------------------- -; // the magic behind it :) -; //---------------------------------------------------------------------------------------- -; // IN : edi = instrument pointer -; // IN : esi = instrumet values -; // IN : ebx = instrument instructions -; // OUT : -; // DIRTY : -; //---------------------------------------------------------------------------------------- -go4k_VM_process: - lea WRK, [edi+8] ; // get current workspace pointer - mov ecx, WRK ; // ecx = workspace start -go4k_VM_process_loop: - movzx eax, byte [ebx] ; // get command byte - inc ebx - test eax, eax - je go4k_VM_process_done ; // command byte = 0? so done - call dword [eax*4+go4k_synth_commands] - add WRK, MAX_UNIT_SLOTS*4 ; // go to next workspace slot - jmp short go4k_VM_process_loop -go4k_VM_process_done: - add edi, go4k_instrument.size ; // go to next instrument voice - ret \ No newline at end of file +%endif ; _4KLANG_INC \ No newline at end of file diff --git a/src/vsti/4klang.asm b/src/vsti/4klang.asm index 8f09333..0749f2b 100644 --- a/src/vsti/4klang.asm +++ b/src/vsti/4klang.asm @@ -1,578 +1,73 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -;%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 9 %define MAX_VOICES 1 %define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 62 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units +%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output +%define GO4K_USE_DST ; // removing this will skip DST unit +%define GO4K_USE_DLL ; // removing this will skip DLL unit +%define GO4K_USE_PAN ; // removing this will skip PAN unit +%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_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 +%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping +%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc ; //---------------------------------------------------------------------------------------- ; // Pattern Data, reduced by 967 patterns ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, db 76, HLD, HLD, HLD, 0, 0, 0, 0, 79, HLD, HLD, HLD, 0, 0, 0, 0, db 69, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, @@ -619,12 +114,9 @@ go4k_patterns_end ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 1, 2, 3, 0, 4, 5, 6, 7, 8, 2, 9, 0, 0, 0, Instrument1List db 9, 7, 10, 7, 11, 7, 12, 7, 9, 7, 10, 7, 11, 7, 12, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 7, 13, 7, 14, 7, 3, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 7, 0, 0, Instrument2List db 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 16, 0, 17, 0, 18, 0, 20, 20, 21, 21, 22, 22, 20, 20, 20, 20, 21, 21, 22, 22, 20, 20, 23, 15, 24, 16, 25, 17, 18, 0, 20, 20, 21, 21, 22, 22, 20, 20, 20, 20, 21, 21, 22, 22, 20, 20, 20, 20, 0, 0, 0, 0, @@ -638,12 +130,9 @@ go4k_pattern_lists_end ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_FST_ID @@ -792,12 +281,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +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) @@ -946,14 +432,9 @@ go4k_synth_parameter_values_end ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 1116 dw 1188 @@ -973,7 +454,4 @@ _go4k_delay_times dw 1642 dw 22050 ; Originally times 100 dw 0, but crashes for me (Peter) - so reverted to this found in an older version dw 16537 - dw 11025 -%endif - -%include "../4klang.inc" + dw 11025 \ No newline at end of file diff --git a/tests/test_dll.asm b/tests/test_dll.asm index eff874e..1f5b680 100644 --- a/tests/test_dll.asm +++ b/tests/test_dll.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_DLL +%define GO4K_USE_DLL_DAMP +%define GO4K_USE_DLL_DC_FILTER + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +45,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -631,25 +65,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_am_modulation.asm b/tests/test_dll_am_modulation.asm index f52e1fa..6ad89c8 100644 --- a/tests/test_dll_am_modulation.asm +++ b/tests/test_dll_am_modulation.asm @@ -1,600 +1,44 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%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 +%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -614,12 +58,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -635,25 +76,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_chorus.asm b/tests/test_dll_chorus.asm index 608f710..c6a8087 100644 --- a/tests/test_dll_chorus.asm +++ b/tests/test_dll_chorus.asm @@ -1,600 +1,38 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_DLL +%define GO4K_USE_DLL_DAMP +%define GO4K_USE_DLL_CHORUS +%define GO4K_USE_DLL_DC_FILTER -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -612,12 +50,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -631,7 +66,7 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- @@ -646,10 +81,10 @@ _go4k_delay_times dw 0 dw 11025 %endif +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_dm_modulation.asm b/tests/test_dll_dm_modulation.asm index 08964fe..c4e60de 100644 --- a/tests/test_dll_dm_modulation.asm +++ b/tests/test_dll_dm_modulation.asm @@ -1,600 +1,44 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%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 +%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -614,12 +58,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -635,25 +76,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_fm_modulation.asm b/tests/test_dll_fm_modulation.asm index 7602645..a581615 100644 --- a/tests/test_dll_fm_modulation.asm +++ b/tests/test_dll_fm_modulation.asm @@ -1,600 +1,42 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%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 +%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -614,12 +56,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -635,25 +74,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_im_modulation.asm b/tests/test_dll_im_modulation.asm index 5de0d85..c78a094 100644 --- a/tests/test_dll_im_modulation.asm +++ b/tests/test_dll_im_modulation.asm @@ -1,600 +1,44 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%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 +%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -614,12 +58,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -635,25 +76,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_notetracking.asm b/tests/test_dll_notetracking.asm index 35335ce..32ec463 100644 --- a/tests/test_dll_notetracking.asm +++ b/tests/test_dll_notetracking.asm @@ -1,600 +1,44 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_DLL +%define GO4K_USE_DLL_DAMP +%define GO4K_USE_DLL_NOTE_SYNC +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_DLL_DC_FILTER +%define GO4K_CLIP_OUTPUT ; the original expected data was clipping, and this was on +%define GO4K_USE_VCF_BAND +%define GO4K_USE_VCF_HIGH +%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units +%define GO4K_USE_DLL_CHORUS ; // removing this will skip delay chorus/flanger code -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -616,12 +60,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(0),DECAY(0),SUSTAIN(96),RELEASE(96),GAIN(128) GO4K_ENV ATTAC(0),DECAY(48),SUSTAIN(0),RELEASE(0),GAIN(128) @@ -639,24 +80,19 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_pm_modulation.asm b/tests/test_dll_pm_modulation.asm index cf590c9..bee9f99 100644 --- a/tests/test_dll_pm_modulation.asm +++ b/tests/test_dll_pm_modulation.asm @@ -1,600 +1,43 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%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 -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -614,12 +57,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -635,25 +75,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_reverb.asm b/tests/test_dll_reverb.asm index 06554ab..6b1bad3 100644 --- a/tests/test_dll_reverb.asm +++ b/tests/test_dll_reverb.asm @@ -1,600 +1,38 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_DLL +%define GO4K_USE_DLL_DAMP +%define GO4K_USE_DLL_DC_FILTER -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +%include "../src/4klang.asm" + +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -612,12 +50,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -631,18 +66,13 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 1116 dw 1188 @@ -652,11 +82,11 @@ _go4k_delay_times dw 1492 dw 1556 dw 1618 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_dll_sm_modulation.asm b/tests/test_dll_sm_modulation.asm index 83b5df4..de4d82a 100644 --- a/tests/test_dll_sm_modulation.asm +++ b/tests/test_dll_sm_modulation.asm @@ -1,600 +1,44 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%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 +%define GO4K_USE_VCO_CHECK ; // removing this skips checks if processing is needed -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -610,16 +54,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -639,21 +80,16 @@ go4k_synth_parameter_values_end ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 dw 11025 -%endif -section .data +; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_dst.asm b/tests/test_dst.asm index 4a8c42d..a94dbbf 100644 --- a/tests/test_dst.asm +++ b/tests/test_dst.asm @@ -1,600 +1,34 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_DST + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_DST_ID @@ -611,12 +45,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_DST DRIVE(32), SNHFREQ(128), FLAGS(0) @@ -629,24 +60,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_dst_modulation.asm b/tests/test_dst_modulation.asm index 3bfeac5..b5acea6 100644 --- a/tests/test_dst_modulation.asm +++ b/tests/test_dst_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%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 + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_DST_ID @@ -614,12 +51,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_DST DRIVE(32), SNHFREQ(128), FLAGS(0) @@ -635,24 +69,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_dst_sh.asm b/tests/test_dst_sh.asm index 5d97350..7240c47 100644 --- a/tests/test_dst_sh.asm +++ b/tests/test_dst_sh.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_DST +%define GO4K_USE_DST_SH +%define GO4K_USE_DST_CHECK + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_DST_ID @@ -611,12 +47,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_DST DRIVE(64), SNHFREQ(3), FLAGS(0) @@ -629,24 +62,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_dst_sh_modulation.asm b/tests/test_dst_sh_modulation.asm index e0de0bb..7da4485 100644 --- a/tests/test_dst_sh_modulation.asm +++ b/tests/test_dst_sh_modulation.asm @@ -1,600 +1,39 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%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 + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_DST_ID @@ -614,12 +53,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_DST DRIVE(64), SNHFREQ(3), FLAGS(0) @@ -635,24 +71,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_dst_stereo.asm b/tests/test_dst_stereo.asm index fec5c18..f6af7ce 100644 --- a/tests/test_dst_stereo.asm +++ b/tests/test_dst_stereo.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_DST +%define GO4K_USE_DST_STEREO + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -610,12 +45,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) @@ -627,24 +59,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_envelope.asm b/tests/test_envelope.asm index 6fac247..c493cc1 100644 --- a/tests/test_envelope.asm +++ b/tests/test_envelope.asm @@ -1,600 +1,34 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS + +%include "../src/4klang.asm" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) + GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -605,16 +39,14 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) + GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_ENV ATTAC(95),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) @@ -625,24 +57,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_envelope_modulation.asm b/tests/test_envelope_modulation.asm index 54ea34e..84f267d 100644 --- a/tests/test_envelope_modulation.asm +++ b/tests/test_envelope_modulation.asm @@ -1,600 +1,38 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%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" ; //---------------------------------------------------------------------------------------- -; // synth defines +; // Pattern Data ; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD,HLD, HLD, HLD, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -610,16 +48,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) 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) @@ -637,23 +72,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) + +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES + + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 -%endif - -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" + dw 11025 \ No newline at end of file diff --git a/tests/test_fop_add.asm b/tests/test_fop_add.asm index d7d2e7f..8699065 100644 --- a/tests/test_fop_add.asm +++ b/tests/test_fop_add.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -610,12 +43,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(32) GO4K_FLD VALUE(128) @@ -627,24 +57,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_addp.asm b/tests/test_fop_addp.asm index 694efd7..ff07a95 100644 --- a/tests/test_fop_addp.asm +++ b/tests/test_fop_addp.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -609,16 +42,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(48) GO4K_FLD VALUE(48) @@ -633,24 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_addp2.asm b/tests/test_fop_addp2.asm index e631646..f353639 100644 --- a/tests/test_fop_addp2.asm +++ b/tests/test_fop_addp2.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -608,16 +41,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(0) GO4K_FLD VALUE(64) @@ -631,24 +61,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_loadnote.asm b/tests/test_fop_loadnote.asm index aeeba16..1cbac24 100644 --- a/tests/test_fop_loadnote.asm +++ b/tests/test_fop_loadnote.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FOP_ID db GO4K_FOP_ID @@ -605,16 +38,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FOP OP(FOP_LOADNOTE) GO4K_FOP OP(FOP_LOADNOTE) @@ -625,24 +55,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_mul.asm b/tests/test_fop_mul.asm index 63c2404..3f66901 100644 --- a/tests/test_fop_mul.asm +++ b/tests/test_fop_mul.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -606,16 +39,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(32) GO4K_FLD VALUE(0) @@ -627,24 +57,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_mulp.asm b/tests/test_fop_mulp.asm index 137370b..387dcbc 100644 --- a/tests/test_fop_mulp.asm +++ b/tests/test_fop_mulp.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -609,16 +42,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(96) GO4K_FLD VALUE(0) @@ -633,24 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_mulp2.asm b/tests/test_fop_mulp2.asm index 9ab33b0..22f44d4 100644 --- a/tests/test_fop_mulp2.asm +++ b/tests/test_fop_mulp2.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -608,16 +41,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(96) GO4K_FLD VALUE(128) @@ -631,24 +61,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_pop.asm b/tests/test_fop_pop.asm index 4c77fc1..d83a784 100644 --- a/tests/test_fop_pop.asm +++ b/tests/test_fop_pop.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -607,16 +40,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(32) GO4K_FLD VALUE(96) @@ -629,24 +59,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_push.asm b/tests/test_fop_push.asm index 2b6525d..01cf836 100644 --- a/tests/test_fop_push.asm +++ b/tests/test_fop_push.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -607,16 +40,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(32) GO4K_FLD VALUE(96) @@ -629,24 +59,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_fop_xch.asm b/tests/test_fop_xch.asm index 64e2988..f53f4de 100644 --- a/tests/test_fop_xch.asm +++ b/tests/test_fop_xch.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -606,16 +39,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(96) GO4K_FLD VALUE(32) @@ -627,24 +57,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_globalstore.asm b/tests/test_globalstore.asm index e2a4e12..5caab82 100644 --- a/tests/test_globalstore.asm +++ b/tests/test_globalstore.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%define GO4K_USE_FLD_MOD_VM +%define GO4K_USE_FSTG -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FSTG_ID @@ -611,16 +47,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_FOP_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +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) @@ -637,24 +70,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_FOP OP(FOP_ADDP) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_load.asm b/tests/test_load.asm index a9977e3..bb288f6 100644 --- a/tests/test_load.asm +++ b/tests/test_load.asm @@ -1,600 +1,33 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%include "../src/4klang.asm" +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +SECT_DATA(g4kmuc1) -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FLD_ID @@ -605,16 +38,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_FLD VALUE(40) GO4K_FLD VALUE(80) @@ -625,24 +55,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_multiple_instruments.asm b/tests/test_multiple_instruments.asm index 0a2a65b..ef67f2a 100644 --- a/tests/test_multiple_instruments.asm +++ b/tests/test_multiple_instruments.asm @@ -1,602 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 2 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64,HLD,HLD,HLD,HLD,HLD,HLD,HLD, 0, 0, 0,0,0,0,0,0, db 0, 0, 0, 0, 0, 0, 0, 0,64,HLD,HLD,0,0,0,0,0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, Instrument1List db 1, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -612,16 +45,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(0) @@ -637,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_panning.asm b/tests/test_panning.asm index 22cd547..b15c95d 100644 --- a/tests/test_panning.asm +++ b/tests/test_panning.asm @@ -1,600 +1,34 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_PAN_ID @@ -605,16 +39,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_PAN PANNING(40) @@ -625,24 +56,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_store.asm b/tests/test_store.asm index d75e313..e7640aa 100644 --- a/tests/test_store.asm +++ b/tests/test_store.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FLD +%define GO4K_USE_FLD_MOD_VM +%define GO4K_USE_FST -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_FLD_ID db GO4K_FST_ID @@ -610,16 +46,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +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) @@ -635,24 +68,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vcf_band.asm b/tests/test_vcf_band.asm index c304f2e..2a2d543 100644 --- a/tests/test_vcf_band.asm +++ b/tests/test_vcf_band.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_VCF_BAND +%define GO4K_USE_VCF_CHECK -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +44,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -631,25 +64,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vcf_fm_modulation.asm b/tests/test_vcf_fm_modulation.asm index b4ab43d..494b69c 100644 --- a/tests/test_vcf_fm_modulation.asm +++ b/tests/test_vcf_fm_modulation.asm @@ -1,600 +1,39 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%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 -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -610,16 +49,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -635,25 +71,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vcf_high.asm b/tests/test_vcf_high.asm index 4ab578a..0ead730 100644 --- a/tests/test_vcf_high.asm +++ b/tests/test_vcf_high.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_VCF_HIGH +%define GO4K_USE_VCF_CHECK +%define GO4K_CLIP_OUTPUT ; the original expected data was clipping, and this was on -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +45,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -631,25 +65,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vcf_low.asm b/tests/test_vcf_low.asm index d979028..1779afe 100644 --- a/tests/test_vcf_low.asm +++ b/tests/test_vcf_low.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_VCF_CHECK -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +43,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -631,25 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vcf_peak.asm b/tests/test_vcf_peak.asm index f44b4de..e89e7d7 100644 --- a/tests/test_vcf_peak.asm +++ b/tests/test_vcf_peak.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_VCF_CHECK +%define GO4K_USE_VCF_PEAK +%define GO4K_CLIP_OUTPUT ; the original expected data was clipping, and this was on -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +45,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -631,25 +65,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES diff --git a/tests/test_vcf_rm_modulation.asm b/tests/test_vcf_rm_modulation.asm index fccb945..41cd7f5 100644 --- a/tests/test_vcf_rm_modulation.asm +++ b/tests/test_vcf_rm_modulation.asm @@ -1,600 +1,39 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%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 -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -610,16 +49,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -635,25 +71,20 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- +; // Export MAX_SAMPLES for test_renderer +; //---------------------------------------------------------------------------------------- +SECT_DATA(g4krender) + +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES + + ; //---------------------------------------------------------------------------------------- ; // Delay/Reverb Times ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times +SECT_DATA(g4kmuc5) + +EXPORT MANGLE_DATA(go4k_delay_times) dw 0 - dw 11025 -%endif - -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" + dw 11025 \ No newline at end of file diff --git a/tests/test_vcf_stereo.asm b/tests/test_vcf_stereo.asm index c304f2e..8b8fec0 100644 --- a/tests/test_vcf_stereo.asm +++ b/tests/test_vcf_stereo.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_PAN +%define GO4K_USE_VCF_STEREO +%define GO4K_USE_VCF_CHECK +%define GO4K_USE_VCF_BAND -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -608,16 +45,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(64),DECAY(64),SUSTAIN(64),RELEASE(72),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(128),SHAPE(64),GAIN(128),FLAGS(TRISAW) @@ -631,25 +65,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 - dw 11025 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_cm_modulation.asm b/tests/test_vco_cm_modulation.asm index f9921bb..3625271 100644 --- a/tests/test_vco_cm_modulation.asm +++ b/tests/test_vco_cm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_CM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -609,16 +46,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_dm_modulation.asm b/tests/test_vco_dm_modulation.asm index 298a4aa..e3d621b 100644 --- a/tests/test_vco_dm_modulation.asm +++ b/tests/test_vco_dm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_DM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -609,16 +46,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_fm_modulation.asm b/tests/test_vco_fm_modulation.asm index 90f7d62..9a4acd6 100644 --- a/tests/test_vco_fm_modulation.asm +++ b/tests/test_vco_fm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_FM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -609,16 +46,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_gate.asm b/tests/test_vco_gate.asm index 7276c78..b7f6cc8 100644 --- a/tests/test_vco_gate.asm +++ b/tests/test_vco_gate.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_GATE -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -608,16 +44,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -631,24 +64,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_gm_modulation.asm b/tests/test_vco_gm_modulation.asm index 87d4303..f6c4d1f 100644 --- a/tests/test_vco_gm_modulation.asm +++ b/tests/test_vco_gm_modulation.asm @@ -1,600 +1,38 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%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 -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -613,19 +51,16 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) 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 sm + GO4K_FST AMOUNT(68),DEST(1*MAX_UNIT_SLOTS + 7 + FST_POP) ; modulate gm GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF ;// global parameters @@ -633,24 +68,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_lfo.asm b/tests/test_vco_lfo.asm index e56a2ae..b38feb8 100644 --- a/tests/test_vco_lfo.asm +++ b/tests/test_vco_lfo.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -612,12 +47,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -631,24 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_noise.asm b/tests/test_vco_noise.asm index fa08183..dc09735 100644 --- a/tests/test_vco_noise.asm +++ b/tests/test_vco_noise.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_CHECK ; this is needed for the noise regression test, for some reason -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -608,16 +44,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -631,24 +64,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" \ No newline at end of file +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_pm_modulation.asm b/tests/test_vco_pm_modulation.asm index 672509d..4a0eb7d 100644 --- a/tests/test_vco_pm_modulation.asm +++ b/tests/test_vco_pm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_PM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -613,12 +50,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_pulse.asm b/tests/test_vco_pulse.asm index 6e70f9e..7deae81 100644 --- a/tests/test_vco_pulse.asm +++ b/tests/test_vco_pulse.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -612,12 +47,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -631,24 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_sine.asm b/tests/test_vco_sine.asm index 2fa2bd3..3f3c4b8 100644 --- a/tests/test_vco_sine.asm +++ b/tests/test_vco_sine.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -612,12 +47,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -631,24 +63,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_sm_modulation.asm b/tests/test_vco_sm_modulation.asm index 02e3897..7ad0a23 100644 --- a/tests/test_vco_sm_modulation.asm +++ b/tests/test_vco_sm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_SM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -613,12 +50,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_stereo.asm b/tests/test_vco_stereo.asm index 2b942c7..ffa4632 100644 --- a/tests/test_vco_stereo.asm +++ b/tests/test_vco_stereo.asm @@ -1,600 +1,36 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_STEREO -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -611,12 +47,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -629,24 +62,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_tm_modulation.asm b/tests/test_vco_tm_modulation.asm index d01b575..f617ffc 100644 --- a/tests/test_vco_tm_modulation.asm +++ b/tests/test_vco_tm_modulation.asm @@ -1,600 +1,37 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_FST +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET +%define GO4K_USE_VCO_MOD_TM -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0 -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_VCO_ID @@ -613,12 +50,9 @@ go4k_synth_instructions_end ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(80),DECAY(80),SUSTAIN(64),RELEASE(80),GAIN(128) GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(128),SHAPE(64),GAIN(128),FLAGS(SINE) @@ -633,24 +67,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_ACC ACCTYPE(OUTPUT) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF -go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file diff --git a/tests/test_vco_trisaw.asm b/tests/test_vco_trisaw.asm index 9838a44..dc900af 100644 --- a/tests/test_vco_trisaw.asm +++ b/tests/test_vco_trisaw.asm @@ -1,600 +1,35 @@ -bits 32 - -; //---------------------------------------------------------------------------------------- -; // useful macros -; //---------------------------------------------------------------------------------------- -; // export function (make it accessable from main.cpp) -; //---------------------------------------------------------------------------------------- -%macro export_func 1 - global _%1 - _%1: -%endmacro -%define USE_SECTIONS -; //---------------------------------------------------------------------------------------- -; // basic defines for the song/synth -; //---------------------------------------------------------------------------------------- -;%define AUTHORING ; Use to export the current tick being rendered -;%define SINGLE_TICK_RENDERING ; Use to render single tick on _4klang_render invocation ( requires AUTHORING enabled ) -%define SAMPLE_RATE 44100 %define MAX_INSTRUMENTS 1 -%define MAX_VOICES 1 -%define HLD 1 ; // can be adjusted to give crinkler some other possibilities %define BPM 100 %define MAX_PATTERNS 1 -%define PATTERN_SIZE_SHIFT 4 -%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT) -%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE) -%define SAMPLES_PER_TICK (SAMPLE_RATE*4*60/(BPM*16)) -%define DEF_LFO_NORMALIZE 0.000038 -%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS) -; //---------------------------------------------------------------------------------------- -; // some defines for unit usage, which reduce synth code size -; //---------------------------------------------------------------------------------------- -;%define GO4K_USE_16BIT_OUTPUT ; // removing this will output to 32bit floating point buffer -;%define GO4K_USE_GROOVE_PATTERN ; // removing this skips groove pattern code -;%define GO4K_USE_ENVELOPE_RECORDINGS ; // removing this skips envelope recording code -;%define GO4K_USE_NOTE_RECORDINGS ; // removing this skips note recording code -%define GO4K_USE_UNDENORMALIZE ; // removing this skips denormalization code in the units -%define GO4K_CLIP_OUTPUT ; // removing this skips clipping code for the final output -%define GO4K_USE_DST ; // removing this will skip DST unit -%define GO4K_USE_DLL ; // removing this will skip DLL unit -%define GO4K_USE_PAN ; // removing this will skip PAN unit -%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_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 -%define GO4K_USE_DLL_CHORUS_CLAMP ; // removing this will skip chorus lfo phase clamping -%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_FLD_MOD_VM ; // removing this will skip float load modulation 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 +%define SINGLE_FILE +%define USE_SECTIONS +%define GO4K_USE_VCO_SHAPE +%define GO4K_USE_VCO_PHASE_OFFSET -; //---------------------------------------------------------------------------------------- -; // synth defines -; //---------------------------------------------------------------------------------------- -%define MAX_DELAY 65536 -%define MAX_UNITS 64 -%define MAX_UNIT_SLOTS 16 -%define GO4K_BEGIN_CMDDEF(def_name) -%define GO4K_END_CMDDEF db 0 -%define GO4K_BEGIN_PARAMDEF(def_name) -%define GO4K_END_PARAMDEF -; //---------------------------------------------------------------------------------------- -; // ENV structs -; //---------------------------------------------------------------------------------------- -GO4K_ENV_ID equ 1 -%macro GO4K_ENV 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ATTAC(val) val -%define DECAY(val) val -%define SUSTAIN(val) val -%define RELEASE(val) val -%define GAIN(val) val -struc go4kENV_val -;// unit paramters - .attac resd 1 - .decay resd 1 - .sustain resd 1 - .release resd 1 - .gain resd 1 - .size -endstruc -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 -%define ENV_STATE_DECAY 1 -%define ENV_STATE_SUSTAIN 2 -%define ENV_STATE_RELEASE 3 -%define ENV_STATE_OFF 4 -; //---------------------------------------------------------------------------------------- -; // VCO structs -; //---------------------------------------------------------------------------------------- -GO4K_VCO_ID equ 2 +%include "../src/4klang.asm" -%macro GO4K_VCO 8 - db %1 - db %2 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - db %3 -%endif -%ifdef GO4K_USE_VCO_GATE - db %4 -%endif - db %5 -%ifdef GO4K_USE_VCO_SHAPE - db %6 -%else -%endif - db %7 - db %8 -%endmacro -%define TRANSPOSE(val) val -%define DETUNE(val) val -%define PHASE(val) val -%define GATES(val) val -%define COLOR(val) val -%define SHAPE(val) val -%define FLAGS(val) val -%define SINE 0x01 -%define TRISAW 0x02 -%define PULSE 0x04 -%define NOISE 0x08 -%define LFO 0x10 -%define GATE 0x20 -%define VCO_STEREO 0x40 -struc go4kVCO_val -;// unit paramters - .transpose resd 1 - .detune resd 1 -%ifdef GO4K_USE_VCO_PHASE_OFFSET - .phaseofs resd 1 -%endif -%ifdef GO4K_USE_VCO_GATE - .gate resd 1 -%endif - .color resd 1 -%ifdef GO4K_USE_VCO_SHAPE - .shape resd 1 -%endif - .gain resd 1 - .flags resd 1 - .size -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 - .size -endstruc +; //------------------------------------------------------------------------------- +; // Pattern Data ; //---------------------------------------------------------------------------------------- -; // VCF structs -; //---------------------------------------------------------------------------------------- -GO4K_VCF_ID equ 3 -%macro GO4K_VCF 3 - db %1 - db %2 - db %3 -%endmacro -%define LOWPASS 0x1 -%define HIGHPASS 0x2 -%define BANDPASS 0x4 -%define BANDSTOP 0x3 -%define ALLPASS 0x7 -%define PEAK 0x8 -%define STEREO 0x10 -%define FREQUENCY(val) val -%define RESONANCE(val) val -%define VCFTYPE(val) val -struc go4kVCF_val -;// unit paramters - .freq resd 1 - .res resd 1 - .type resd 1 - .size -endstruc -struc go4kVCF_wrk -;// work variables - .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 -;// stereo variables - .low2 resd 1 - .high2 resd 1 - .band2 resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // DST structs -; //---------------------------------------------------------------------------------------- -GO4K_DST_ID equ 4 -%macro GO4K_DST 3 - 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 -%endmacro -%define DRIVE(val) val -%define SNHFREQ(val) val -%define FLAGS(val) val -struc go4kDST_val -;// unit paramters - .drive resd 1 -%ifdef GO4K_USE_DST_SH - .snhfreq resd 1 -%endif - .flags resd 1 - .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 -endstruc -; //---------------------------------------------------------------------------------------- -; // DLL structs -; //---------------------------------------------------------------------------------------- -GO4K_DLL_ID equ 5 -%macro GO4K_DLL 8 - db %1 - db %2 - db %3 -%ifdef GO4K_USE_DLL_DAMP - db %4 -%endif -%ifdef GO4K_USE_DLL_CHORUS - db %5 - db %6 -%endif - db %7 - db %8 -%endmacro -%define PREGAIN(val) val -%define DRY(val) val -%define FEEDBACK(val) val -%define DEPTH(val) val -%define DAMP(val) val -%define DELAY(val) val -%define COUNT(val) val -struc go4kDLL_val -;// unit paramters - .pregain resd 1 - .dry resd 1 - .feedback resd 1 -%ifdef GO4K_USE_DLL_DAMP - .damp resd 1 -%endif -%ifdef GO4K_USE_DLL_CHORUS - .freq resd 1 - .depth -%endif - .delay resd 1 - .count resd 1 - .size -endstruc -struc go4kDLL_wrk -;// work variables - .index resd 1 - .store resd 1 - .dcin resd 1 - .dcout resd 1 - .phase resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -GO4K_FOP_ID equ 6 -%macro GO4K_FOP 1 - db %1 -%endmacro -%define OP(val) val -%define FOP_POP 0x1 -%define FOP_ADDP 0x2 -%define FOP_MULP 0x3 -%define FOP_PUSH 0x4 -%define FOP_XCH 0x5 -%define FOP_ADD 0x6 -%define FOP_MUL 0x7 -%define FOP_ADDP2 0x8 -%define FOP_LOADNOTE 0x9 -%define FOP_MULP2 0xa -struc go4kFOP_val - .flags resd 1 - .size -endstruc -struc go4kFOP_wrk - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // FST structs -; //---------------------------------------------------------------------------------------- -GO4K_FST_ID equ 7 -%macro GO4K_FST 2 - db %1 - dw %2 -%endmacro -%define AMOUNT(val) val -%define DEST(val) val -%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 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // PAN structs -; //---------------------------------------------------------------------------------------- -GO4K_PAN_ID equ 8 -%macro GO4K_PAN 1 -%ifdef GO4K_USE_PAN - db %1 -%endif -%endmacro -%define PANNING(val) val -struc go4kPAN_val -%ifdef GO4K_USE_PAN - .panning resd 1 -%endif - .size -endstruc -struc go4kPAN_wrk -;// modulation targets - .pm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // OUT structs -; //---------------------------------------------------------------------------------------- -GO4K_OUT_ID equ 9 -%macro GO4K_OUT 2 - db %1 -%ifdef GO4K_USE_GLOBAL_DLL - db %2 -%endif -%endmacro -%define AUXSEND(val) val -struc go4kOUT_val - .gain resd 1 -%ifdef GO4K_USE_GLOBAL_DLL - .auxsend resd 1 -%endif - .size -endstruc -struc go4kOUT_wrk -;// modulation targets - .am resd 1 - .gm resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // ACC structs (this is for the synth def only) -; //---------------------------------------------------------------------------------------- -GO4K_ACC_ID equ 10 -%macro GO4K_ACC 1 - db %1 -%endmacro -%define OUTPUT 0 -%define AUX 8 -%define ACCTYPE(val) val -struc go4kACC_val - .acctype resd 1 - .size -endstruc -struc go4kACC_wrk - .size -endstruc -%ifdef GO4K_USE_FLD -; //---------------------------------------------------------------------------------------- -; // FLD structs -; //---------------------------------------------------------------------------------------- -GO4K_FLD_ID equ 11 -%macro GO4K_FLD 1 - db %1 -%endmacro -%define VALUE(val) val -struc go4kFLD_val - .value resd 1 - .size -endstruc -struc go4kFLD_wrk -;// modulation targets - .vm resd 1 - .size -endstruc -%endif -%ifdef GO4K_USE_GLITCH -; //---------------------------------------------------------------------------------------- -; // GLITCH structs -; //---------------------------------------------------------------------------------------- -GO4K_GLITCH_ID equ 12 -%macro GO4K_GLITCH 5 - db %1 - db %2 - db %3 - db %4 - db %5 -%endmacro -%define ACTIVE(val) val -%define SLICEFACTOR(val)val -%define PITCHFACTOR(val)val -%define SLICESIZE(val) val -struc go4kGLITCH_val -;// unit paramters - .active resd 1 - .dry resd 1 - .dsize resd 1 - .dpitch resd 1 - .slicesize resd 1 - .size -endstruc -struc go4kGLITCH_wrk -;// work variables - .index resd 1 - .store resd 1 - .slizesize resd 1 - .slicepitch resd 1 - .unused resd 1 -;// the delay buffer - .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 -; //---------------------------------------------------------------------------------------- -; // FSTG structs -; //---------------------------------------------------------------------------------------- -GO4K_FSTG_ID equ 13 -%macro GO4K_FSTG 2 - db %1 - dw %2 -%endmacro -struc go4kFSTG_val - .amount resd 1 - .op1 resd 1 - .size -endstruc -struc go4kFSTG_wrk - .size -endstruc -%endif -; //---------------------------------------------------------------------------------------- -; // Voice struct -; //---------------------------------------------------------------------------------------- -struc go4k_instrument - .release resd 1 - .note resd 1 - .workspace resd MAX_UNITS*MAX_UNIT_SLOTS - .dlloutl resd 1 - .dlloutr resd 1 - .outl resd 1 - .outr resd 1 - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Synth struct -; //---------------------------------------------------------------------------------------- -struc go4k_synth - .instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES - .global resb go4k_instrument.size * MAX_VOICES - .size -endstruc -; //---------------------------------------------------------------------------------------- -; // Pattern Data, reduced by 967 patterns -; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc1 data align=1 -%else -section .data align=1 -%endif -go4k_patterns +SECT_DATA(g4kmuc1) + +EXPORT MANGLE_DATA(go4k_patterns) db 64, 0, 68, 0, 32, 0, 0, 0, 75, 0, 78, 0, 0, 0, 0, 0, -go4k_patterns_end + ; //---------------------------------------------------------------------------------------- ; // Pattern Index List ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc2 data align=1 -%else -section .data -%endif -go4k_pattern_lists +SECT_DATA(g4kmuc2) + +EXPORT MANGLE_DATA(go4k_pattern_lists) Instrument0List db 0, -go4k_pattern_lists_end + ; //---------------------------------------------------------------------------------------- ; // Instrument Commands ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc3 data align=1 -%else -section .data -%endif -go4k_synth_instructions +SECT_DATA(g4kmuc3) + +EXPORT MANGLE_DATA(go4k_synth_instructions) GO4K_BEGIN_CMDDEF(Instrument0) db GO4K_ENV_ID db GO4K_ENV_ID @@ -608,16 +43,13 @@ GO4K_BEGIN_CMDDEF(Global) db GO4K_ACC_ID db GO4K_OUT_ID GO4K_END_CMDDEF -go4k_synth_instructions_end + ; //---------------------------------------------------------------------------------------- ; // Intrument Data ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc4 data align=1 -%else -section .data -%endif -go4k_synth_parameter_values +SECT_DATA(g4kmuc4) + +EXPORT MANGLE_DATA(go4k_synth_parameter_values) GO4K_BEGIN_PARAMDEF(Instrument0) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) GO4K_ENV ATTAC(32),DECAY(32),SUSTAIN(64),RELEASE(64),GAIN(128) @@ -632,23 +64,11 @@ GO4K_BEGIN_PARAMDEF(Global) GO4K_OUT GAIN(128), AUXSEND(0) GO4K_END_PARAMDEF go4k_synth_parameter_values_end + ; //---------------------------------------------------------------------------------------- -; // Delay/Reverb Times +; // Export MAX_SAMPLES for test_renderer ; //---------------------------------------------------------------------------------------- -%ifdef USE_SECTIONS -section .g4kmuc5 data align=1 -%else -section .data -%endif -%ifdef GO4K_USE_DLL -global _go4k_delay_times -_go4k_delay_times - dw 0 -%endif +SECT_DATA(g4krender) -section .data - -global _test_max_samples -_test_max_samples dd MAX_SAMPLES - -%include "../src/4klang.inc" +EXPORT MANGLE_DATA(test_max_samples) + dd MAX_SAMPLES \ No newline at end of file