Somebody sent me this code which I made into a block and it does seem to work. Oh, it looks like what Frank posted years ago!
Code: Select all
mem delay 32767
skp run, loop
sof 0, -0.25 ;clear acc and set -0.25
wrax rmp0_rate, 0 ;ramp rate = -.25, clear to 0
wrax rmp0_range, 0 ;ramp range= 0
loop:
sof 0,0 ;clear acc
rdax adcl, 1.0 ;read left adc
wra delay#, 0.0 ;write to delay ram and clear
cho rdal, rmp0 ;get ramp lfo
wrax addr_ptr, 0 ;write data at delay ram address
rmpa 1.0 ;read data at delay ram address 1.0
wrax dacr, 1.0
wrax dacl, 0.0
So we're not using any CHO RDA here to get the delayed signal, only RMPA. And that's probably fine so long as the ratio of the pitch readout is not fractional and we wouldn't be needing to interpolate between samples anyway.
To be honest, the code sample I received did not have anything explicit for this line:
wrax rmp0_range, ;ramp range= 0
I inserted the value 0 based on the comment, so now it's like this:
wrax rmp0_range, 0 ;ramp range= 0
It does work although I don't think the buffer length is a full second.
Here's a few things I don't claim to understand:
1) If you set the RMP0_RANGE to 0, how is it that we get anything useful out of CHO RDAL? Is RMP0_RANGE important here, or not?
2) I'm kinda used to having to multiply an explicit delay RAM reference by 256 prior to RMPA. But here, we pick off the value of the RAMP0 LFO, which supposedly has a width of zero, and then use that directly as the ADDR_PTR value, and it seems to work,
I don't want to give up just because this isn't documented. It's doing something close to what I want. All I want to do now is add some code that would generate explicit crossfade waveforms that I could use if RMPA is the way to go. I haven't tried CHO RDA here yet and if that worked then maybe that other bit wouldn't be necessary.
The other point of confusion I have is why the entire RAM bank is allocated. What range is RMPA really looping over?
One of the previous examples showed both CHO RDA and RMPA methods combined. Unfortunately it looks like the audio result of the standard 6 pitch shift instructions was written to ADDR_PTR, so no wonder it sounded like noise.
So (I'm guessing) this RMPA approach will work but the CHO RDA will not. Crossfading waveforms can be generated from the ramp uch as you'd make a triangle:
SOF 0, -(half of ramp amplitude) ; puts center of ramp at zero
ABSA ; folds lower half up to make triangle
SOF 1.0, -(1/4 of ramp amplitude) ; make triangle symmetrical around 0
SOF -2.0, 0 ; boost level of triangle up to clip off tops and bottoms
SOF -2.0, 0 ; requires a few of these to get there, not sure how many
...
; now you have a triangle with tops and bottoms clipped off
SOF 0.5, 0.5 ; now it is suitable for one half of a crossfade
WRAX REG0, 1.0 ; save it
SOF -0.999, 0.999 ; invert it - now you have the other half of the crossfade waveform
WRAX REG1, 0 ; save it so it can be used with MULX later
------------------------
The next challenge is going to be picking off a delay point "halfway" from what ADDR_PTR is pointing at. I guess you can multiply ADDR_PTR by 0.5 and that solves that problem.
All highly theoretical at this point.
DL