global fcommand, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt
set fcommand to EMPTY
set cpy1buf to 27
set cpy2buf to 60
set srcidx to 0
set destidx to cpy1buf
set cpidx to 0
set maxtrys to 100
set t1_idxcntsv to t1_idxcnt
set t2_idxcntsv to t2_idxcnt
cur_busy()
repeat with i = 1 to 24
if AR1idx(mget, srcidx) <> 0 then
if i > 12 then
Ar1track(mput, destidx, 2)
else
Ar1track(mput, destidx, 1)
end if
AR1idx(mput, destidx, AR1idx(mget, srcidx))
move_ar1(destidx, srcidx)
set cpidx to cpidx + 1
set destidx to destidx + 1
end if
set srcidx to srcidx + 1
end repeat
AR1idx(mput, destidx + 1, 0)
set srcidx to 0
set destidx to cpy2buf
repeat with i = 1 to 24
if AR1idx(mget, srcidx) <> 0 then
if i > 13 then
Ar1track(mput, destidx, 2)
else
Ar1track(mput, destidx, 1)
end if
AR1idx(mput, destidx, AR1idx(mget, srcidx))
move_ar1(destidx, srcidx)
set destidx to destidx + 1
end if
set srcidx to srcidx + 1
end repeat
AR1idx(mput, destidx + 1, 0)
set t1_pos to 1
set t2_pos to 1
set t_pos to 1
cleanup()
cleanUpArrs()
updateStage()
set full to 0
set trackmove to 1
repeat while 1
if cpidx = 0 then
exit repeat
end if
repeat while 1
if t2_idxcntsv > 0 then
if trackmove > t1_idxcntsv then
set srcidx to random(cpidx) + cpy1buf - 1
set t_pos to t2_pos
if (t_pos + ar1seg(mget, srcidx)) <= 13 then
set t_add to 12
set destidx to t2_idxcnt + 1
exit repeat
end if
else
set srcidx to cpy1buf
set trackmove to trackmove + 1
set t_pos to t1_pos
if (t_pos + ar1seg(mget, srcidx)) <= 13 then
set t_add to 0
set destidx to t1_idxcnt + 1
exit repeat
end if
end if
else
set srcidx to random(cpidx) + cpy1buf - 1
set t_pos to t1_pos
if (t_pos + ar1seg(mget, srcidx)) <= 13 then
set t_add to 0
set destidx to t1_idxcnt + 1
exit repeat
end if
end if
set full to full + 1
if full > maxtrys then
cur_on()
alertrd(" Random can not be finished because " & "the tracks are too full." & RETURN & "Restoring circle.", " REMIX kann nicht beendet werden weil " & "die Spuren zu voll sind." & RETURN & "Wiederherstellung.")
set stop1idx to ar_pos2idxstop(0, getstopidx(0) - 1)
set stop2idx to ar_pos2idxstop(12, getstopidx(12) - 1)
set seg1 to segsum(start1idx, stop1idx)
set seg2 to segsum(start2idx, stop2idx)
if not (ar1pos(mget, start1idx) = ar1pos(mget, start2idx)) then
alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Start Looppoints must fit the element start.", "Looppunkte entsprechen nicht den geladenen ELEMENTEN." & RETURN & "Startlooppunkte muessen am ELEMENT Anfang stehen.")
exit
end if
if stop1idx > (value(ar1pos(mget, start1idx)) + value(ar1seg(mget, start1idx))) then
alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Stop Looppoints must fit the element length on track 1.", "Looppunkte entsprechen nicht den geladenen ELEMENTEN." & RETURN & "Stoplooppunkte muessen am ELEMENT Ende stehen.")
exit
end if
if (start1idx > stop1idx) or (start2idx > stop2idx) then
alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Loopoints must fit smalest elelemtsize.", "Zum mixen gueltige Looppunte setzen." & RETURN & "Stoplooppunkte muessen am ELEMENT Ende stehen.")
put "mixerr 5"
exit
end if
if (ar1pos(mget, start2idx + 12) + ar1seg(mget, start2idx + 12)) > (LED_2 + 12) then
alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Loopoints must fit smalest elelemtsize.", "Zum mixen gueltige Looppunte setzen." & RETURN & "Stoplooppunkte muessen am ELEMENT Ende stehen.")
alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Loopoints must fit smalest elelemtsize.", "Zum mixen gueltige Looppunte setzen." & RETURN & "Stoplooppunkte muessen am ELEMENT Ende stehen.")
put "mixerr 7"
exit
end if
set mix_err to "1"
set mix_ofs1 to "0"
set mix_idx to set_globmix(start1idx, start2idx, stop1idx, stop2idx)