Here’s a possible method:
Concatenate the arrays, and append the index positions of the appends at the end of the array.
As long as you know the last values in the array refer to index positions, you can then extract the embedded arrays using slicearray.
Here’s an example (it’s a bit more convenient to demonstrate this with i-rate arrays).
-odac --nchnls=2 --0dbfs=1 -m0 --sample-rate=48000 --ksmps=120
;; With the help of ArrCat udo from the csudo repository, Joahim Heintz, MIT License 2023
;; [https://github.com/csudo/csudo/blob/master/arrays/ArrCat.csd#L23C1-L39C6](https://github.com/csudo/csudo/blob/master/arrays/ArrCat.csd#L23C1-L39C6)
opcode ArrCat, i[], i[]i[]
iArr1[], iArr2[] xin
iLenOutArr = lenarray(iArr1) + lenarray(iArr2)
iOutArr[] init iLenOutArr
indx = 0
while indx < lenarray(iArr1) do
iOutArr[indx] = iArr1[indx]
indx += 1
od
while indx < iLenOutArr do
iOutArr[indx] = iArr2[indx-lenarray(iArr1)]
indx += 1
od
xout iOutArr
endop
instr 1
iArr1[] fillarray 1,2,3,4,5
iArr2[] fillarray 10,20,30,40,50
idelimiters[] fillarray lenarray(iArr1),lenarray(iArr1) + lenarray(iArr2)
;; now combine them all into one array, storing the delimiter values at the end.
icombined[] ArrCat iArr1, iArr2
icombined[] ArrCat icombined, idelimiters
printf_i “\nCombined array:”,1
printarray icombined
;; to extract the arrays,
;; use the delimiter values as position indices for slicearray.
idivndx1 = icombined[lenarray(icombined) - 2]
idivndx2 = icombined[lenarray(icombined) - 1]
iArr1extracted[] slicearray icombined,0,idivndx1-1
iArr2extracted[] slicearray icombined,idivndx1,idivndx2-1
printf_i “\nExtracted Array 1:”,1
printarray iArr1extracted
printf_i “\nExtracted Array 2:”,1
printarray iArr2extracted
endin
i1 0 1
e