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

  1. on find_slot
  2.   repeat with i = 1 to 24
  3.     repeat with c = 1 to 24
  4.       set chk to Ar1play(mget, c)
  5.       if value(chk) = i then
  6.         exit repeat
  7.       end if
  8.       if c = 24 then
  9.         return i
  10.       end if
  11.     end repeat
  12.   end repeat
  13. end
  14.  
  15. on chk_slot
  16.   repeat with i = 1 to 24
  17.   end repeat
  18. end
  19.  
  20. on snd_init
  21.   global sndobj, mix_err, mix_vol1, mix_ofs1, up_mem
  22.   set mix_ofs1 to string(integer(up_mem * 100000))
  23.   set mix_vol1 to "1"
  24.   if the machineType = 256 then
  25.     set mix_err to sndobj(mSndInit)
  26.   else
  27.     set mix_err to sndobj(mInit, value(mix_ofs1))
  28.   end if
  29.   if mix_err <> 0 then
  30.     alert("SNDWORK Error while Init: " & mix_err)
  31.     return 0
  32.   end if
  33.   return 1
  34. end
  35.  
  36. on snd_stop
  37.   global sndobj, last_play, mix_idx1, mix_err, playing
  38.   set mix_idx1 to string(last_play)
  39.   if the machineType = 256 then
  40.     set mix_err to sndobj(mSndStop)
  41.   else
  42.     set mix_err to sndobj(mStop, value(mix_idx1))
  43.   end if
  44.   if mix_err <> 0 then
  45.   end if
  46.   set playing to 0
  47. end
  48.  
  49. on snd_close idx
  50.   global sndobj, mix_err, mix_idx1
  51.   set mix_idx1 to string(idx)
  52.   if the machineType = 256 then
  53.     set mix_err to sndobj(mSndClose)
  54.   else
  55.     set mix_err to sndobj(mClose, value(mix_idx1))
  56.   end if
  57.   if mix_err <> 0 then
  58.     put "SNDWORK Error while Close: " & string(mix_err)
  59.   end if
  60. end
  61.  
  62. on snd_done
  63.   global sndobj, mix_err
  64.   if the machineType = 256 then
  65.     if objectp(sndobj) then
  66.       set mix_err to sndobj(mSndDone)
  67.     end if
  68.   else
  69.     if objectp(sndobj) then
  70.       set mix_err to sndobj(mDone)
  71.     end if
  72.   end if
  73.   if mix_err <> 0 then
  74.     alert("SNDWORK Error while Done: " & mix_err)
  75.   end if
  76. end
  77.  
  78. on readsound psound, scast, msg
  79.   global fcommand, scommand, sel_scast, sel_size, acwin, fl_msg, enterFrame, firstsound, sample_rate, sample_offset, circle_qua, enterFrame, enterFrame, enterFrame, sndobj, mix_fn1, mix_fn2, mix_ofs1, mix_vol1, mix_vol2, mix_err, mix_rate, mix_qua, mix_size, mix_mon, mix_idx1, mix_idx2, mix_loop, mix_start, mix_end
  80.   set psound to stripcrtlchars(psound)
  81.   put "readsound>" & psound & "< scast>" & scast & "< msg>" & msg & "<"
  82.   if not (sndpar(psound) = 0) then
  83.     if value(msg) = 0 then
  84.       cur_on()
  85.       alertrd("Can`t identify soundfile type while reading !" & RETURN & psound & "<>", "Soundformatfehler beim Laden !" & RETURN & psound & "<>")
  86.       cur_busy()
  87.     end if
  88.     return 0
  89.   end if
  90.   if ((mix_size * (value(circle_qua) / 8)) + 200) >= the freeBytes then
  91.     cur_on()
  92.     err_memsnd()
  93.     cur_busy()
  94.     return 0
  95.   end if
  96.   if not firstsound then
  97.     if not (mix_qua = circle_qua) then
  98.       cur_on()
  99.       alertrd("This Cirle was not set for this" & RETURN & "soundparameters ! (Bits/Rate/Mode)", "Dieser CIRCLE arbeitet mit einem anderen" & RETURN & "Soundformat ! (Bits/Rate/Mode)")
  100.       return 0
  101.     end if
  102.   else
  103.     mem_update()
  104.   end if
  105.   if circle_qua = "16" then
  106.     if demobit() then
  107.       return 0
  108.     end if
  109.   end if
  110.   set mix_idx1 to string(scast)
  111.   set mix_fn1 to psound
  112.   put "load scast>" & scast & "< sel_c>" & sel_scast & " mix_idx1>" & mix_idx1
  113.   if the machineType = 256 then
  114.     set mix_err to sndobj(mSndClose)
  115.     set mix_err to sndobj(mSndLoad)
  116.   else
  117.     set mix_err to sndobj(mClose, value(mix_idx1))
  118.     set mix_err to sndobj(mLoad, value(mix_idx1), mix_fn1)
  119.   end if
  120.   if mix_err <> 0 then
  121.     if value(msg) = 0 then
  122.       alertrd("SNDWORK Error while loading: " & mix_err, "SNDWORK Fehler beim Laden: " & mix_err)
  123.     end if
  124.   else
  125.     set tmp_size to value(mix_size)
  126.     if firstsound then
  127.       set sample_rate to mix_rate
  128.       set circle_qua to mix_qua
  129.       set firstsound to 0
  130.     end if
  131.   end if
  132.   if circle_qua = "16" then
  133.     set tmp_size to integer(integer(tmp_size / 2) * 2)
  134.   end if
  135.   set sel_size to tmp_size
  136.   put "loaded>>>" & tmp_size
  137.   return tmp_size
  138. end
  139.  
  140. on circleplay
  141.   global fcommand, sel_idx, sel_track, namepause_bs, sndobj, mix_vol1, mix_err, mix_idx1, mix_loop, last_play
  142.   set fcommand to EMPTY
  143.   if sel_track <> 0 then
  144.     set pidx to Ar1play(mget, sel_idx)
  145.     set pvol to Ar1Vol(mget, sel_idx)
  146.     if Ar1sound(mget, sel_idx) = namepause_bs then
  147.       exit
  148.     end if
  149.     snd_stop()
  150.     set mix_idx1 to string(pidx)
  151.     set mix_vol1 to string(pvol)
  152.     set mix_loop to "0"
  153.     if the machineType = 256 then
  154.       set mix_err to sndobj(mSndPlay)
  155.     else
  156.       if value(mix_vol1) > 15 then
  157.         set mix_vol1 to "15"
  158.       end if
  159.       set mix_err to sndobj(mPlay, value(mix_idx1), value(mix_loop), value(mix_vol1))
  160.     end if
  161.     if mix_err <> 0 then
  162.       alertrd("SNDWORK Error while Playing: " & mix_err, "SNDWORK Fehler beim Abspielen: " & mix_err)
  163.     else
  164.       set last_play to string(pidx)
  165.     end if
  166.     waitforup()
  167.   end if
  168. end
  169.  
  170. on circleloopinit
  171.   global fcommand, t1_idxcnt, t2_idxcnt, mixedloop, starttimeticks, stopidx, startidx, loopidx, last_play, startTime, stopTime, ltl_time, wait_time, loop_time, sndobj, mix_vol1, mix_start, mix_end, mix_ofs1, mix_err, up_mvol
  172.   set the floatPrecision to 16
  173.   set fcommand to EMPTY
  174.   snd_stop()
  175.   if (t1_idxcnt = 0) and (t2_idxcnt = 0) then
  176.     return 
  177.   end if
  178.   set startidx to getstartidx(0)
  179.   set stopidx to getstopidx(0)
  180.   set loopidx to startidx
  181.   if not mixedloop then
  182.     if snd_mix(value(startidx)) then
  183.       set mixedloop to 1
  184.     else
  185.       exit
  186.     end if
  187.   end if
  188.   set startTime to integer(tltimestart(startidx))
  189.   set stopTime to integer(tltimestop(stopidx - 1))
  190.   set loop_time to stopTime
  191.   WALK(mnew, loopidx)
  192.   startTimer()
  193.   set wait_time to float(calcticks(getAt(ltl_time, loopidx)))
  194.   set sp to getspritenum("LOP")
  195.   set the castNum of sprite sp to the number of cast "LOP_do"
  196.   set the ink of sprite sp to 8
  197.   sprite_show(sp, 235, 292)
  198.   set last_play to string(0)
  199.   set fcommand to "LOOP"
  200.   set mix_start to string(integer(startTime))
  201.   set mix_end to string(integer(stopTime - startTime))
  202.   set mix_vol1 to string(up_mvol)
  203.   set mix_ofs1 to "1"
  204.   if the machineType = 256 then
  205.     set mix_err to sndobj(mSndLoop)
  206.   else
  207.     if value(mix_vol1) > 15 then
  208.       set mix_vol1 to "15"
  209.     end if
  210.     set mix_err to sndobj(mLoop, value(mix_start), value(mix_end), value(mix_ofs1), value(mix_vol1))
  211.   end if
  212.   if mix_err <> 0 then
  213.     put "initloop err"
  214.     alertrd("SNDWORK Error while Playing: " & mix_err, "SNDWORK Fehler beim Abspielen: " & mix_err)
  215.     set sp to getspritenum("LOP")
  216.     set the castNum of sprite sp to the number of cast "LOP"
  217.     set the ink of sprite sp to 8
  218.     sprite_show(sp, 235, 292)
  219.     set fcommand to EMPTY
  220.   end if
  221. end
  222.  
  223. on circleloopplay
  224.   global fcommand, t_add, MUTE, pastebuf, t1_idxcnt, t2_idxcnt, ARLEDs, s_ticks, e_ticks, junkvol, areon, stopidx, startidx, loopidx, enterFrame, junk_cst, junk_vol, junk_time, LED_1, enterFrame, up_override, ltl_time, wait_time, loop_time, last_play, startTime, stopTime, up_mvol, starttimeticks
  225.   if the mouseDown and (the mouseCast = the number of cast "fire") and (pastebuf <> 0) then
  226.     circlefire()
  227.     set loopidx to startidx
  228.     WALK(mnew, loopidx)
  229.     startTimer()
  230.     set wait_time to calcticks(getAt(ltl_time, loopidx))
  231.     set last_play to string(0)
  232.     set fcommand to "LOOP"
  233.     set mix_start to string(integer(startTime))
  234.     set mix_end to string(integer(stopTime - startTime))
  235.     set mix_vol1 to string(up_mvol)
  236.     set mix_ofs1 to "1"
  237.     if the machineType = 256 then
  238.       set mix_err to sndobj(mSndLoop)
  239.     else
  240.       if value(mix_vol1) > 15 then
  241.         set mix_vol1 to "15"
  242.       end if
  243.       set mix_err to sndobj(mLoop, value(mix_start), value(mix_end), value(mix_ofs1), value(mix_vol1))
  244.     end if
  245.     if mix_err <> 0 then
  246.       alertrd("SNDWORK Error while Playing: " & mix_err, "SNDWORK Fehler beim Abspielen: " & mix_err)
  247.       set fcommand to EMPTY
  248.     end if
  249.   end if
  250.   set the floatPrecision to 16
  251.   if the machineType = 256 then
  252.     set tmptimer to the timer * up_override
  253.   else
  254.     set tmptimer to the timer
  255.   end if
  256.   if tmptimer >= integer(wait_time) then
  257.     if loopidx >= (stopidx - 1) then
  258.       set loopidx to startidx
  259.       WALK(mmove, loopidx)
  260.       set wait_time to float(wait_time + calcticks(getAt(ltl_time, loopidx)))
  261.     else
  262.       set loopidx to loopidx + 1
  263.       WALK(mmove, loopidx)
  264.       set wait_time to float(wait_time + calcticks(getAt(ltl_time, loopidx)))
  265.     end if
  266.   end if
  267. end
  268.  
  269. on circleloopstop
  270.   global fcommand, sndobj, last_play, mix_idx1, mix_err
  271.   set mix_idx1 to string(0)
  272.   if the machineType = 256 then
  273.     set mix_err to sndobj(mSndStop)
  274.   else
  275.     set mix_err to sndobj(mStop, value(mix_idx1))
  276.   end if
  277.   if mix_err <> 0 then
  278.   end if
  279.   set fcommand to EMPTY
  280.   WALK(mrelease)
  281.   set sp to getspritenum("LOP")
  282.   set the castNum of sprite sp to the number of cast "LOP"
  283.   set the ink of sprite sp to 8
  284.   sprite_show(sp, 235, 292)
  285. end
  286.  
  287. on snd_mix lidx
  288.   global sndobj, mix_fn1, mix_fn2, mix_ofs1, mix_vol1, mix_vol2, mix_rate, mix_qua, mix_size, mix_mon, mix_err, mix_idx1, mix_idx2, mix_loop, mix_start, mix_end, fcommand, namepause_bs, areon, LED_1, LED_2, t1_idxcnt, t1_segcnt, t2_idxcnt, t2_segcnt, p1_idx, p1_start, p1_stop, p1_vol, p1_name, p1_cast, p1_time, p2_idx, p2_start, p2_stop, p2_vol, p2_name, p2_cast, p2_time, acmixdest
  289.   set fcommnad to EMPTY
  290.   if lidx > 0 then
  291.     set led to value(LED_1)
  292.   else
  293.     set led to 1
  294.   end if
  295.   if (t1_idxcnt = 0) and (t2_idxcnt = 0) then
  296.     return 
  297.   end if
  298.   if t1_idxcnt > t2_idxcnt then
  299.     set tmx to t1_idxcnt
  300.   else
  301.     set tmx to t2_idxcnt
  302.   end if
  303.   if t1_segcnt > t2_segcnt then
  304.     set tms to t1_segcnt
  305.   else
  306.     set tms to t2_segcnt
  307.   end if
  308.   if led > tms then
  309.     return 
  310.   end if
  311.   cur_busy()
  312.   set sp to getspritenum("MIX")
  313.   set the castNum of sprite sp to the number of cast "MIX_DO"
  314.   set the ink of sprite sp to 8
  315.   sprite_show(sp, 282, 199)
  316.   updateStage()
  317.   if areon = 2 then
  318.     if LED_2 > (tms + 1) then
  319.       set hl to "LD" & lzero(tms)
  320.       ledklick(hl)
  321.     else
  322.       set tms to LED_2 - 1
  323.     end if
  324.   end if
  325.   set acmixdest to tltimestart(led)
  326.   set t1ok to 1
  327.   set t2ok to 1
  328.   set i to led
  329.   repeat while 1
  330.     set t1ok to getpar1(i)
  331.     set t2ok to getpar2(i)
  332.     if (t1ok = 0) and (t2ok = 0) then
  333.       set mxret to mixit(tms - led)
  334.       if mxret = 0 then
  335.         exit repeat
  336.       end if
  337.       set i to i + mxret
  338.     else
  339.       if (t1ok = 0) and (t2ok <> 0) then
  340.         set mxret to ins_t1()
  341.         if mxret = 0 then
  342.           exit repeat
  343.         end if
  344.         set i to i + mxret
  345.       else
  346.         if (t1ok <> 0) and (t2ok = 0) then
  347.           set mxret to ins_t2()
  348.           if mxret = 0 then
  349.             exit repeat
  350.           end if
  351.           set i to i + mxret
  352.         else
  353.           if (t1ok <> 0) and (t2ok <> 0) then
  354.             set sp to getspritenum("MIX")
  355.             set the castNum of sprite sp to the number of cast "MIX"
  356.             set the ink of sprite sp to 8
  357.             sprite_show(sp, 282, 199)
  358.             cur_on()
  359.             return 
  360.           end if
  361.         end if
  362.       end if
  363.     end if
  364.     if i = (tms + 1) then
  365.       exit repeat
  366.     end if
  367.   end repeat
  368.   set sp to getspritenum("MIX")
  369.   set the castNum of sprite sp to the number of cast "MIX"
  370.   set the ink of sprite sp to 8
  371.   sprite_show(sp, 282, 199)
  372.   cur_on()
  373.   if mxret = 0 then
  374.     alertrd("Mixing Error !", "Fehler beim mixen !")
  375.     WALK(mrelease)
  376.     set sp to getspritenum("LOP")
  377.     set the castNum of sprite sp to the number of cast "LOP"
  378.     set the ink of sprite sp to 8
  379.     sprite_show(sp, 235, 292)
  380.     return 0
  381.   else
  382.     return 1
  383.   end if
  384. end
  385.