This could be very useful for performing vibrato on shorter buffer segments with other waveforms than a sine.
I have a concept for a method though I'm struggling with finding a good way to write up the code:
* Consider a positive (0 to 1) variable X with a 23-bit resolution (ignoring negative range), and a memory buffer of 1024 samples (~30 ms).
* The addressing resolution directly available with the ADDR_PTR is : 1024 * 256 = 10 + 8 bit = 18 bit (262 144 positions).
* Using the 18 MSB (most significant bits) of X to set the ADDR_PTR would leave 5 leftover LSB bits available for further interpolation resolution.
* Using the 5 LSB (least significant bits) one could crossfade between two RMPA reading from two adjacent ADDR_PTR positions.
* For our 1024 sample (10-bit) buffer and 23-bit variable X this would produce a interpolation resolution of 23 - 10 = 13 bits.
By the way does anyone know the interpolation resolution when using the CHO instructions for vibrato?
Bonus question: Could anyone think of a way to improve this method by allowing a 24-bit bipolar variable for X ( yielding +1 bit resolution)?
Rough, non-functional code to illustrate the idea:
Code: Select all
mem buffer 1023 ; 30 ms buffer
equ wave reg0 ; 23-bit positive waveform output register
equ xfade reg1 ; 5bit crossfade
equ const reg2 ; adjacent addr_ptr pos offset constant
equ adja reg3 ; offset addr_ptr pos
equ mix reg4 ; temporary mix register
; offset constant setup
clr ; clr acc
or 1 ; add (1 / 2^23)
wrax const, 0 ; store, clr acc
; Main addres positions
rdax wave, 0.03125 ; scale down to 18 bit
wrax ADDR_PTR, 1 ; store addres position, keep in acc
rdax const, 1 ; add offset
wrax adja, 0 ; store adjacent position, clear acc
; 5-bit additional interpolation
ldax wave ; read waveform
and 0b11111 ; remove 18 MSB
sof -2, 0 ; bitwise shift remaining 5 bits with 18 [sof -2,0] instructions
... ;
wrax xfade, 0 ; store, clr acc
; Audio input
ldax ADCL ; read audio input
wra buffer, 0 ; store to start of buffer, clr acc
; Audio Output
rmpa 1.0 ; read first position
wrax mix, 0 ; store, clr acc
ldax adja ; read adjacent position
wrax ADDR_PTR, 0 ; set second position, clr acc
rmpa 1.0 ; read second position
rdax mix, -1 ;
mulx xfade ; perform phase inversion crossfade
rdax mix, 1 ;
wrax DACL, 0 ; output audio, clr acc