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

  1. on sounddelete
  2.   global sel_pos, namepause_bs, backcast, fcommand, sel_track, sel_idx, segsprite, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt
  3.   set fcommand to EMPTY
  4.   set tmpi to 0
  5.   set tmp_idxcnt to 0
  6.   set sp to getspritenum("DEL")
  7.   set the castNum of sprite sp to the number of cast "DEL_PR"
  8.   set the ink of sprite sp to 8
  9.   sprite_show(sp, 189, 199)
  10.   updateStage()
  11.   if sel_track = 0 then
  12.     if selwin("Delete the whole CIRCLE ?", "Den gesamten CIRCLE loeschen ?") then
  13.       clear_circle()
  14.     end if
  15.     set sp to getspritenum("DEL")
  16.     set the castNum of sprite sp to the number of cast "DEL"
  17.     set the ink of sprite sp to 8
  18.     sprite_show(sp, 189, 199)
  19.     return 
  20.   end if
  21.   cur_busy()
  22.   if sel_track = 1 then
  23.     set t1_segcnt to integer(t1_segcnt - value(ar1seg(mget, sel_idx)))
  24.     set t1_idxcnt to t1_idxcnt - 1
  25.     set tmp_idxcnt to t1_idxcnt
  26.     set tmpi to sel_idx
  27.     set t_add to 0
  28.   else
  29.     set t2_segcnt to integer(t2_segcnt - value(ar1seg(mget, sel_idx)))
  30.     set t2_idxcnt to t2_idxcnt - 1
  31.     set tmp_idxcnt to t2_idxcnt
  32.     set tmpi to sel_idx - 12
  33.     set t_add to 12
  34.   end if
  35.   set delseg to ar1seg(mget, sel_idx)
  36.   set copyidx to sel_idx
  37.   if Ar1sound(mget, sel_idx) <> namepause_bs then
  38.     if Ar1play(mget, sel_idx) > 0 then
  39.       snd_close(value(Ar1play(mget, sel_idx)))
  40.     end if
  41.   end if
  42.   repeat while tmpi <= tmp_idxcnt
  43.     set vpos0 to integer(value(ar1pos(mget, copyidx + 1)) - delseg)
  44.     set vpos1 to lzero(vpos0)
  45.     ar1pos(mput, copyidx, string(vpos1))
  46.     AR1idx(mput, copyidx, AR1idx(mget, copyidx + 1) - 1)
  47.     ar1seg(mput, copyidx, ar1seg(mget, copyidx + 1))
  48.     Ar1Vol(mput, copyidx, Ar1Vol(mget, copyidx + 1))
  49.     Ar1col(mput, copyidx, Ar1col(mget, copyidx + 1))
  50.     Ar1time(mput, copyidx, Ar1time(mget, copyidx + 1))
  51.     Ar1sound(mput, copyidx, Ar1sound(mget, copyidx + 1))
  52.     Ar1play(mput, copyidx, Ar1play(mget, copyidx + 1))
  53.     ar1cast(mput, copyidx, ar1cast(mget, copyidx + 1))
  54.     Ar1time(mput, copyidx, Ar1time(mget, copyidx + 1))
  55.     Ar1Sprite(mput, copyidx, Ar1Sprite(mget, copyidx + 1))
  56.     set copyidx to copyidx + 1
  57.     set tmpi to tmpi + 1
  58.   end repeat
  59.   AR1idx(mput, copyidx, 0)
  60.   ar1pos(mput, copyidx, 0)
  61.   ar1seg(mput, copyidx, 0)
  62.   Ar1play(mput, copyidx, 0)
  63.   displaysegs()
  64.   set segsprite to 0
  65.   circlemaster()
  66.   set sp to getspritenum("DEL")
  67.   set the castNum of sprite sp to the number of cast "DEL"
  68.   set the ink of sprite sp to 8
  69.   sprite_show(sp, 189, 199)
  70.   cur_on()
  71. end
  72.  
  73. on circleinsert
  74.   global fcommand, t1pos, t2pos, MUTE, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt, AR_nnsc, sel_track, sel_pos, segsprite, sel_name, sel_txpos, sel_ttrak, tmp_segcnt
  75.   set fcommand to EMPTY
  76.   if sel_track = 0 then
  77.     if MUTE = 1 then
  78.       set tmp_segcnt to t1_segcnt
  79.       set sel_ttrak to "1"
  80.     else
  81.       set tmp_segcnt to t2_segcnt
  82.       set sel_ttrak to "2"
  83.     end if
  84.     set txpos to tmp_segcnt + 1
  85.   else
  86.     if sel_track = 1 then
  87.       set tmp_segcnt to t1_segcnt
  88.       set sel_ttrak to "1"
  89.       set txpos to sel_pos
  90.     else
  91.       if sel_track = 2 then
  92.         set tmp_segcnt to t2_segcnt
  93.         set sel_ttrak to "2"
  94.         set txpos to sel_pos
  95.       end if
  96.     end if
  97.   end if
  98.   if (tmp_segcnt + 1) > 12 then
  99.     alertrd("No more free soundelements on this track !", "Keine freien ELEMENTE auf dieser Spur !")
  100.     exit
  101.   end if
  102.   if isdemosegs(t1_idxcnt + t2_idxcnt) then
  103.     exit
  104.   end if
  105.   fsel("SOUND")
  106. end
  107.  
  108. on setseglen ttrak, txpos, tsize, tsndcast
  109.   global up_override, Citotaltime
  110.   set w_reqidx to value(txpos)
  111.   set w_rdidx to w_reqidx
  112.   set totaltime to 0
  113.   set totalseg to 0
  114.   set retval to 0
  115.   set tmpsize to tsize
  116.   if ttrak = 1 then
  117.     set offset to 12
  118.   else
  119.     set offset to 0
  120.   end if
  121.   repeat with i = 1 to 12
  122.     if ar1pos(mget, i) = txpos then
  123.       exit repeat
  124.     end if
  125.     if ar1pos(mget, i + 12) = txpos then
  126.       exit repeat
  127.     end if
  128.   end repeat
  129.   set st_idx to i
  130.   if i <= 12 then
  131.     repeat while 1
  132.       if AR1idx(mget, st_idx + offset) <= 0 then
  133.         if tsize > (totaltime + up_override) then
  134.           set retval to retval + 1
  135.         end if
  136.         exit repeat
  137.       end if
  138.       set totaltime to totaltime + Ar1time(mget, st_idx + offset)
  139.       set totalseg to totalseg
  140.       set retval to retval + ar1seg(mget, st_idx + offset)
  141.       if tsize <= (totaltime + up_override) then
  142.         exit repeat
  143.       end if
  144.       set st_idx to st_idx + 1
  145.     end repeat
  146.   end if
  147.   if retval < 1 then
  148.     set retval to 1
  149.   end if
  150.   if retval = 7 then
  151.     set retval to 8
  152.   end if
  153.   if retval = 10 then
  154.     set retval to 12
  155.   end if
  156.   if retval = 11 then
  157.     set retval to 12
  158.   end if
  159.   if retval > 12 then
  160.     set retval to 0
  161.   end if
  162.   return integer(retval)
  163. end
  164.  
  165. on dispsound ptrack, psound, ppos, plen, pvol, copyflag
  166.   global maxsegs, fcommand, gcast, firstsound, sample_offset, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt, AR_nnsc, sel_track, sel_idx, sel_pos, sel_size, pastebuf, newidx
  167.   set ppos to lzero(ppos)
  168.   set psize to 0
  169.   if sel_track = 0 then
  170.     if ptrack = "1" then
  171.       set sel_idx to t1_idxcnt + 1
  172.     else
  173.       set sel_idx to t2_idxcnt + 1 + 12
  174.     end if
  175.   else
  176.     set tmpidx to sel_idx
  177.     set tmpi to sel_idx
  178.     if sel_track = 1 then
  179.       set tmp_idxcnt to t1_idxcnt
  180.       set copyidx to tmp_idxcnt + 1
  181.       set ptrack to "1"
  182.     else
  183.       set tmp_idxcnt to t2_idxcnt + 12
  184.       set copyidx to tmp_idxcnt + 1
  185.       set ptrack to "2"
  186.     end if
  187.     repeat while tmpi <= tmp_idxcnt
  188.       set vpos0 to integer(value(ar1pos(mget, copyidx - 1)) + value(plen))
  189.       set vpos1 to string(vpos0)
  190.       if length(vpos1) < 2 then
  191.         set vpos1 to "0" & vpos1
  192.       end if
  193.       AR1idx(mput, copyidx, AR1idx(mget, copyidx - 1) + 1)
  194.       ar1pos(mput, copyidx, vpos1)
  195.       ar1seg(mput, copyidx, ar1seg(mget, copyidx - 1))
  196.       Ar1Vol(mput, copyidx, Ar1Vol(mget, copyidx - 1))
  197.       Ar1col(mput, copyidx, Ar1col(mget, copyidx - 1))
  198.       Ar1time(mput, copyidx, Ar1time(mget, copyidx - 1))
  199.       Ar1sound(mput, copyidx, Ar1sound(mget, copyidx - 1))
  200.       Ar1play(mput, copyidx, Ar1play(mget, copyidx - 1))
  201.       ar1cast(mput, copyidx, ar1cast(mget, copyidx - 1))
  202.       Ar1time(mput, copyidx, Ar1time(mget, copyidx - 1))
  203.       Ar1Sprite(mput, copyidx, Ar1Sprite(mget, copyidx - 1))
  204.       set copyidx to copyidx - 1
  205.       set tmpi to tmpi + 1
  206.     end repeat
  207.   end if
  208.   if copyflag = 0 then
  209.     set tmpcastno to newidx
  210.     set AR_nnsc to newidx
  211.     set pcol to calccol(psound)
  212.     set psize to sel_size
  213.   else
  214.     set tmpcastno to newidx
  215.     set AR_nnsc to AR_nnsc + 1
  216.     set pcol to Ar1col(mget, copyflag)
  217.     set psize to sel_size
  218.   end if
  219.   if ptrack = "1" then
  220.     set t1_segcnt to t1_segcnt + value(plen)
  221.     set t1_idxcnt to t1_idxcnt + 1
  222.   else
  223.     set t2_segcnt to t2_segcnt + value(plen)
  224.     set t2_idxcnt to t2_idxcnt + 1
  225.   end if
  226.   AR1idx(mput, sel_idx, sel_idx)
  227.   ar1pos(mput, sel_idx, ppos)
  228.   ar1seg(mput, sel_idx, plen)
  229.   Ar1Vol(mput, sel_idx, pvol)
  230.   Ar1col(mput, sel_idx, pcol)
  231.   Ar1sound(mput, sel_idx, psound)
  232.   Ar1time(mput, sel_idx, psize)
  233.   Ar1play(mput, sel_idx, tmpcastno)
  234. end
  235.  
  236. on getsoundname dummy
  237.   global fcommand, t1_segcnt, t2_segcnt, MUTE
  238.   set fcommand to EMPTY
  239.   set file to FileIO(mnew, "?read", "AIFF")
  240.   if not objectp(file) then
  241.     return EMPTY
  242.     exit
  243.   end if
  244.   set psound to file(mFileName)
  245.   file(mdispose)
  246.   return psound
  247. end
  248.  
  249. on soundcopy
  250.   global fcommand, gcast, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt, AR_nnsc, sel_track, sel_idx, sel_pos, pastebuf, demo, sample_offset, namepause_bs, cp_idx
  251.   set fcommand to EMPTY
  252.   if sel_track = 0 then
  253.     alertrd("Select a ELEMENT for copying", "Zum Kopieren ein ELEMENT auswaehlen !")
  254.     return 0
  255.   else
  256.     set copyidx to sel_idx
  257.     set destidx to cp_idx
  258.     Ar1Vol(mput, destidx, Ar1Vol(mget, copyidx))
  259.     Ar1col(mput, destidx, Ar1col(mget, copyidx))
  260.     Ar1time(mput, destidx, Ar1time(mget, copyidx))
  261.     set cps to Ar1sound(mget, copyidx)
  262.     if cps = namepause_bs then
  263.       exit
  264.       return 0
  265.     else
  266.       Ar1sound(mput, destidx, cps)
  267.     end if
  268.     if pastebuf = 0 then
  269.       set tmpsprite to getspritenum("FIRE")
  270.       set the visible of sprite tmpsprite to 1
  271.     end if
  272.     ar1cast(mput, destidx, ar1cast(mget, copyidx))
  273.     if charToNum(chars(cps, length(cps), length(cps))) < 33 then
  274.       set tmpsound to chars(cps, 1, length(cps) - 1)
  275.     else
  276.       set tmpsound to cps
  277.     end if
  278.     cur_busy()
  279.     set tsize to readsound(tmpsound, destidx)
  280.     Ar1play(mput, destidx, destidx)
  281.     set pastebuf to pastebuf + 1
  282.     copywindow()
  283.     cur_on()
  284.     return 1
  285.   end if
  286. end
  287.  
  288. on soundpaste
  289.   global fcommand, MUTE, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt, AR_nnsc, sel_track, sel_pos, segsprite, pastebuf, newidx, demo, cp_idx
  290.   set fcommand to EMPTY
  291.   set cidx to cp_idx
  292.   if pastebuf = 0 then
  293.     alertrd("No ELEMENT in the Copybuffer !", "Kein ELEMENT im Kopierpuffer !")
  294.     return 0
  295.   end if
  296.   if demo then
  297.     if isdemosegs(t1_idxcnt + t2_idxcnt) then
  298.       return 0
  299.     end if
  300.   end if
  301.   set tmpname to Ar1sound(mget, cidx)
  302.   if tmpname = EMPTY then
  303.     exit
  304.   end if
  305.   if sel_track = 0 then
  306.     if MUTE = 1 then
  307.       set tmp_segcnt to t1_segcnt
  308.       set ttrak to "1"
  309.       set t_add to 0
  310.     else
  311.       set tmp_segcnt to t2_segcnt
  312.       set ttrak to "2"
  313.       set t_add to 12
  314.     end if
  315.     set txpos to tmp_segcnt + 1
  316.   else
  317.     if sel_track = 1 then
  318.       set tmp_segcnt to t1_segcnt
  319.       set ttrak to "1"
  320.       set t_add to 0
  321.       set txpos to sel_pos
  322.     else
  323.       if sel_track = 2 then
  324.         set tmp_segcnt to t2_segcnt
  325.         set ttrak to "2"
  326.         set t_add to 12
  327.         set txpos to sel_pos
  328.       end if
  329.     end if
  330.   end if
  331.   put "paste1 t1_segcnt>" & t1_segcnt & "t2_segcnt>" & t2_segcnt & "tmp_segcnt>" & tmp_segcnt
  332.   if (tmp_segcnt + 1) > 12 then
  333.     alertrd("No more free soundelements on this track !", "Keine freien ELEMENTE auf dieser Spur !")
  334.     return 0
  335.   end if
  336.   cur_busy()
  337.   set newidx to find_slot()
  338.   if demo then
  339.     set tsize to readsound(tmpname, newidx)
  340.   else
  341.     set tsize to readsound(tmpname, newidx)
  342.   end if
  343.   dispsound(ttrak, tmpname, txpos, "1", "16", cidx)
  344.   displaysegs()
  345.   set segsprite to 0
  346.   setmastervol()
  347.   cur_on()
  348.   return 1
  349. end
  350.  
  351. on circlepause
  352.   global fcommand, t1pos, t2pos, MUTE, t1_segcnt, t2_segcnt, t1_idxcnt, t2_idxcnt, AR_nnsc, sel_track, sel_pos, segsprite, namepause_bs, newidx
  353.   set fcommand to EMPTY
  354.   set tmpname to namepause_bs
  355.   if sel_track = 0 then
  356.     if MUTE = 1 then
  357.       set tmp_segcnt to t1_segcnt
  358.       set ttrak to "1"
  359.       set t_add to 0
  360.     else
  361.       set tmp_segcnt to t2_segcnt
  362.       set ttrak to "2"
  363.       set t_add to 12
  364.     end if
  365.     set txpos to tmp_segcnt + 1
  366.   else
  367.     if sel_track = 1 then
  368.       set tmp_segcnt to t1_segcnt
  369.       set ttrak to "1"
  370.       set t_add to 0
  371.       set txpos to sel_pos
  372.     else
  373.       if sel_track = 2 then
  374.         set tmp_segcnt to t2_segcnt
  375.         set ttrak to "2"
  376.         set t_add to 12
  377.         set txpos to sel_pos
  378.       end if
  379.     end if
  380.   end if
  381.   if (tmp_segcnt + 1) > 12 then
  382.     alertrd("No more free ELEMENTS on this track !", "Keine freien ELEMENTE auf dieser Spur !")
  383.     exit
  384.   end if
  385.   cur_busy()
  386.   set tsize to get_pausesize(value(txpos), sel_track)
  387.   if tsize <> 0 then
  388.     set newidx to find_slot()
  389.     set st_seglen to "01"
  390.     dispsound(ttrak, tmpname, txpos, st_seglen, 16, 0)
  391.     displaysegs()
  392.     set segsprite to 0
  393.     setmastervol()
  394.   end if
  395.   cur_on()
  396. end
  397.  
  398. on get_pausesize pos, track
  399.   global ltl_len, ltl_mix, ltl_scast, ltl_time
  400.   set opptrack to value(getAt(ltl_mix, pos))
  401.   if pos > tl_maxpos(1) then
  402.     return 0
  403.   else
  404.     return getAt(ltl_time, pos)
  405.   end if
  406. end
  407.  
  408. on d_copy sw
  409.   global cp_idx, cp_1, cp_2
  410.   if sw = 1 then
  411.     set cp_idx to 25
  412.     if soundcopy() then
  413.       cp1set(1)
  414.     end if
  415.   else
  416.     set cp_idx to 26
  417.     if soundcopy() then
  418.       cp2set(1)
  419.     end if
  420.   end if
  421. end
  422.  
  423. on d_paste sw
  424.   global cp_idx, cp_1, cp_2, pastebuf
  425.   if sw = 1 then
  426.     set cp_idx to 25
  427.     if soundpaste() then
  428.       if not (the shiftDown) then
  429.         cp1set(0)
  430.         set pastebuf to pastebuf - 1
  431.       end if
  432.     end if
  433.   else
  434.     set cp_idx to 26
  435.     if soundpaste() then
  436.       if not (the shiftDown) then
  437.         cp2set(0)
  438.         set pastebuf to pastebuf - 1
  439.       end if
  440.     end if
  441.   end if
  442.   if pastebuf = 0 then
  443.     set tmpsprite to getspritenum("FIRE")
  444.     set the visible of sprite tmpsprite to 0
  445.   end if
  446. end
  447.  
  448. on cp1set sw
  449.   global cp_1, cp_idx
  450.   set tmpsprite to getspritenum("BF_CP1")
  451.   if sw = 1 then
  452.     set the foreColor of sprite tmpsprite to Ar1col(mget, cp_idx)
  453.     sprite_show(tmpsprite, 557, 79)
  454.     set cp_1 to 1
  455.   else
  456.     sprite_blank(tmpsprite)
  457.     set cp_1 to 0
  458.   end if
  459. end
  460.  
  461. on cp2set sw
  462.   global cp_2, cp_idx
  463.   set tmpsprite to getspritenum("BF_CP2")
  464.   if sw = 1 then
  465.     set the foreColor of sprite tmpsprite to Ar1col(mget, cp_idx)
  466.     sprite_show(tmpsprite, 609, 79)
  467.     set cp_2 to 1
  468.   else
  469.     sprite_blank(tmpsprite)
  470.     set cp_2 to 0
  471.   end if
  472. end
  473.  
  474. on circlemaster
  475.   global fcommand, backcast, segsprite, segcol, last_mute
  476.   set backcast to 0
  477.   setmastervol()
  478.   if segsprite <> 0 then
  479.     flashback(segsprite, segcol)
  480.   end if
  481.   if last_mute > 0 then
  482.     if last_mute = 2 then
  483.       mute0off()
  484.       mute2On()
  485.     else
  486.       mute0off()
  487.       mute1On()
  488.     end if
  489.     set last_mute to 0
  490.   end if
  491.   segszklick()
  492. end
  493.  
  494. on clear_circle
  495.   global backcast, freemaster, up_sampm, MUTE
  496.   cur_busy()
  497.   set backcast to 0
  498.   set freemaster to up_sampm
  499.   setmastervol()
  500.   cleanup()
  501.   cleanUpArrs()
  502.   cleanupsounds()
  503.   set MUTE to 2
  504.   muteklick()
  505.   cur_on()
  506. end
  507.