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

  1. on mixit gosegs
  2.   global sndobj, mix_fn1, mix_fn2, mix_ofs1, mix_vol1, mix_vol2, mix_rate, mix_qua, mix_size, mix_mon, mix_err, mix_ofs2, mix_idx1, mix_idx2, mix_loop, mix_start, mix_end, up_sampm, fcommand, namepause_bs, 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, freemaster, m1_start, m2_start
  3.   set retvar to 1
  4.   if (p1_name <> namepause_bs) and (p2_name <> namepause_bs) and (p2_start < p2_time) and (p1_start < p1_time) then
  5.     set mix_idx1 to string(p1_cast)
  6.     set mix_idx2 to string(p2_cast)
  7.     set mix_vol1 to string(p1_vol)
  8.     set mix_vol2 to string(p2_vol)
  9.     set mix_start to string(integer(acmixdest))
  10.     set mix_ofs1 to string(integer(p1_start))
  11.     set mix_ofs2 to string(integer(p2_start))
  12.     if p1_start = p2_start then
  13.       set p_step to p1_stop
  14.       repeat with i = 1 to gosegs
  15.         if (value(ar1seg(mget, p1_idx)) > i) and (value(ar1seg(mget, p2_idx)) > i) then
  16.           set retvar to retvar + 1
  17.           set p1_stop to integer(p1_stop + p_step)
  18.           set mix_end to string(p1_stop)
  19.           next repeat
  20.         end if
  21.         exit repeat
  22.       end repeat
  23.     end if
  24.     if mix_ofs1 >= p1_stop then
  25.       alertrd("Error: ofs1 >stop on mix", "Fehler: ofs1 >stop on mix")
  26.     end if
  27.     if mix_ofs2 >= p2_stop then
  28.       alertrd("Error: ofs2 >stop on mix", "Fehler: ofs2 >stop on mix")
  29.     end if
  30.     set mix_end to string(p1_stop)
  31.     if p1_stop > p2_stop then
  32.       set p_stop to p1_stop
  33.     else
  34.       set p_stop to p2_stop
  35.     end if
  36.     if (value(mix_start) + value(mix_end)) > up_sampm then
  37.       err_mem()
  38.       return 0
  39.     else
  40.       set freemaster to up_sampm - (value(mix_start) + value(mix_end))
  41.       if the machineType = 256 then
  42.         set mix_err to sndobj(mSndMix)
  43.       else
  44.         set mix_err to sndobj(mMix, value(mix_idx1), value(mix_idx2), value(mix_vol1), value(mix_vol2), value(mix_start), value(mix_end), value(mix_ofs1), value(mix_ofs2))
  45.       end if
  46.       if mix_err <> 0 then
  47.         alertrd("SNDWORK: Error while mixing: " & string(mix_err), "SNDWORK: Fehler beim mixen: " & string(mix_err))
  48.         return 0
  49.       end if
  50.       set acmixdest to acmixdest + (p1_stop - p1_start)
  51.     end if
  52.   else
  53.     if (p1_name = namepause_bs) and (p2_name <> namepause_bs) then
  54.       ins_t2()
  55.     else
  56.       if p1_name <> namepause_bs then
  57.         ins_t1()
  58.       else
  59.         if (p1_name = namepause_bs) and (p2_name = namepause_bs) then
  60.           alertrd("Empty ELEMENTS on both tracks not allowed.", "Leere ELEMENTE auf beiden Spuren sind nicht erlaubt.")
  61.           return 0
  62.         end if
  63.       end if
  64.     end if
  65.   end if
  66.   return retvar
  67. end
  68.  
  69. on getpar1 led
  70.   global p1_idx, p1_start, p1_stop, p1_vol, p1_name, p1_cast, p1_time, circle_qua
  71.   set idx1 to getpos1idx(led)
  72.   if idx1 = 0 then
  73.     return 1
  74.   end if
  75.   set segcnt to 0
  76.   set tmppos to ar1pos(mget, idx1)
  77.   set segtime to integer(value(Ar1time(mget, idx1)) / value(ar1seg(mget, idx1)))
  78.   if circle_qua = "16" then
  79.     set segtime to integer(integer(segtime / 2) * 2)
  80.   end if
  81.   set p1_start to 0
  82.   set p1_vol to Ar1Vol(mget, idx1)
  83.   set p1_name to Ar1sound(mget, idx1)
  84.   set p1_stop to segtime
  85.   set p1_idx to idx1
  86.   set p1_cast to Ar1play(mget, idx1)
  87.   set p1_time to integer(value(Ar1time(mget, idx1)))
  88.   repeat while 1
  89.     if tmppos = led then
  90.       exit repeat
  91.     end if
  92.     if tmppos > led then
  93.       return 1
  94.     end if
  95.     set p1_start to integer(p1_start + segtime)
  96.     set p1_stop to integer(p1_stop + segtime)
  97.     set tmppos to tmppos + 1
  98.   end repeat
  99.   return 0
  100. end
  101.  
  102. on getpar2 led
  103.   global p2_idx, p2_start, p2_stop, p2_vol, p2_name, p2_cast, p2_time, t1_idxcnt, t2_idxcnt, circle_qua
  104.   set idx1 to getpos1idx(led)
  105.   set idx2 to getpos2idx(led)
  106.   if idx2 = 0 then
  107.     return 1
  108.   end if
  109.   set p2_time to integer(value(Ar1time(mget, idx2)))
  110.   set segcnt to 0
  111.   set tmppos to ar1pos(mget, idx2)
  112.   if idx1 = 0 then
  113.     set segtime to integer(value(Ar1time(mget, idx2)) / value(ar1seg(mget, idx2)))
  114.   else
  115.     set segtime to integer(value(Ar1time(mget, idx1)) / value(ar1seg(mget, idx1)))
  116.   end if
  117.   if circle_qua = "16" then
  118.     set segtime to integer(integer(segtime / 2) * 2)
  119.   end if
  120.   set p2_start to 0
  121.   set p2_vol to Ar1Vol(mget, idx2)
  122.   set p2_name to Ar1sound(mget, idx2)
  123.   set p2_stop to segtime
  124.   set p2_idx to idx2
  125.   set p2_cast to Ar1play(mget, idx2)
  126.   repeat while 1
  127.     if tmppos = led then
  128.       exit repeat
  129.     end if
  130.     if tmppos > led then
  131.       return 1
  132.     end if
  133.     set p2_start to integer(p2_start + segtime)
  134.     set p2_stop to integer(p2_stop + segtime)
  135.     set tmppos to tmppos + 1
  136.   end repeat
  137.   return 0
  138. end
  139.  
  140. on ins_t1
  141.   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, up_sampm, fcommand, namepause_bs, LED_1, LED_2, t1_idxcnt, t1_segcnt, t2_idxcnt, t2_segcnt, p1_idx, p1_start, p1_stop, p1_vol, p1_name, p1_cast, p2_idx, p2_start, p2_stop, p2_vol, p2_name, p2_cast, acmixdest, freemaster
  142.   if p1_name = namepause_bs then
  143.     alertrd("An empty ELEMENT only on one track is not allowed.", "Ein leeres ELEMENT nur auf einer Spur ist nicht erlaubt.")
  144.     return 0
  145.   end if
  146.   set mix_idx1 to string(p1_cast)
  147.   set mix_ofs1 to string(integer(acmixdest))
  148.   set mix_start to string(integer(p1_start))
  149.   set mix_end to string(integer(p1_stop - p1_start))
  150.   put ">>insert at1>" & mix_ofs1 & " start>" & mix_start & " len>" & mix_end & " ofs>" & mix_ofs1
  151.   if (value(mix_ofs1) + value(mix_end)) > up_sampm then
  152.     err_mem()
  153.     return 0
  154.   else
  155.     set freemaster to up_sampm - (value(mix_start) + value(mix_end))
  156.     if the machineType = 256 then
  157.       set mix_err to sndobj(msndinsert)
  158.     else
  159.       set mix_err to sndobj(mInsert, value(mix_idx1), value(mix_ofs1), value(mix_start), value(mix_end))
  160.     end if
  161.     if mix_err <> 0 then
  162.       alertrd("SNDWORK: Error while insert T1: " & string(mix_err), "SNDWORK: Fehler Einfuegen T1: " & string(mix_err))
  163.       return 0
  164.     end if
  165.     set acmixdest to integer(acmixdest + (p1_stop - p1_start))
  166.     put ">>ins_t1 new acmixdest>" & acmixdest
  167.     return 1
  168.   end if
  169. end
  170.  
  171. on ins_t2
  172.   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, up_sampm, LED_1, LED_2, t1_idxcnt, t1_segcnt, t2_idxcnt, t2_segcnt, p1_idx, p1_start, p1_stop, p1_vol, p1_name, p1_cast, p2_idx, p2_start, p2_stop, p2_vol, p2_name, p2_cast, acmixdest, freemaster
  173.   if p2_name = namepause_bs then
  174.     alertrd("An empty Element only on one track is not allowed.", "Ein leeres ELEMENT nur auf einer Spur ist nicht erlaubt.")
  175.     return 0
  176.   end if
  177.   set mix_idx1 to string(p2_cast)
  178.   set mix_ofs1 to string(integer(acmixdest))
  179.   set mix_start to string(integer(p2_start))
  180.   set mix_end to string(integer(p2_stop - p2_start))
  181.   put ">>insert at>" & mix_ofs1 & " start>" & mix_start & " stop>" & mix_end & " ofs>" & mix_ofs1
  182.   if (value(mix_ofs1) + value(mix_end)) > up_sampm then
  183.     err_mem()
  184.     return 0
  185.   else
  186.     set freemaster to up_sampm - (value(mix_start) + value(mix_end))
  187.     if the machineType = 256 then
  188.       set mix_err to sndobj(msndinsert)
  189.     else
  190.       set mix_err to sndobj(mInsert, value(mix_idx1), value(mix_ofs1), value(mix_start), value(mix_end))
  191.     end if
  192.     if mix_err <> 0 then
  193.       alertrd("SNDWORK: Error while insert T2: " & string(mix_err), "SNDWORK: Fehler Einfuegen T2: " & string(mix_err))
  194.       return 0
  195.     end if
  196.     set acmixdest to integer(acmixdest + (p2_stop - p2_start))
  197.     put ">>ins_t2 acmixdest>" & acmixdest
  198.     return 1
  199.   end if
  200. end
  201.  
  202. on getpos1idx led
  203.   global t1_idxcnt, t1_segcnt
  204.   set retvar to 0
  205.   repeat with i = t1_idxcnt down to 1
  206.     if value(ar1pos(mget, i)) <= led then
  207.       set retvar to i
  208.       if (value(ar1pos(mget, i)) + value(ar1seg(mget, i)) - 1) < led then
  209.         set retvar to 0
  210.       end if
  211.       exit repeat
  212.     end if
  213.   end repeat
  214.   return retvar
  215. end
  216.  
  217. on getpos2idx led
  218.   global t2_idxcnt, t2_segcnt
  219.   set retvar to 0
  220.   repeat with i = t2_idxcnt down to 1
  221.     if value(ar1pos(mget, i + 12)) <= led then
  222.       set retvar to i + 12
  223.       if (value(ar1pos(mget, i + 12)) + value(ar1seg(mget, i + 12)) - 1) < led then
  224.         set retvar to 0
  225.       end if
  226.       exit repeat
  227.     end if
  228.   end repeat
  229.   return retvar
  230. end
  231.  
  232. on circlefire
  233.   global junk, fcommand, MUTE, pastebuf, backcast, sample_rate, ticks_ps, circle_qua, loopidx, mix_idx1, mix_err, sndobj, last_play, mix_loop, cp_idx, up_mvol
  234.   put "circlefire"
  235.   set cidx to cp_idx
  236.   if pastebuf = 0 then
  237.     put "Before using FIRE , you have to copy a soundelemet"
  238.     if not (fcommand = "LOOP") then
  239.       set fcommand to EMPTY
  240.     end if
  241.     exit
  242.   end if
  243.   set junk to Ar1play(mget, cidx)
  244.   if not (fcommand = "LOOP") then
  245.     copywindow()
  246.     set fcommand to EMPTY
  247.   end if
  248.   startTimer()
  249.   snd_stop()
  250.   set mix_idx1 to string(junk)
  251.   set mix_vol1 to string(up_mvol)
  252.   set mix_loop to "1"
  253.   if the machineType = 256 then
  254.     set mix_err to sndobj(mSndPlay)
  255.   else
  256.     set mix_err to sndobj(mPlay, value(mix_idx1), value(mix_loop), value(mix_vol1))
  257.   end if
  258.   if mix_err <> 0 then
  259.     alertrd("SNDWORK Error while Playing Fire: " & mix_err, "SNDWORK beim FIRE abspielen: " & mix_err)
  260.   else
  261.     set last_play to string(pidx)
  262.   end if
  263.   waitforup()
  264.   if the machineType = 256 then
  265.     set mix_err to sndobj(mSndStop)
  266.   else
  267.     set mix_err to sndobj(mStop, value(mix_idx1))
  268.   end if
  269.   if not (fcommand = "LOOP") then
  270.     if backcast <> 0 then
  271.       setwindow(the name of cast backcast)
  272.     end if
  273.   end if
  274.   updateStage()
  275. end
  276.  
  277. on do_savemix
  278.   global ltl_scast, up_save, fcommand, new_read, mixedloop, mix_fn1, mix_start, mix_end, mix_err, sndobj, sel_name, scommand
  279.   set scommand to EMPTY
  280.   if the machineType = 256 then
  281.     set dest to up_save & sel_name
  282.   else
  283.     set dest to up_save & sel_name
  284.   end if
  285.   set startidx to getstartidx(0)
  286.   set stopidx to getstopidx(0)
  287.   set loopidx to startidx
  288.   if not mixedloop then
  289.     snd_mix(value(startidx))
  290.   end if
  291.   set startTime to tltimestart(startidx)
  292.   set stopTime to tltimestop(stopidx - 1)
  293.   cur_busy()
  294.   set mix_fn1 to dest
  295.   set mix_start to string(startTime)
  296.   set mix_end to string(stopTime)
  297.   if the machineType = 256 then
  298.     set mix_err to sndobj(mSndSave)
  299.   else
  300.     set mix_err to sndobj(mSave, mix_fn1, value(mix_start), value(mix_end))
  301.   end if
  302.   cur_on()
  303.   if mix_err <> 0 then
  304.     alertrd("SNDWORK: Error while saving !" & string(mix_err), "SNDWORK: Fehler beim speichern !" & string(mix_err))
  305.   end if
  306.   set new_read to 1
  307. end
  308.  
  309. on do_saveseg sidx, pidx, fn
  310.   global ltl_scast, up_save, fcommand, new_read, mix_fn1, mix_start, mix_end, mix_err, sndobj
  311.   set startidx to sidx
  312.   set startTime to tltimestart(startidx)
  313.   if the machineType = 256 then
  314.     set stopTime to startTime + value(Ar1time(mget, pidx))
  315.   else
  316.     set stopTime to value(Ar1time(mget, pidx))
  317.   end if
  318.   put "saveseg time>" & startTime & " stop>" & stopTime
  319.   set mix_fn1 to fn
  320.   set mix_start to string(startTime)
  321.   set mix_end to string(stopTime)
  322.   if the machineType = 256 then
  323.     set mix_err to sndobj(mSndSave)
  324.   else
  325.     set mix_err to sndobj(mSave, mix_fn1, value(mix_start), value(mix_end))
  326.   end if
  327.   if mix_err <> 0 then
  328.     alertrd("SNDWORK: Error while saving !" & string(mix_err), "SNDWORK: Fehler beim speichern !" & string(mix_err))
  329.   end if
  330.   set new_read to 1
  331. end
  332.  
  333. on do_savesegeff fn
  334.   global ltl_scast, up_temp, fcommand, new_read, mix_fn1, mix_start, mix_end, mix_err, sndobj, p1_start, p1_stop
  335.   set startTime to 0
  336.   if the machineType = 256 then
  337.     set stopTime to p1_stop
  338.   else
  339.     set stopTime to p1_stop
  340.   end if
  341.   put "savesegeff time>" & startTime & " stop>" & stopTime
  342.   set mix_fn1 to fn
  343.   set mix_start to string(startTime)
  344.   set mix_end to string(stopTime)
  345.   if the machineType = 256 then
  346.     set mix_err to sndobj(mSndSave)
  347.   else
  348.     set mix_err to sndobj(mSave, mix_fn1, value(mix_start), value(mix_end))
  349.   end if
  350.   if mix_err <> 0 then
  351.     alertrd("SNDWORK: Error while saving !" & string(mix_err), "SNDWORK: Fehler beim speichern !" & string(mix_err))
  352.   end if
  353.   set new_read to 1
  354. end
  355.  
  356. on err_mem
  357.   alertrd("Not enough memory !" & RETURN & "Increase the mastertrack memory", "Nicht genuegend Speicher fuer die Masterspur!" & RETURN & "Speicher fuer die Masterspur vergroessern.")
  358. end
  359.  
  360. on err_memsnd
  361.   alertrd("Not enough memory for this Sound !" & RETURN & "Decrease the mastertrack memory", "Nicht genuegend Speicher fuer diesen Sound!" & RETURN & "Speicher fuer die Masterspur verkleinern.")
  362. end
  363.  
  364. on sndpar fileName
  365.   global mix_rate, mix_qua, mix_mon, mix_size, mix_err, mix_fn1, sndobj
  366.   set mix_err to 0
  367.   set mix_fn1 to fileName
  368.   set mix_rate to "0"
  369.   set mix_qua to "0"
  370.   set mix_size to "0"
  371.   set mix_mon to "0"
  372.   if the machineType = 256 then
  373.     sndobj(msndcheck)
  374.   else
  375.     set macstr to sndobj(mSndPar, fileName)
  376.     if chars(macstr, 1, 5) = "ERROR" then
  377.       set mix_err to 1
  378.     else
  379.       set mix_err to 0
  380.       set mix_qua to word 1 of macstr
  381.       if word 2 of macstr = "1" then
  382.         set mix_mon to "mono"
  383.       end if
  384.       if word 2 of macstr = "2" then
  385.         set mix_mon to "stereo"
  386.       end if
  387.       set mix_size to word 3 of macstr
  388.       set mix_rate to word 4 of macstr
  389.     end if
  390.   end if
  391.   return value(mix_err)
  392. end
  393.  
  394. on effectplay
  395.   global 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, fcommand, acmixdest, up_mvol, t1_idxcnt, t2_idxcnt, mixedloop, stopidx, startidx, loopidx, last_play, startTime, stopTime, ltl_time, wait_time, loop_time, sndobj, mix_vol1, mix_start, mix_end, mix_ofs1, mix_err, leff_name, leff_time1, leff_time2, eff_lidx, eff_vol, eff_idx
  396.   set fcommand to EMPTY
  397.   snd_stop()
  398.   if not mixedloop then
  399.     mkeffect()
  400.   end if
  401.   set startTime to p1_start
  402.   set stopTime to p1_stop
  403.   set loop_time to stopTime
  404.   set last_play to string(0)
  405.   set mix_start to string(startTime)
  406.   set mix_end to string(stopTime - startTime)
  407.   set mix_vol1 to string(up_mvol)
  408.   set mix_ofs1 to "0"
  409.   if the machineType = 256 then
  410.     set mix_err to sndobj(mSndLoop)
  411.   else
  412.     if value(mix_vol1) > 15 then
  413.       set mix_vol1 to "15"
  414.     end if
  415.     set mix_err to sndobj(mLoop, value(mix_start), value(mix_end), value(mix_ofs1), value(mix_vol1))
  416.   end if
  417.   if mix_err <> 0 then
  418.     alertrd("SNDWORK Error while Effect Playing: " & mix_err, "SNDWORK Fehler beim Abspielen: " & mix_err)
  419.     set fcommand to EMPTY
  420.   end if
  421. end
  422.