home *** CD-ROM | disk | FTP | other *** search
/ Sound, Music & MIDI Collection 2 / SMMVOL2.bin / DEMO / PRG / CIRCLES.ZIP / CI_MAIN.DIX / 00006_FEATURES.ls < prev    next >
Encoding:
Text File  |  1995-05-01  |  14.7 KB  |  463 lines

  1. on mkrandom
  2.   global fcommand, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt
  3.   set fcommand to EMPTY
  4.   set cpy1buf to 27
  5.   set cpy2buf to 60
  6.   set srcidx to 0
  7.   set destidx to cpy1buf
  8.   set cpidx to 0
  9.   set maxtrys to 100
  10.   set t1_idxcntsv to t1_idxcnt
  11.   set t2_idxcntsv to t2_idxcnt
  12.   cur_busy()
  13.   repeat with i = 1 to 24
  14.     if AR1idx(mget, srcidx) <> 0 then
  15.       if i > 12 then
  16.         Ar1track(mput, destidx, 2)
  17.       else
  18.         Ar1track(mput, destidx, 1)
  19.       end if
  20.       AR1idx(mput, destidx, AR1idx(mget, srcidx))
  21.       move_ar1(destidx, srcidx)
  22.       set cpidx to cpidx + 1
  23.       set destidx to destidx + 1
  24.     end if
  25.     set srcidx to srcidx + 1
  26.   end repeat
  27.   AR1idx(mput, destidx + 1, 0)
  28.   set srcidx to 0
  29.   set destidx to cpy2buf
  30.   repeat with i = 1 to 24
  31.     if AR1idx(mget, srcidx) <> 0 then
  32.       if i > 13 then
  33.         Ar1track(mput, destidx, 2)
  34.       else
  35.         Ar1track(mput, destidx, 1)
  36.       end if
  37.       AR1idx(mput, destidx, AR1idx(mget, srcidx))
  38.       move_ar1(destidx, srcidx)
  39.       set destidx to destidx + 1
  40.     end if
  41.     set srcidx to srcidx + 1
  42.   end repeat
  43.   AR1idx(mput, destidx + 1, 0)
  44.   set t1_pos to 1
  45.   set t2_pos to 1
  46.   set t_pos to 1
  47.   cleanup()
  48.   cleanUpArrs()
  49.   updateStage()
  50.   set full to 0
  51.   set trackmove to 1
  52.   repeat while 1
  53.     if cpidx = 0 then
  54.       exit repeat
  55.     end if
  56.     repeat while 1
  57.       if t2_idxcntsv > 0 then
  58.         if trackmove > t1_idxcntsv then
  59.           set srcidx to random(cpidx) + cpy1buf - 1
  60.           set t_pos to t2_pos
  61.           if (t_pos + ar1seg(mget, srcidx)) <= 13 then
  62.             set t_add to 12
  63.             set destidx to t2_idxcnt + 1
  64.             exit repeat
  65.           end if
  66.         else
  67.           set srcidx to cpy1buf
  68.           set trackmove to trackmove + 1
  69.           set t_pos to t1_pos
  70.           if (t_pos + ar1seg(mget, srcidx)) <= 13 then
  71.             set t_add to 0
  72.             set destidx to t1_idxcnt + 1
  73.             exit repeat
  74.           end if
  75.         end if
  76.       else
  77.         set srcidx to random(cpidx) + cpy1buf - 1
  78.         set t_pos to t1_pos
  79.         if (t_pos + ar1seg(mget, srcidx)) <= 13 then
  80.           set t_add to 0
  81.           set destidx to t1_idxcnt + 1
  82.           exit repeat
  83.         end if
  84.       end if
  85.       set full to full + 1
  86.       if full > maxtrys then
  87.         cur_on()
  88.         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.")
  89.         cur_busy()
  90.         restorecircle(cpy2buf)
  91.         displaysegs()
  92.         cleanUpArrs(cpy1buf)
  93.         cleanUpArrs(cpy2buf)
  94.         cur_on()
  95.         exit repeat
  96.       end if
  97.     end repeat
  98.     if full > maxtrys then
  99.       exit
  100.     end if
  101.     AR1idx(mput, destidx + t_add, destidx + t_add)
  102.     move_ar1(destidx + t_add, srcidx)
  103.     ar1pos(mput, destidx + t_add, t_pos)
  104.     displaysegs()
  105.     if t_add = 0 then
  106.       set t1_pos to t1_pos + ar1seg(mget, srcidx)
  107.       set t1_segcnt to t1_segcnt + ar1seg(mget, srcidx)
  108.       set t1_idxcnt to t1_idxcnt + 1
  109.     else
  110.       set t2_pos to t2_pos + ar1seg(mget, srcidx)
  111.       set t2_segcnt to t2_segcnt + ar1seg(mget, srcidx)
  112.       set t2_idxcnt to t2_idxcnt + 1
  113.     end if
  114.     set tmp_idx to srcidx
  115.     repeat while 1
  116.       if AR1idx(mget, tmp_idx + 1) = 0 then
  117.         exit repeat
  118.       end if
  119.       AR1idx(mput, tmp_idx, AR1idx(mget, tmp_idx + 1))
  120.       move_ar1(tmp_idx, tmp_idx + 1)
  121.       set tmp_idx to tmp_idx + 1
  122.     end repeat
  123.     set cpidx to cpidx - 1
  124.   end repeat
  125.   cleanUpArrs(cpy1buf)
  126.   cleanUpArrs(cpy2buf)
  127.   cur_on()
  128. end
  129.  
  130. on restorecircle cpy2buf
  131.   global t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt
  132.   set srcidx to cpy2buf
  133.   set dest1idx to 0
  134.   set dest2idx to 0
  135.   set t1_segcnt to 0
  136.   set t2_segcnt to 0
  137.   set t1_idxcnt to 0
  138.   set t2_idxcnt to 0
  139.   cleanup()
  140.   cleanUpArrs()
  141.   updateStage()
  142.   repeat with i = 1 to 24
  143.     if AR1idx(mget, srcidx) <> 0 then
  144.       if Ar1track(mget, srcidx) = 2 then
  145.         set t_add to 12
  146.         set dest2idx to dest2idx + 1
  147.         set t2_idxcnt to t2_idxcnt + 1
  148.         set t2_segcnt to t2_segcnt + 1
  149.         set tidx to dest2idx
  150.       else
  151.         set t_add to 0
  152.         set dest1idx to dest1idx + 1
  153.         set t1_idxcnt to t1_idxcnt + 1
  154.         set t1_segcnt to t1_segcnt + 1
  155.         set tidx to dest1idx
  156.       end if
  157.       AR1idx(mput, tidx + t_add, tidx)
  158.       move_ar1(tidx + t_add, srcidx)
  159.       displaysegs()
  160.     end if
  161.     set srcidx to srcidx + 1
  162.   end repeat
  163. end
  164.  
  165. on move_ar1 destidx, srcidx
  166.   ar1pos(mput, destidx, ar1pos(mget, srcidx))
  167.   ar1seg(mput, destidx, ar1seg(mget, srcidx))
  168.   Ar1Vol(mput, destidx, Ar1Vol(mget, srcidx))
  169.   Ar1col(mput, destidx, Ar1col(mget, srcidx))
  170.   Ar1time(mput, destidx, Ar1time(mget, srcidx))
  171.   Ar1sound(mput, destidx, Ar1sound(mget, srcidx))
  172.   Ar1play(mput, destidx, Ar1play(mget, srcidx))
  173.   ar1cast(mput, destidx, ar1cast(mget, srcidx))
  174.   Ar1time(mput, destidx, Ar1time(mget, srcidx))
  175.   Ar1Sprite(mput, destidx, Ar1Sprite(mget, srcidx))
  176. end
  177.  
  178. on mixseg
  179.   global mix_vol1, mix_vol2, mix_ofs1, mix_fn1, mix_fn2, mix_fnO, mix_rate, mix_qua, mix_mon, mix_size, mix_err, sndobj
  180.   put "Mixing ...." & RETURN & " " & filenameMAC(mix_fn1) & " <> " & filenameMAC(mix_fn2) & "  " & RETURN & " Please wait ..." & mix_qua & RETURN, 1
  181.   set save2name to mix_fn2
  182.   set mix_err to 0
  183.   if the machineType <> 256 then
  184.     set src to mix_fn1
  185.     set dest to the pathName & "mixtmp.AIF"
  186.     if the machineType = 256 then
  187.       set mix_fn1 to src
  188.       set mix_fn2 to dest
  189.       set mix_err to sndobj(mFcopy)
  190.     else
  191.       sndobj(mfname1, src)
  192.       sndobj(mfname2, dest)
  193.       set mix_err to sndobj(mFcopy)
  194.     end if
  195.     if mix_err <> 0 then
  196.       alertrd("Error " & string(mix_err) & " while copying !", "Fehler " & string(mix_err) & " beim kopieren !")
  197.     end if
  198.     set mix_fn1 to the pathName & "mixtmp.AIF"
  199.     set mix_fn2 to save2name
  200.   end if
  201.   if the machineType <> 256 then
  202.     sndobj(mfname1, mix_fn1)
  203.     sndobj(mfname2, mix_fn2)
  204.     sndobj(mfnameo, mix_fnO)
  205.     sndobj(mvolume1, value(mix_vol1))
  206.     sndobj(mVolume2, value(mix_vol2))
  207.     sndobj(mOffset, integer(value(mix_ofs1)))
  208.     set mix_err to sndobj(mMixit)
  209.   else
  210.     sndobj(mMixit)
  211.   end if
  212.   alertrdremove()
  213.   if mix_err <> 0 then
  214.     alertrd("Error while mixing." & RETURN & "Code:>" & mix_err, "Fehler beim mixen." & RETURN & "Code:>" & mix_err)
  215.   end if
  216. end
  217.  
  218. on segsum start, stop
  219.   set retval to 0
  220.   if start > 12 then
  221.     set add to 12
  222.   else
  223.     set add to 0
  224.   end if
  225.   repeat with i = start to stop
  226.     if value(ar1seg(mget, i)) = 0 then
  227.       exit repeat
  228.     end if
  229.     set retval to retval + value(ar1seg(mget, i))
  230.   end repeat
  231.   return retval
  232. end
  233.  
  234. on circlemix
  235.   global mix_vol1, mix_vol2, mix_ofs1, mix_fn1, mix_fn2, mix_fnO, mix_seg, mix_pos, mix_segtime, mix_sl, mix_err, LED_1, LED_2, t1_idxcnt, t2_idxcnt, nn_mixcast, namepause_bs, areon, t1_segcnt, t2_segcnt, tret, ltl_len, ltl_time, ltl_scast, ltl_mix, fcommand
  236.   set fcommand to EMPTY
  237.   if (t1_segcnt = 0) and (t2_segcnt = 0) then
  238.     return 
  239.   end if
  240.   if areon = 1 then
  241.     set fcommand to "REMX"
  242.     return 
  243.   end if
  244.   set start1idx to ar_pos2idx(0, getstartidx(0))
  245.   set start2idx to ar_pos2idx(12, getstartidx(12))
  246.   set stop1idx to ar_pos2idxstop(0, getstopidx(0) - 1)
  247.   set stop2idx to ar_pos2idxstop(12, getstopidx(12) - 1)
  248.   set seg1 to segsum(start1idx, stop1idx)
  249.   set seg2 to segsum(start2idx, stop2idx)
  250.   if not (ar1pos(mget, start1idx) = ar1pos(mget, start2idx)) then
  251.     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.")
  252.     exit
  253.   end if
  254.   if stop1idx > (value(ar1pos(mget, start1idx)) + value(ar1seg(mget, start1idx))) then
  255.     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.")
  256.     exit
  257.   end if
  258.   if (start1idx > stop1idx) or (start2idx > stop2idx) then
  259.     alertrd("Set valid Looppoints for mixing 2 tracks.", "Zum mixen gueltige Looppunte setzen.")
  260.     exit
  261.   end if
  262.   if not (seg1 = seg2) then
  263.     alertrd("Set valid Looppoints for mixing 2 tracks." & RETURN & "Insert Empty Elements or adjust size", "Zum mixen gueltige Looppunte setzen oder Laenge aendern.")
  264.     exit
  265.   end if
  266.   if (ar1pos(mget, start1idx) + ar1seg(mget, start1idx)) > LED_2 then
  267.     put "1 > LED_2  >" & value(ar1pos(mget, start1idx)) & "<>" & value(ar1seg(mget, start1idx)) & "<>" & LED_2 & "<>" & stop1idx
  268.     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.")
  269.     put "mixerr 5"
  270.     exit
  271.   end if
  272.   if (ar1pos(mget, start2idx + 12) + ar1seg(mget, start2idx + 12)) > (LED_2 + 12) then
  273.     put "2 > LED_2  >" & value(ar1pos(mget, start2idx + 12)) & "<>" & value(ar1seg(mget, start2idx + 12)) & "<>" & LED_2 & "<>" & stop2idx
  274.     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.")
  275.     put "mixerr 6"
  276.     exit
  277.   end if
  278.   if (LED_2 - 1) > t1_segcnt then
  279.     put "end 1 >" & value(ar1pos(mget, stop1idx)) & "<>" & value(ar1seg(mget, stop1idx)) & "<>" & LED_2 & "<>" & stop1idx
  280.     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.")
  281.     put "mixerr 7"
  282.     exit
  283.   end if
  284.   set mix_err to "1"
  285.   set mix_ofs1 to "0"
  286.   set mix_idx to set_globmix(start1idx, start2idx, stop1idx, stop2idx)
  287.   put "mix_idx>" & mix_idx & " mixsegtime>" & string(mix_segtime) & " mixseg>" & mix_seg
  288.   if mix_idx = 0 then
  289.     exit
  290.   else
  291.     cur_busy()
  292.     mixseg()
  293.     set nn_mixcast to nn_mixcast + 1
  294.     set loopsl to mix_seg - mix_sl - 1
  295.   end if
  296.   repeat with i = 1 to loopsl
  297.     put "i >" & i & " loop>" & loopsl & " mix_sl>" & mix_sl
  298.     if mix_idx > 12 then
  299.       if (mix_idx + i) > stop2idx then
  300.         exit repeat
  301.       end if
  302.     else
  303.       if (mix_idx + i) > stop1idx then
  304.         exit repeat
  305.       end if
  306.     end if
  307.     set_globmixsl(mix_idx + i)
  308.     set mix_ofs1 to string(value(mix_ofs1) + (mix_segtime * ar1seg(mget, mix_idx + i)))
  309.     if not ((mix_fn1 = namepause_bs) or (mix_fn2 = namepause_bs) or (mix_fn1 = EMPTY) or (mix_fn2 = EMPTY)) then
  310.       put "mix_ofs1 >" & mix_ofs1 & " mix_segtime>" & mix_segtime & " i>" & i
  311.       mixseg()
  312.       set nn_mixcast to nn_mixcast + 1
  313.       put "SLSETOK" & "<>" & mix_fn1 & "<>" & mix_fn2
  314.       next repeat
  315.     end if
  316.     if mix_fn2 = namepause_bs then
  317.     end if
  318.     put "SLPAUSE" & "<>" & mix_fn1 & "<>" & mix_fn2
  319.   end repeat
  320.   put "sl_end"
  321.   if mix_err = 0 then
  322.     set tmpsize to readsound(the pathName & string(nn_mixcast - 1) & ".AIF", nn_mixcast - 1)
  323.     if tmpsize <> 0 then
  324.       set segtime to tmpsize / mix_seg
  325.       tl_insert(mix_pos, mix_seg, integer(segtime), nn_mixcast - 1, "M")
  326.       repeat with i = mix_pos + 1 to mix_pos + mix_seg - 1
  327.         put "tl_SL-------------"
  328.         tl_insert(i, "-", segtime, 0, "-")
  329.       end repeat
  330.       mixneed_off()
  331.     end if
  332.   end if
  333.   cur_on()
  334. end
  335.  
  336. on set_globmix start1idx, start2idx, stop1idx, stop2idx
  337.   global mix_vol1, mix_vol2, mix_ofs1, mix_fn1, mix_fn2, mix_fnO, mix_seg, mix_pos, nn_mixcast, namepause_bs, mix_segtime, tret, mix_sl
  338.   set mix_sl to 0
  339.   set mix_seg to value(ar1seg(mget, start1idx))
  340.   set mix_pos to value(ar1pos(mget, start1idx))
  341.   set mix_segtime to Ar1time(mget, start1idx) / mix_seg
  342.   set tret to 1
  343.   repeat while 1
  344.     set mix_fn1 to Ar1sound(mget, start1idx)
  345.     if mix_fn1 <> namepause_bs then
  346.       exit repeat
  347.     end if
  348.     set mix_ofs1 to string(value(mix_ofs1) + (ar1seg(mget, start1idx) * mix_segtime))
  349.     set mix_sl to mix_sl + ar1seg(mget, start1idx)
  350.     set start1idx to start1idx + 1
  351.     if start1idx > stop1idx then
  352.       put "start1idx > stop1idx"
  353.       return 0
  354.     end if
  355.   end repeat
  356.   repeat while 1
  357.     set mix_fn2 to Ar1sound(mget, start2idx)
  358.     if mix_fn2 <> namepause_bs then
  359.       if mix_fn2 <> mix_fn1 then
  360.         exit repeat
  361.       end if
  362.     end if
  363.     set mix_ofs1 to string(value(mix_ofs1) + (ar1seg(mget, start2idx) * mix_segtime))
  364.     set mix_sl to mix_sl + ar1seg(mget, start2idx)
  365.     set start2idx to start2idx + 1
  366.     if start2idx > stop2idx then
  367.       put "start2idx > stop2idx"
  368.       return 0
  369.     end if
  370.   end repeat
  371.   if (mix_fn1 = mix_fn2) and (value(mix_ofs1) = 0) then
  372.     put "mix_fn1 = mix_fn2"
  373.     return 0
  374.   else
  375.     set mix_vol1 to string(Ar1Vol(mget, start1idx) - 1)
  376.     set mix_vol2 to string(Ar1Vol(mget, start2idx) - 1)
  377.     set mix_fnO to the pathName & string(nn_mixcast) & ".aif"
  378.     if tret = 1 then
  379.       return start2idx
  380.     else
  381.       return start1idx
  382.     end if
  383.   end if
  384. end
  385.  
  386. on set_globmixsl startidx
  387.   global mix_vol1, mix_vol2, mix_ofs1, mix_fn1, mix_fn2, mix_fnO, mix_seg, mix_pos, nn_mixcast
  388.   set mix_fn1 to the pathName & string(nn_mixcast - 1) & ".aif"
  389.   set mix_fn2 to Ar1sound(mget, startidx)
  390.   set mix_vol1 to "15"
  391.   set mix_vol2 to string(Ar1Vol(mget, startidx) - 1)
  392.   set mix_fnO to the pathName & string(nn_mixcast) & ".aif"
  393. end
  394.  
  395. on mixneed_on
  396.   global mixneed
  397.   set mixneed to 1
  398. end
  399.  
  400. on mixneed_off
  401.   global mixneed
  402.   set mixneed to 0
  403. end
  404.  
  405. on fpos2idx pos, track
  406.   set reti to 0
  407.   set tmp to 0
  408.   repeat with i = track to 11 + track
  409.     set tmp to tmp + value(ar1seg(mget, i))
  410.     if tmp >= pos then
  411.       set reti to i
  412.       exit repeat
  413.     end if
  414.   end repeat
  415.   return reti
  416. end
  417.  
  418. on circleshrink
  419.   global fcommand, t1_idxcnt, t2_idxcnt, up_save, mixedloop, startidx, t1_segcnt, t2_segcnt, mix_idx1, sel_idx, demo
  420.   set fcommand to EMPTY
  421.   if demo then
  422.     demomixwin()
  423.     exit
  424.   end if
  425.   if t2_idxcnt = 0 then
  426.     return 
  427.   end if
  428.   if not mixedloop then
  429.     snd_mix(value(startidx))
  430.   end if
  431.   circlemaster()
  432.   cur_busy()
  433.   set sp to getspritenum("MIX")
  434.   set the castNum of sprite sp to the number of cast "MIX_PR"
  435.   set the ink of sprite sp to 8
  436.   sprite_show(sp, 282, 199)
  437.   updateStage()
  438.   set virtled to 1
  439.   repeat with idxlpcnt = 1 to t1_idxcnt
  440.     set dest to get_randfnmx("MX")
  441.     put "shrink idxlpcnt>" & idxlpcnt & " virtled>" & virtled & " dest >" & dest
  442.     do_saveseg(virtled, idxlpcnt, dest)
  443.     if Ar1play(mget, idxlpcnt) > 0 then
  444.       snd_close(value(Ar1play(mget, idxlpcnt)))
  445.     end if
  446.     set newidx to find_slot()
  447.     set sel_size to readsound(dest, newidx)
  448.     Ar1time(mput, idxlpcnt, sel_size)
  449.     Ar1sound(mput, idxlpcnt, dest)
  450.     Ar1play(mput, idxlpcnt, newidx)
  451.     set virtled to virtled + value(ar1seg(mget, idxlpcnt))
  452.   end repeat
  453.   cleanUpt2()
  454.   set sel_idx to 1
  455.   displaysegs()
  456.   circlemaster()
  457.   set sp to getspritenum("MIX")
  458.   set the castNum of sprite sp to the number of cast "MIX"
  459.   set the ink of sprite sp to 8
  460.   sprite_show(sp, 282, 199)
  461.   cur_on()
  462. end
  463.