Does this seem reasonable then?
<Cabbage>
form caption("Reverse") size(400, 300), guiMode("queue"), colour(58, 110, 182), pluginId("def1")
rslider bounds(60, 30, 60, 60) channel("length") range(0.1, 1, 1, 1, 0.1), text("Length")
gentable bounds(110, 134, 198, 108), tableNumber(93.0)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
giTableLen = 2^16
giTableL ftgen 91, 0, giTableLen, 7, 0, giTableLen, 0
giTableR ftgen 92, 0, giTableLen, 7, 0, giTableLen, 0
giEnvTable ftgen 93, 0, giTableLen, 9, 0.5, 1, 0
opcode Reverse, a, aiik
setksmps 1
aIn, iFn, iEnvTable, kLength xin
kWritePointer init 0
kReadPointer init 0
gkTableLength = ftlen(iFn)*kLength
tablew aIn, a(kReadPointer), iFn
aSignal table a(gkTableLength)-a(kReadPointer), iFn
kWritePointer = kWritePointer < gkTableLength ? kWritePointer + 1 : 0
kReadPointer = kReadPointer < gkTableLength ? kReadPointer + 1 : 0
aEnvPhs1 phasor sr/gkTableLength
aEnvPhs2 phasor sr/gkTableLength, 0.5
aEnv1 table aEnvPhs1*2, iEnvTable, 1
aEnv2 table aEnvPhs2*2, iEnvTable, 1
xout aSignal*aEnv1 + aSignal*aEnv2
endop
instr 1
kLength cabbageGetValue "length"
a1 inch 1
a2 inch 2
aRevL Reverse a1, giTableL, giEnvTable, kLength
aRevR Reverse a2, giTableR, giEnvTable, kLength
outs aRevL, aRevR
endin
</CsInstruments>
<CsScore>
i1 0 [60*60*24*7]
</CsScore>
</CsoundSynthesizer>
I notice sometimes when you change the length-parameter, it seems like either the audio table or the window shape envelope get’s thrown off, since it creates a small click at the start of each loop. Does something need to be upsampled or interpolated?