mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-04 01:28:45 -04:00
The stereo opcode variants have bit 1 of the command stream set. The polyphony is split into two parts: 1) polyphony, meaning that voices reuse the same opcodes; 2) multitrack voices, meaning that a track triggers more than voice. They both can be flexible defined in any combinations: for example voice 1 and 2 can be triggered by track 1 and use instrument 1, and voice 3 by track 2/instrument 2 and voice 4 by track 3/instrument 2. This is achieved through the use of bitmasks: in the aforementioned example, bit 1 of su_voicetrack_bitmask would be set, meaning "the voice after voice #1 will be triggered by the same track". On the other hand, bits 1 and 3 of su_polyphony_bitmask would be set to indicate that "the voices after #1 and #3 will reuse the same instruments".
63 lines
2.8 KiB
NASM
63 lines
2.8 KiB
NASM
;-------------------------------------------------------------------------------
|
|
; su_op_advance function: opcode to advance from one instrument to next
|
|
;-------------------------------------------------------------------------------
|
|
; Stack: voice wrkptr valptr comptr
|
|
; voice : the number of voice we are currently processing
|
|
; wrkptr : pointer to the first unit of current voice - su_unit.size
|
|
; valptr : pointer to the first unit's value of current voice
|
|
; comptr : pointer to the first command of current voice
|
|
; COM : pointer to the command after current command
|
|
; Output: WRK : pointer to the next unit to be processed
|
|
; VAL : pointer to the values of the next to be processed
|
|
; COM : pointer to the next command to be executed
|
|
;
|
|
; Checks if this was the last voice of current instrument. If so, moves to
|
|
; next opcodes and updates the stack to reflect the instrument change.
|
|
; If this instrument has more voices to process, rolls back the COM and VAL
|
|
; pointers to where they were when this instrument started.
|
|
;-------------------------------------------------------------------------------
|
|
SECT_TEXT(suopadvn)
|
|
|
|
%ifdef INCLUDE_POLYPHONY
|
|
|
|
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
|
mov WRK, dword [esp+8] ; WRK = wrkptr
|
|
add WRK, su_voice.size ; move to next voice
|
|
mov dword [esp+8], WRK ; update stack
|
|
mov ecx, dword [esp+4] ; ecx = voice
|
|
bt dword [su_polyphony_bitmask],ecx ; if voice bit of su_polyphonism not set
|
|
jnc su_op_advance_next_instrument ; goto next_instrument
|
|
mov VAL, dword [esp+12] ; rollback to where we were earlier
|
|
mov COM, dword [esp+16]
|
|
jmp short su_op_advance_finish
|
|
su_op_advance_next_instrument:
|
|
mov dword [esp+12], VAL ; save current VAL as a checkpoint
|
|
mov dword [esp+16], COM ; save current COM as a checkpoint
|
|
su_op_advance_finish:
|
|
inc ecx ; voice++
|
|
mov dword [esp+4], ecx
|
|
ret
|
|
|
|
%else
|
|
|
|
EXPORT MANGLE_FUNC(su_op_advance,0) ; Stack: addr voice wrkptr valptr comptr
|
|
mov WRK, dword [esp+8] ; WRK = wrkptr
|
|
add WRK, su_voice.size ; move to next voice
|
|
mov dword [esp+8], WRK ; update stack
|
|
inc dword [esp+4] ; voice++
|
|
ret
|
|
|
|
%endif
|
|
|
|
|
|
;-------------------------------------------------------------------------------
|
|
; Constants
|
|
;-------------------------------------------------------------------------------
|
|
%ifdef SU_USE_DLL_DC_FILTER
|
|
%ifndef C_DC_CONST
|
|
SECT_DATA(suconst)
|
|
c_dc_const dd 0.99609375 ; R = 1 - (pi*2 * frequency /samplerate)
|
|
%define C_DC_CONST
|
|
%endif
|
|
|
|
%endif |