Advertisement
Ganeesya

onsei_plus.anm (aviutl script)

Nov 9th, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.51 KB | None | 0 0
  1. @周波数分析
  2. --track0:1フレーム横サイズ,1,100,3,1
  3. --track1:1周波数縦サイズ,1,100,10,1
  4. --track2:カラー閾値,1,10000,2000,1
  5. --track3:フォーカス周波数,1,256,1,1
  6. --file:
  7.  
  8. function split(str, delim)
  9.   if string.find(str,delim)==nil then
  10.     return { str }
  11.   end
  12.   local result = {}
  13.   local pat="(.-)"..delim.."()"
  14.   local lastPos
  15.   for part, pos in string.gfind(str,pat) do
  16.     table.insert(result,part)
  17.     lastPos=pos
  18.   end
  19.   table.insert(result,string.sub(str,lastPos))
  20.   return result
  21. end
  22.  
  23. datas = {}
  24. f=io.open(file)
  25. i = 1
  26. for line in f:lines() do
  27.   datas[i] = split(line,",")
  28.   i = i + 1
  29. end
  30. f:close()
  31.  
  32. obj.setoption("drawtarget","tempbuffer",obj.screen_w,obj.screen_h)
  33.  
  34. obj.load("figure","四角形",0xff0000,2)
  35. obj.drawpoly(0,           -obj.screen_h/2,  0
  36.             ,0,           obj.screen_h/2,   0
  37.             ,obj.track0,  obj.screen_h/2,   0
  38.             ,obj.track0,  -obj.screen_h/2,  0
  39.             ,0,0 ,1,0 ,1,1 ,0,1, 0.6)
  40.  
  41. obj.load("figure","四角形",0x0000ff,2)
  42. obj.drawpoly(-obj.screen_w/2  ,obj.screen_h/2-obj.track1 * (obj.track3-0),  0
  43.             ,-obj.screen_w/2  ,obj.screen_h/2-obj.track1 * (obj.track3-1),   0
  44.             , obj.screen_w/2  ,obj.screen_h/2-obj.track1 * (obj.track3-1),   0
  45.             , obj.screen_w/2  ,obj.screen_h/2-obj.track1 * (obj.track3-0),  0
  46.             ,0,0 ,1,0 ,1,1 ,0,1, 0.6)
  47.  
  48. scroll=-obj.frame*obj.track0
  49.  
  50. for i,v in ipairs(datas) do
  51.   if i * obj.track0 + scroll > -obj.screen_w/2 then
  52.     for j,x in ipairs(v) do
  53.       if tonumber(x) > obj.track2 then
  54.         clr = HSV(100-(tonumber(x) - obj.track2)/20,100,100)
  55.       else
  56.         clr = HSV(0,0,tonumber(x)/obj.track2*70)
  57.       end
  58.       obj.load("figure","円",clr)
  59.       obj.drawpoly( scroll + i * obj.track0       , obj.screen_h/2 - (j-1) * obj.track1  ,0
  60.                   , scroll + i * obj.track0       , obj.screen_h/2 - j * obj.track1      ,0
  61.                   , scroll + ( i - 1) * obj.track0, obj.screen_h/2 - j * obj.track1      ,0
  62.                   , scroll + ( i - 1) * obj.track0, obj.screen_h/2 - (j-1) * obj.track1  ,0)
  63.     end
  64.   end
  65.   if i * obj.track0 + scroll > obj.screen_w/2 then
  66.     break
  67.   end
  68. end
  69. obj.load("tempbuffer")
  70. obj.setoption("drawtarget","framebuffer")
  71. obj.draw()
  72.  
  73.  
  74. @音声読み込み
  75. --track0:周波数,1,1024,1,1
  76. --track1:オフセット,-1000000,1000000,0,1
  77. --track2:閾値,0,10000,2000,1
  78. --file:
  79. ff = obj.track0
  80. offset = obj.track1
  81.  
  82. function split(str, delim)
  83.   if string.find(str,delim)==nil then
  84.     return { str }
  85.   end
  86.   local result = {}
  87.   local pat="(.-)"..delim.."()"
  88.   local lastPos
  89.   for part, pos in string.gfind(str,pat) do
  90.     table.insert(result,part)
  91.     lastPos=pos
  92.   end
  93.   table.insert(result,string.sub(str,lastPos))
  94.   return result
  95. end
  96.  
  97. f=io.open(file)
  98. timedatas = split(f:read("*a"),"\n")
  99. f:close()
  100.  
  101. if timedatas[obj.frame+obj.track1-1] then
  102.   oldline = split(timedatas[obj.frame+obj.track1-1],",")[ff]
  103. end
  104.  
  105. if timedatas[obj.frame+obj.track1] then
  106.   nowline = split(timedatas[obj.frame+obj.track1],",")[ff]
  107. end
  108.  
  109. flag = false
  110. if tonumber(oldline) < obj.track2 and tonumber(nowline) > obj.track2 then
  111.   flag = true
  112. end
  113.  
  114. @山なり制御(拡大)
  115. --track0:底値,0,4000,100,0.01
  116. --track1:山値,0,4000,200,0.01
  117. --track2:ピークポイント,0,100,50,0.1
  118. --track3:継続フレーム,0,6000,15,1
  119. if not yamaz then
  120.   yamaz = {}
  121. end
  122.  
  123. if flag then
  124.   spPoint = math.floor(obj.track3*obj.track2/100.0)
  125.   for i=1,spPoint,1 do
  126.     lvl = math.pow(i/spPoint,2)
  127.     if not yamaz[i] or yamaz[i] < lvl then
  128.       yamaz[i] = lvl
  129.     end
  130.   end
  131.   for i=spPoint,obj.track3,1 do
  132.     lvl = math.pow( (obj.track3-i)/(obj.track3-spPoint) ,2)
  133.     if not yamaz[i] or yamaz[i] < lvl then
  134.       yamaz[i] = lvl
  135.     end    
  136.   end  
  137. end
  138.  
  139. if #yamaz > 0 then
  140.   obj.zoom = (yamaz[1]*obj.track1 + (1-yamaz[1])*obj.track0)/100
  141.   table.remove(yamaz,1)
  142. else
  143.   obj.zoom = obj.track0/100
  144. end
  145.  
  146. @山なり制御(回転)
  147. --track0:底値,-4000,4000,0,0.01
  148. --track1:山値,-4000,4000,90,0.01
  149. --track2:ピークポイント,0,1000,50,0.1
  150. --track3:継続フレーム,0,6000,15,1
  151. if not yamar then
  152.   yamar = {}
  153. end
  154.  
  155. if flag then
  156.   spPoint = math.floor(obj.track3*obj.track2/100.0)
  157.   for i=1,spPoint,1 do
  158.     lvl = math.pow(i/spPoint,2)
  159.     if not yamar[i] or yamar[i] < lvl then
  160.       yamar[i] = lvl
  161.     end
  162.   end
  163.   for i=spPoint,obj.track3,1 do
  164.     lvl = math.pow( (obj.track3-i)/(obj.track3-spPoint) ,2)
  165.     if not yamar[i] or yamar[i] < lvl then
  166.       yamar[i] = lvl
  167.     end    
  168.   end  
  169. end
  170.  
  171. if #yamar > 0 then
  172.   obj.rz = (yamar[1]*obj.track1 + (1-yamar[1])*obj.track0)
  173.   table.remove(yamar,1)
  174. else
  175.   obj.rz = obj.track0
  176. end
  177.  
  178.  
  179. @スイッチ制御(回転)
  180. --track0:値1,-4000,4000,0,0.01
  181. --track1:値2,-4000,4000,90,0.01
  182. --track2:継続フレーム,0,6000,15,1
  183. if not swr then
  184.   swr = {}
  185. end
  186.  
  187. if flag then
  188.   if swRollSide then
  189.     for i=1,obj.track2,1 do
  190.       lvl = i/obj.track2
  191.       if not swr[i] or swr[i] < lvl then
  192.         swr[i] = lvl
  193.       end
  194.     end  
  195.     swRollSide = false
  196.   else
  197.     for i=1,obj.track2,1 do
  198.       lvl = 1-i/obj.track2
  199.       if not swr[i] or swr[i] > lvl then
  200.         swr[i] = lvl
  201.       end
  202.     end  
  203.     swRollSide = true
  204.   end
  205. end
  206.  
  207. if #swr > 0 then
  208.   obj.rz = swr[1]*obj.track1 + (1-swr[1])*obj.track0
  209.   if #swr > 1 then
  210.     table.remove(swr,1)
  211.   end
  212. end
  213.  
  214.  
  215. @スイッチ制御(拡大)
  216. --track0:値1,-4000,4000,100,0.01
  217. --track1:値2,-4000,4000,200,0.01
  218. --track2:継続フレーム,0,6000,15,1
  219. if not swz then
  220.   swz = {}
  221. end
  222.  
  223. if flag then
  224.   if swZoomSide then
  225.     for i=1,obj.track2,1 do
  226.       lvl = i/obj.track2
  227.       if not swz[i] or swz[i] < lvl then
  228.         swz[i] = lvl
  229.       end
  230.     end  
  231.     swZoomSide = false
  232.   else
  233.     for i=1,obj.track2,1 do
  234.       lvl = 1-i/obj.track2
  235.       if not swz[i] or swz[i] > lvl then
  236.         swz[i] = lvl
  237.       end
  238.     end
  239.     swZoomSide = true
  240.   end
  241. end
  242.  
  243. if #swz > 0 then
  244.   obj.zoom = (swz[1]*obj.track1 + (1-swz[1])*obj.track0)/100
  245.   if #swz > 1 then
  246.     table.remove(swz,1)
  247.   end
  248. end
  249.  
  250.  
  251. @山なり制御(透明)
  252. --track0:底値,0,100,0,0.01
  253. --track1:山値,0,100,100,0.01
  254. --track2:ピークポイント,0,1000,50,0.1
  255. --track3:継続フレーム,0,6000,15,1
  256. if not yamaAl then
  257.   yamaAl = {}
  258. end
  259.  
  260. if flag then
  261.   spPoint = math.floor(obj.track3*obj.track2/100.0)
  262.   for i=1,spPoint,1 do
  263.     lvl = math.pow(i/spPoint,2)
  264.     if not yamaAl[i] or yamaAl[i] < lvl then
  265.       yamaAl[i] = lvl
  266.     end
  267.   end
  268.   for i=spPoint,obj.track3,1 do
  269.     lvl = math.pow( (obj.track3-i)/(obj.track3-spPoint) ,2)
  270.     if not yamaAl[i] or yamaAl[i] < lvl then
  271.       yamaAl[i] = lvl
  272.     end    
  273.   end  
  274. end
  275.  
  276. if #yamaAl > 0 then
  277.   obj.alpha = (yamaAl[1]*obj.track1 + (1-yamaAl[1])*obj.track0)/100
  278.   table.remove(yamaAl,1)
  279. else
  280.   obj.alpha = obj.track0/100
  281. end
  282.  
  283.  
  284. @スイッチ制御(透明)
  285. --track0:値1,0,100,0,0.01
  286. --track1:値2,0,100,100,0.01
  287. --track2:継続フレーム,0,6000,15,1
  288. if not swAl then
  289.   swAl = {}
  290. end
  291.  
  292. if flag then
  293.   if swRollSide then
  294.     for i=1,obj.track2,1 do
  295.       lvl = i/obj.track2
  296.       if not swAl[i] or swAl[i] < lvl then
  297.         swAl[i] = lvl
  298.       end
  299.     end  
  300.     swRollSide = false
  301.   else
  302.     for i=1,obj.track2,1 do
  303.       lvl = 1-i/obj.track2
  304.       if not swAl[i] or swAl[i] > lvl then
  305.         swAl[i] = lvl
  306.       end
  307.     end  
  308.     swRollSide = true
  309.   end
  310. end
  311.  
  312. if #swAl > 0 then
  313.   obj.alpha = (swAl[1]*obj.track1 + (1-swAl[1])*obj.track0)/100
  314.   if #swAl > 1 then
  315.     table.remove(swAl,1)
  316.   end
  317. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement