; Pitch Tremolo effect for FORM2
mem pidel 4096 ; Pitch delay
mem temp 1 ; Temp location for partial calculations
equ jump reg0 ; Pitch shifting value
equ rate reg1 ; tremolo rate reg
equ square reg2 ; square wave 0 to 1
equ tria reg3 ; sinus wave 0 to 1
equ shape reg4 ; blended waveform
equ nRise reg6 ; -1 to 0 ramp
; Initialization ############## 2 inst
skp RUN, loop
wldr RMP0, 0, 4096 ; Ramp0 init
loop:
; Ramp Generator ############# 6 inst
or 5120 ; 20 Hz
mulx POT0 ; * rate ctrl
mulx POT0 ; square
rdax nRise, 1 ; add last counter
skp NEG, 1 ; if GEZ : reset
sof 0, -1 ; -1
wrax nRise, 0 ; store new counter value, clr
; Triangle Wave #################### inst
sof 0, -1 ; -1
rdax nRise, -2 ; -1 to 1
absa ; 1 to 0 to 1
wrax tria, 1 ; store, keep
sof 1, -0.5 ; 0.5 to -0.5 to 0.5
skp NEG, 2 ; if GEZ : make 1
sof 0, 0.999023 ; 1
skp GEZ, 1 ; uncond. skp
clr ; if NEG : make 0
wrax square, 0 ; store, clr
; POT1 Glissando ctrl ####################
ldax tria ; Read tria
rdax square, -1 ; add inverted square
mulx POT1 ; * crossmixer
rdax square, 1 ; add back square
wrax shape, 0 ; store, clr [Square <-> Tria]
; Pitch adjustment ############### 5 inst
ldax POT2
sof 1, -0.143 ; 0 to 1 - (1/7)
skp GEZ, next1 ; if GEZ : to go next
clr
or 2097152 ; 12
sof -1, 0 ; -12
skp NEG, setJump ; uncond skp
next1:
sof 1, -0.143 ; - (1/7)
skp GEZ, next2 ; if GEZ : to go next
clr
or 1394942 ; 7
sof -1, 0 ; -7
skp NEG, setJump ; uncond skp
next2:
sof 1, -0.143 ; -1/7
skp GEZ, next3 ; if GEZ : to go next
clr
or 1052126 ; 5
sof -1, 0 ; -5
skp NEG, setJump ; uncond
next3:
sof 1, -0.143 ; -1/7
skp GEZ, next4 ; if GEZ : to go next
clr ; 0
skp ZRO, setJump ; uncond
next4:
sof 1, -0.143 ; -1/7
skp GEZ, next5 ; if GEZ : to go next
clr
or 2090051 ; +7
skp GEZ, setJump ; uncond
next5:
sof 1, -0.143 ; -1/7
skp GEZ, next6 ; if GEZ : to go next
clr
or 4194304 ; +12
skp GEZ, setJump ; uncond
next6:
clr
or 8374407 ; +19
setJump:
wrax jump, 0 ; store, clr [-0.25 to 0.5]
; Write Pitch shift amount ###########
ldax jump ; waveshape
mulx shape ; * interval (amplitude)
wrax RMP0_RATE, 0 ; store new ramp1 rate, clr
; Audio Input ###################
ldax ADCL ;
wra pidel, 0 ; Write to pitch shift delay, clr
; Audio Output ##################
cho rda, RMP0, REG|COMPC, pidel
cho rda, RMP0,, pidel+1
wra temp, 0
cho rda, RMP0, RPTR2|COMPC, pidel
cho rda, RMP0, RPTR2, pidel+1
cho sof, RMP0, NA|COMPC, 0
cho rda, RMP0, NA, temp
wrax DACL, 0 ; Output, clr