Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.83 KB | None | 0 0
  1. --
  2.  
  3. function lerp(a,b,c)
  4. return a+(b-a)*c
  5. end
  6. local admunz={"Jack_Shadow37","thejonathann","oxcool1",'ClassyUmadbro2bad','MakerModelLua','Nexure','Diitto'}
  7.  
  8. local fme="YourTrueEnd"
  9.  
  10. local mid = ""
  11.  
  12. local guis={}
  13.  
  14. local xnum = 2
  15.  
  16. local ynum = 3
  17.  
  18. local znum = 0
  19.  
  20. local soundscape = {}
  21.  
  22. SoundPoint = nil
  23.  
  24.  
  25. wait(1)
  26. function WaitChild(par,name)
  27. local obj = par:findFirstChild(name)
  28. while obj == nil do
  29. wait(0.25)
  30. obj = par:findFirstChild(name)
  31. end
  32. return obj
  33. end
  34.  
  35. reload_B64 = false
  36. SortSongByName = false
  37. Max_SLength = 131070
  38. DisregardMixerVolume = false
  39.  
  40. local properties = Instance.new("BoolValue",script)
  41. properties.Name = "Properties"
  42. local volume = Instance.new("NumberValue",properties)
  43. volume.Name = "Volume"
  44. volume.Value = 3
  45. local loop = Instance.new("BoolValue",properties)
  46. loop.Name = "Loop"
  47. local playthroughall = Instance.new("BoolValue",properties)
  48. playthroughall.Name = "PlayThroughAll"
  49. local advanced = Instance.new("BoolValue",properties)
  50. advanced.Name = "Advanced"
  51. local tempomod = Instance.new("IntValue",advanced)
  52. tempomod.Name = "TempoMOD"
  53. local songposset = Instance.new("NumberValue",advanced)
  54. songposset.Name = "SongPosSet"
  55. songposset.Value = 761.332
  56. local posget = Instance.new("BoolValue",advanced)
  57. posget.Name = "PosGet"
  58. local play = Instance.new("BoolValue",posget)
  59. play.Name = "Play"
  60. local songpos = Instance.new("NumberValue",posget)
  61. songpos.Name = "SongPos"
  62. local songid = Instance.new("IntValue",posget)
  63. songid.Name = "SongID"
  64. local songlength = Instance.new("NumberValue",posget)
  65. songlength.Name = "SongLength"
  66. local globalpitchmod = Instance.new("NumberValue",advanced)
  67. globalpitchmod.Name = "GlobalPitchMOD"
  68. local formuter = Instance.new("NumberValue",advanced)
  69. formuter.Name = "ForMuter"
  70. formuter.Value = 1
  71. local fastforward = Instance.new("BoolValue",advanced)
  72. fastforward.Name = "Fastforward"
  73. local debug = Instance.new("BoolValue",advanced)
  74. debug.Name = "Debug"
  75. local isplaying = Instance.new("BoolValue",advanced)
  76. isplaying.Name = "isPlaying"
  77. local stop = Instance.new("BoolValue",properties)
  78. stop.Name = "Stop"
  79. local play_2 = Instance.new("BoolValue",properties)
  80. play_2.Name = "Play"
  81. local pause = Instance.new("BoolValue",properties)
  82. pause.Name = "Pause"
  83.  
  84. local songa = Instance.new("IntValue",script)
  85. songa.Name = "Song"
  86. songa.Value=0
  87. local a = Instance.new("StringValue",songa)
  88. a.Name = "a"
  89. a.Value=[[]]
  90.  
  91. wait()
  92. function DefSpecialProp()
  93. svolume = WaitChild(prop,"Volume")
  94. Stop = WaitChild(prop,"Stop")
  95. loop = WaitChild(prop,"Loop")
  96. adv = WaitChild(prop,"Advanced")
  97. isPlaying = WaitChild(adv,"isPlaying")
  98. FFwrd = WaitChild(adv,"Fastforward")
  99. fmuter = WaitChild(adv,"ForMuter")
  100. songPS = WaitChild(adv,"SongPosSet")
  101. play = WaitChild(prop,"Play")
  102. tempoMod = WaitChild(adv,"TempoMOD")
  103. gpmod = WaitChild(adv,"GlobalPitchMOD")
  104. pause = WaitChild(prop,"Pause")
  105. pta = WaitChild(prop,"PlayThroughAll")
  106. pget = WaitChild(adv,"PosGet")
  107. sposOBJ = WaitChild(pget,"SongPos")
  108. songLGet = WaitChild(pget,"SongLength")
  109. songGet = WaitChild(pget,"SongID")
  110. end
  111.  
  112. function FindPlayer(name,Speaker)
  113. local found,rand = {},math.random(1,game.Players.NumPlayers)
  114. for word in name:gmatch("%S+")do
  115. for i,player in pairs(Game.Players:GetPlayers())do
  116. if player.Name:lower():find(word:lower())== 1
  117. or word:lower()== "all"
  118. or word:lower()== "everyone"
  119. or word:lower()== "everybody"
  120. or word:lower()== "everypony"
  121. or word:lower()== "local" and player == Speaker
  122. or word:lower()== "me" and player == Speaker
  123. or word:lower()== "others" and player ~= Speaker
  124. or word:lower()== "random" and i == rand then
  125. table.insert(found,player)
  126. end
  127. end
  128. end
  129. return found
  130. end
  131.  
  132. function addSS()
  133. local p = Instance.new("Part",workspace)
  134. p.Anchored = true
  135. p.FormFactor = "Custom"
  136. p:BreakJoints()
  137. p.TopSurface,p.BottomSurface = 0,0
  138. p.CanCollide = false
  139. p.Size = Vector3.new(1,1,1)
  140. p.Locked = true
  141. p.CFrame = getMiddleCFrame()
  142. local PL=Instance.new("PointLight",p)
  143. PL.Color= BrickColor.new("Royal purple").Color
  144. PL.Brightness=0
  145. local SM = Instance.new("SpecialMesh",p)
  146. SM.MeshId = "http://www.roblox.com/Asset/?id=9856898"
  147. SM.TextureId = "rbxassetid://3319251"
  148. SM.VertexColor = Vector3.new(0,0,0)
  149. SM.Scale = Vector3.new()
  150. table.insert(soundscape,p)
  151. return p
  152. end
  153.  
  154. function strhex(str)
  155. local res=''
  156. local hnt=Instance.new('Hint',workspace)
  157. hnt.Text='Decoding'
  158. for port in str:gmatch'.'do
  159. res=res..string.format('%02x',port:byte())
  160. end
  161. hnt:Destroy()
  162. return(res)
  163. end
  164.  
  165. local debris = game:GetService("Debris")
  166. function newSS(am)
  167. for i,v in pairs(soundscape) do for _,x in pairs(v:GetChildren()) do debris:AddItem(x,0) end debris:AddItem(v,.05) end
  168. soundscape = {}
  169. for i=1,am do
  170. addSS()
  171. end
  172. end
  173.  
  174. function SetStartValues()
  175. tempoMod.Value = 0
  176. play.Value = false
  177. Stop.Value = false
  178. end
  179.  
  180.  
  181. function ClrLerp(Mesh,Clr2,Step)
  182. Clr1 = Mesh.VertexColor
  183. Mesh.VertexColor = Vector3.new(lerp(Clr1.X,Clr2.X,Step),lerp(Clr1.Y,Clr2.Y,Step),lerp(Clr1.Z,Clr2.Z,Step))
  184. end
  185.  
  186. function getMiddleCFrame()
  187. cf = workspace:FindFirstChild(fme) and workspace[fme]:FindFirstChild("Torso") and workspace[fme].Torso:IsA("Part") and workspace[fme].Torso.CFrame + Vector3.new(0,3,0) or CFrame.new(0,10,0)
  188. return CFrame.new(cf.p)
  189. end
  190.  
  191. do
  192. local function QuaternionFromCFrame(cf) local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components() local trace = m00 + m11 + m22 if trace > 0 then local s = math.sqrt(1 + trace) local recip = 0.5/s return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5 else local i = 0 if m11 > m00 then i = 1 end if m22 > (i == 0 and m00 or m11) then i = 2 end if i == 0 then local s = math.sqrt(m00-m11-m22+1) local recip = 0.5/s return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip elseif i == 1 then local s = math.sqrt(m11-m22-m00+1) local recip = 0.5/s return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip elseif i == 2 then local s = math.sqrt(m22-m00-m11+1) local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip end end end
  193.  
  194. local function QuaternionToCFrame(px, py, pz, x, y, z, w) local xs, ys, zs = x + x, y + y, z + z local wx, wy, wz = w*xs, w*ys, w*zs local xx = x*xs local xy = x*ys local xz = x*zs local yy = y*ys local yz = y*zs local zz = z*zs return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy)) end
  195.  
  196. local function QuaternionSlerp(a, b, t) local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4] local startInterp, finishInterp; if cosTheta >= 0.0001 then if (1 - cosTheta) > 0.0001 then local theta = math.acos(cosTheta) local invSinTheta = 1/math.sin(theta) startInterp = math.sin((1-t)*theta)*invSinTheta finishInterp = math.sin(t*theta)*invSinTheta else startInterp = 1-t finishInterp = t end else if (1+cosTheta) > 0.0001 then local theta = math.acos(-cosTheta) local invSinTheta = 1/math.sin(theta) startInterp = math.sin((t-1)*theta)*invSinTheta finishInterp = math.sin(t*theta)*invSinTheta else startInterp = t-1 finishInterp = t end end return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp end
  197.  
  198. function clerp(a,b,t)
  199. local qa = {QuaternionFromCFrame(a)}
  200. local qb = {QuaternionFromCFrame(b)}
  201. local ax, ay, az = a.x, a.y, a.z
  202. local bx, by, bz = b.x, b.y, b.z
  203.  
  204. local _t = 1-t
  205. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  206. end
  207. end
  208. Num = 0
  209. Rnd = math.random
  210.  
  211. game:GetService("RunService").Stepped:connect(function()
  212. local mcf = getMiddleCFrame()
  213. for i,v in pairs(soundscape) do
  214. local snd,m,pl=v:FindFirstChild("Sound"),v:FindFirstChild("Mesh"),v:FindFirstChild("PointLight")
  215. if snd and m then
  216. pl.Brightness=snd.Volume
  217. ClrLerp(m,Vector3.new(snd.Volume/2,0,snd.Volume),.05)
  218. m.Scale = Vector3.new(.5,math.max(.02,lerp(m.Scale.Y+snd.Volume/2*1.3,snd.Volume,.3)*1.3),.5)
  219. elseif m then
  220. pl.Brightness=0
  221. m.Scale = Vector3.new(1,.02,1)
  222. ClrLerp(m,Vector3.new(0,0,0),.3)
  223. end
  224. if m then
  225. m.Offset = Vector3.new(0,m.Scale.Y/2*v.Size.Y/4,0)
  226. end
  227. --[[
  228. local ran = 4
  229. local ang;
  230. repeat
  231. ran = ran + .25
  232. ang = math.atan(v.Size.X/ran) + math.rad(1)
  233. until (#soundscape)*ang < math.pi*2]]
  234. ang = math.pi*2 / #soundscape
  235. ran = math.max(3,(v.Size.X / math.tan(ang)) + .5)
  236. v.CFrame = CFrame.new(i,0,0)--v.CFrame = clerp(v.CFrame,mcf*CFrame.Angles(0,math.pi*2/#soundscape*(i-1),0)*CFrame.new(0,0,-#soundscape*.3)+Vector3.new(0,math.sin((tick()+i)*5),0),.1)
  237. end
  238. end)
  239.  
  240.  
  241.  
  242. song = WaitChild(script,"Song")
  243. prop = WaitChild(script,"Properties")
  244.  
  245.  
  246.  
  247. DefSpecialProp()
  248. GVol = svolume.Value*fmuter.Value
  249.  
  250. function CompareAndRefresh(old,new)
  251. gcp = old:GetChildren()
  252. cp = new:GetChildren()
  253.  
  254. for i=1,#gcp do
  255. for ii=1,#cp do
  256. if gcp[i].Name == cp[ii].Name then
  257. local Gobj = gcp[i]
  258. local obj = cp[ii]
  259. obj.Value = Gobj.Value
  260. obj.Changed:connect(function() Gobj.Value = obj.Value end)
  261. end
  262. end
  263. end
  264. end
  265.  
  266. SetStartValues()
  267.  
  268. if #song:GetChildren() == 1 then
  269. pta.Value = false
  270. end
  271.  
  272. if pta.Value == false then
  273. ResetSongOnDeath = true
  274. end
  275.  
  276. songs = song:GetChildren()
  277. TheMidi = songs[song.Value]
  278.  
  279. if songs[song.Value] ~= nil then
  280. mid = songs[song.Value].Value
  281. else
  282. mid = songs[1].Value
  283. end
  284.  
  285. playDebounce = false
  286.  
  287. midiplayer = script.Parent
  288.  
  289. sounds = {}
  290. midichecksum = 365
  291. waitloop = false
  292. tracksOn = 0
  293.  
  294. tempo = 120
  295.  
  296. -- {id,tune,startkey,endkey,volume,attack,release,loop}
  297. snap = 12222140
  298. ping = 12221990
  299. bass = 12221831
  300. button = 12221967
  301. clickf = "rbxasset://sounds//clickfast.wav"
  302. clunk = "rbxasset://sounds//flashbulb.wav"
  303.  
  304. url = "http://www.roblox.com/asset/?id="
  305.  
  306. -- M_INS
  307. programs = {
  308. {{"12857654",0.3,0,66,0.5},{"12857804",-7,67,71,0.5},{"12857664",-11.5,72,127,0.8}}, -- Banjo
  309. {{"12857637",-3.9,0,64,0.5},{"12857660",-8.4,65,127,0.5}}, -- Banjo 2
  310. {{"13114759",-6,0,127,1}}, -- ding
  311. {{"19344667",-8.6,0,127,0.5}}, -- bell
  312. {{"15666462",-13.5,0,127,0.4}}, -- Beep
  313. {{"13424334",-23.2,0,127,0.5,0,0.5}}, -- piccolo
  314. {{"1089407",8.2,0,57,0.5},{"1089403",3.2,58,127,1}}, -- Electric Guitar
  315. {{"13032199",8.2,0,57,0.5},{"13032178",3.2,58,127,1}}, -- Space Guitar
  316. {{"60661796",-2.5,0,127,0.5,0.3,0.2}}, -- Metal Guitar
  317. {{"13019281",11.2,0,127,0.5}}, -- Ninja Guitar (Twang Twang!)
  318. {{"13019300",11.3,0,127,0.5}}, -- Ninja Guitar (T-T-Twang Twang!)
  319. {{"12892216",-7,0,127,0.5}}, -- Jungle Guitar
  320. {{"10209668",6.5,0,127,0.5}}, -- synth sound 1
  321. {{"11998777",12,0,127,0.5}}, -- synth sound 2
  322. {{"11998796",4.8,0,127,0.5,0,0.15}}, -- synth sound 3
  323. {{bass,11.7,0,127,0.5}}, -- Bass
  324. {{"rbxasset://sounds//uuhhh.wav",0.2,0,127,0.5}}, -- Robloxian Death
  325. {{button,6.7,0,127,0.4}}, -- Button
  326. {{ping,-21.7,0,127,0.5,0,0.2}}, -- Ping!
  327. {{"rbxasset://sounds//Kid saying Ouch.wav",0.9,0,127,0.5}}, -- 'Ouch'
  328. {{"11984351",16.8,0,127,0.3,0.02,0.2}}, -- Long Destructive Synth
  329. -- v V Drumset V v
  330. {{"13114759",39.7,26,26,0.5},{snap,37,27,27,0.5,0,0.25},
  331. {"108553903",38,28,28,0.5,0,0,0},
  332. {"18426149",41,29,29,0.4,0,0.25},{"18426149",34,30,30,0.4,0,0.25},{snap,37,31,31,0.2},
  333. {clickf,40,31,31,0.7},{clunk,40,32,32,0.5},{clickf,38,33,34,0.5},
  334. {"56524816",24,34,34,0.3},{"31173820",20,35,35,0.5},{"31173820",24,36,36,0.5},
  335. {"14863866",16,37,37,1},{"31173799",20,38,38,0.7},{"2101148",54,39,39,0.7},{"31173799",20,40,40,0.5},
  336. {"31173881",17,41,41,0.5},
  337. {snap,45,42,42,0.25,0,0.25},{"31173881",19,43,43,0.5},{snap,52,44,44,0.25,0,0.25},
  338. {"31173881",21,45,45,0.5},{"31173735",14,46,46,0.5},{"31173881",23,47,47,0.5},{"31173844",13,48,48,0.5},
  339. {"31173771",14,49,49,0.5},{"31173844",15,50,50,0.5},{"31173898",8,51,51,0.5},{"31173771",5,52,52,0.5},
  340. {"11113679",9.5,53,53,0.5},{snap,34,54,54,0.15,0,0.25},{"31173771",24,55,55,0.5},{snap,14,56,56,0.2},{"57802055",1,56,56,0.3},
  341. {"31173771",7,57,57,0.5},{"31173898",1,59,59,0.5},{"57801983",3,60,60,0.5,0,0.25},{"57801983",-10,61,61,0.5,0,0.25}, -- tuning was -5
  342. {"101088307",24,62,62,0.5,0,0,0},{"57802055",-16,63,63,0.5,0,0.25},{"57802055",-22,64,64,0.5,0,0.25},{"57801983",-15,65,65,0.5,0,0.25}
  343. ,{"57801983",-21,66,66,0.5,0,0.25},
  344. {"13114759",-8,67,67,0.5,0,0.25},{"13114759",-14,68,68,0.5,0,0.25},
  345. {snap,22,69,69,0.4},
  346. {snap,32,70,70,0.5,0,0.25},{"28510547",-14.4,71,71,0.4,0,0.25},{"28510547",-18.4,72,72,0.4,0,0.25},{"101180005",-3.4,73,73,0.3,0,0,0},
  347. {"100391463",-4,74,74,0.4,0,0,0},{"15666462",8,75,75,0.4},{"57802055",-2,76,76,0.4},{"57802055",-5,77,77,0.4},{"75338648",-13,78,78,0.6,0,1,0},{"75338648",-31.7,79,79,0.5,0,0,0},
  348. {"19344667",2.5,80,80,0.25,0,0.25},{"19344667",1.5,81,81,0.2},{snap,12,82,82,0.3,0,0.25},{"101093314",-22,83,83,0.4,0,0.25},
  349. {"13061809",-4,84,84,0.4},{"57802055",8,85,85,0.4},{"31173844",-35,86,86,0.4},{"31173844",-36,87,87,0.4}},
  350. -- Horror SFX v v v
  351. {{"13061809",-2,56,64,0.5},{"13061802",-10,65,74,0.5},{"13061810",-23,75,84,0.5},{"11984254",-34,85,127,0.5},
  352. {"rbxasset://sounds//HalloweenThunder.wav",8,48,55,0.5},{"rbxasset://sounds//HalloweenGhost.wav",27,0,47,0.5}},
  353. {{"21338895",0,0,127,0.5}}, -- Maraca
  354. {{"11949128",10,0,127,0.5}}, -- Big Drum (Even though it isn't.)
  355. {{"10209888",13.4,0,127,0.3},{"10209888",14.2,61,127,0.3}}, -- Popcorn
  356. {{"45885030",1.4,0,127,0.3}}, -- KatanaSlash
  357. {{"75421988",33.75,0,80,0.3,0,0.2,1},{"75338648",-24.7,81,127,0.5,0,0.4,1},
  358. {"75338648",-0.7,81,127,0.4,0,0.4,1},{"75338648",11.4,81,127,0.5,0,0.4,1}}, -- ChargeSynth
  359. {{"15666462",52.2,0,127,0.4,0.5,0.5,1}}, -- Hard Synth Bass
  360. {{"11944350",-9.6,0,127,0.5}}, -- Pew
  361. {{"79236960",0,0,127,0.3,0}}, -- Bass Drum
  362. {{"81146867",16,0,127,0.3,0}}, -- Saber Sound
  363. {{"75338648",-13,0,127,0.7,0,0.1,1}}, -- Beep sound
  364. {{"11949128",43,0,127,0.5,0,0.25,1}}, -- Growly Thing
  365. {{"11998796",4.8,0,127,1,0,0.25},{"75421988",33.8,0,80,0.2,0.4,0.4,1},{"75421988",33.9,0,80,0.2,0.4,0.4,1},
  366. {"75338648",-24.7,81,127,0.5,0,0.4,1},{"75338648",-0.7,81,127,0.4,0,0.4,1},{"75338648",11.4,81,127,0.5,0,0.4,1}}, -- Nice Synth
  367. {{"58479648",15.2,0,127,0.5,0,0.25}}, -- 035 Spitsy Bass
  368. {{"58479648",15.2,0,127,0.5,0,0.15,1}}, -- 036 Spitsy Bass/Beep (Loops)
  369. {{"69446845",13.5,0,127,0.5,0,0.15,1}}, -- 037 Dead Synth Strings
  370. {{"75421988",33.7,0,80,0.2,0.4,0.4,1},{"75421988",33.8,0,80,0.2,0.4,0.4,1},{"75338648",-24.7,81,127,0.5,0,0.4,1},{"75338648",-0.7,81,100,0.4,0,0.4,1},{"75338648",11.4,81,86,0.5,0,0.4,1}}, -- 038 Charge Synth Smooth
  371. {{"57802055",-2,0,127,0.5}}, -- 039 Noted Congo
  372. {{bass,23.8,0,127,0.5}}, -- 040 Bass Octave Higher
  373. {{"25641508",-9.5,0,127,0.5}}, -- 041 "Oof!"
  374. -- 42 Fake Piano V2
  375. {{bass,23.8,42,50,0.07},{"12857664",-11.6,36,80,0.6},
  376. {ping,-21.7,82,127,0.5,0,0.15},
  377. {"12857664",-11.6,87,127,0.18},{"12857664",-11.6,81,86,0.3},{bass,23.8,0,41,0.2},
  378. {ping,-21.7,0,81,0.8,0,0.2}},
  379. {{"75338648",-24.7,0,127,0.7,0,0.1,1}}, -- Soft Whistle (Octave lower)
  380. {{"89357191",21.5,0,127,0.7,0,0.1,1}}, -- Lightsaber Hum
  381. {{"13417380",-18.3,0,127,0.7,0,0.1}}, -- Clarinet
  382. {{"13418521",-8,0,127,0.7,0,0.2}}, -- Sax
  383. {{"13414759",4,0,127,0.7,0.5,0.5}}, -- Bagpipe Bass
  384. {{"13414758",14,0,127,0.7,0,0.1,1}}, -- Bagpipes (beeps loop)
  385. {{"13414749",19,0,127,0.7,0,0.1,1}}, -- Bagpipes (beeps2 loop)
  386. {{"75338648",-24.7,0,127,0.5,0,0.1,1},{"75338648",-12.7,0,127,0.5,0,0.1,1},{"75338648",-5.7,0,127,0.7,0,0.1,1},{"75338648",-0.7,0,127,0.5,0,0.1,1}}, -- Ahhh
  387. {{"75338648",-24.7,0,127,0.6,0,0.5,1},{"75338648",-12.7,0,127,0.6,0,0.5,1},{"75338648",-5.7,0,127,0.5,0,0.5,1}}, -- Synth
  388. {{"75338648",-24.7,0,90,0.5,0,0.1,1},{"75338648",-5.7,0,90,0.4,0,0.1,1},{"75338648",-0.7,0,90,0.5,0,0.1,1},
  389. {"75338648",-24.7,91,127,0.25,0,0.1,1},{"75338648",-5.7,91,127,0.15,0,0.1,1},{"75338648",-0.7,91,127,0.25,0,0.1,1}}, -- Organ?
  390. {{"75338648",-24.7,0,127,0.5,0,0.1,1},{"75338648",-0.7,0,127,0.4,0,0.1,1},{"75338648",11.4,0,127,0.5,0,0.1,1}}, -- Organ?
  391. {{ping,-21.7,0,127,0.3,0,0.1},{ping,4.7,0,127,0.2,0,0.1},{ping,14.7,0,127,0.2,0,0.1}}, -- Xylaphone
  392. {{ping,-21.7,0,127,0.5,0,0.25},{ping,14.4,0,127,0.2,0,0.25},{"13114759",6,0,127,0.2,0,0.25}}, -- Marimba
  393. {{bass,23.8,0,127,0.5,0,0.5}}, -- 040 Bass (Quick Rel)
  394. {{"55741744",2.8,54,127,0.5,0,0.5},{"55741275",13.8,0,53,0.5,0,0.5}}, -- Jaw Harp
  395. {{"60871617",-13,0,127,0.5,0,0.5}}, -- Cat Meow
  396. {{"56524816",-13.8,0,127,0.5,0,0.5}}, -- Wizard Wand Ding
  397. {{"31173844",2,0,127,0.5}}, -- Synth Drum
  398. {{"75421988",33.6,0,80,0.2,0.05,0.4,1},{"75421988",33.7,0,80,0.2,0.05,0.4,1},{"75338648",-24.7,81,127,0.5,0.05,0.4,1},{"75338648",-0.7,81,100,0.4,0.05,0.4,1},{"75338648",11.4,81,86,0.5,0.05,0.4,1}}, -- 038 Charge Synth Slow (More Smooth)
  399. {{"57802055",-14,0,127,0.5,0,0.1},{"11949128",10,0,127,0.3,0,0.1}}, -- 062 Pluck
  400. {{"99190550",7.6,0,127,0.3,0,0.1}}, -- 063 E Chug
  401. {{"99170481",8,0,49,0.5,0,0.1},{"99170583",5.1,50,56,0.5,0,0.1},{"99190216",-4,57,66,0.5,0,0.1},{"99170403",-14,67,127,0.5,0,0.1}}, -- EGuitar 4
  402. {{"99666917",2,0,127,0.5,0,0.1}}, -- Sacatto Organ
  403. {{"13414749",-5,0,127,0.4,0,0.2,0},{"75338648",-24.7,0,127,0.5,0,0.1,1}}, -- Dr. Solo
  404. {{"10209257",0,57,127,0.2,0,0,0},{"10209257",0,47,56,0.15,0,0,0},{"10209257",0,0,46,0.1,0,0,0}}, -- Gunshot
  405. {{"106708146",20,0,127,0.4,0.1,0,1}}, -- Applause
  406. {{"75338648",-24.7,0,127,1,0.5,0.1,1},{"75338648",-5.7,0,127,0.2,0.5,0.1,1},{"75338648",-12.7,0,127,0.15,0.5,0.1,1}}, -- Loop flute
  407. {{"75338648",-24.7,0,127,0.7,0,0.1,1},{"75338648",23.8,0,127,0.01,0,0.1,1},{"75338648",-12.7,0,127,0.1,0,0,1}}, -- EPiano 1
  408. {{"108553955",17.1,0,127,0.5,0,0,1},{"75338648",-24.7,46,127,0.4,0,0.1,1},{"75338648",-24.7,0,45,0.7,0,0.1,1}}, -- Whispery Bass Synth
  409. {{"109618842",-24,70,127,0.4,0,0,0},{"109618754",-14,0,56,0.4,0,0,0},{"109618435",-18.8,66,69,0.4,0,0,0},{"109619047",-23,57,59,0.4,0,0,0},{"109618940",-11.9,60,65,0.4,0,0,0}}, -- Celtic Harp
  410. {{"109618842",-24,86,127,0.4,0,0,0},{"109618754",-14,0,59,0.4,0,0,0},{"109618940",-11.9,60,85,0.4,0,0,0}}, -- Piano/Harp
  411. {{"109618435",-18.8,0,127,0.6,0,0.2,0}}, -- Fake Guitar
  412. {{"109619047",-23,0,127,0.4,0,0.2,0}}, -- Fake Guitar 2
  413. -- v V Orchestra Drumset V v
  414. {{"12222140",60,27,27,0.5,0,0,0},{"12222140",60,28,28,0.5,0,0,0},
  415. {"31173735",31,29,29,0.4,0,0,0},{"31173898",24,30,30,0.5,0,0,0},{snap,37,31,31,0.2},
  416. {clickf,40,31,31,0.7},{clunk,40,32,32,0.5},{clickf,38,33,34,0.5},
  417. {"56524816",24,34,34,0.3},{"31173820",20,35,35,0.5},{"11949128",10,36,36,0.5,0,0,0},
  418. {"14863866",16,37,37,1},{"112503990",28,38,38,0.8,0,0,0},
  419. {"106543491",20.5,39,39,0.5,0,0,0},{"112503990",26.4,40,40,0.8,0,0,0},
  420. {"11949128",10,41,53,0.5,0,0,0},{snap,34,54,54,0.15,0,0.25},{"31173771",24,55,55,0.5},
  421. {snap,14,56,56,0.2},{"57802055",1,56,56,0.3},{"31173771",12,57,57,0.5,0,0,0},
  422. {"31173771",16,59,59,0.5,0,0,0},
  423. {"57801983",3,60,60,0.5,0,0.25},{"57801983",-10,61,61,0.5,0,0.25},
  424. {"101088307",24,62,62,0.5,0,0,0},{"57802055",-16,63,63,0.5,0,0.25},
  425. {"57802055",-22,64,64,0.5,0,0.25},{"57801983",-15,65,65,0.5,0,0.25},
  426. {"57801983",-21,66,66,0.5,0,0.25},{"13114759",-8,67,67,0.5,0,0.25},
  427. {"13114759",-14,68,68,0.5,0,0.25},
  428. {snap,22,69,69,0.4},{snap,32,70,70,0.5,0,0.25},{"28510547",-14.4,71,71,0.4,0,0.25},
  429. {"28510547",-18.4,72,72,0.4,0,0.25},{"101180005",-3.4,73,73,0.3,0,0,0},
  430. {"100391463",-4,74,74,0.4,0,0,0},{"15666462",8,75,75,0.4},{"57802055",-2,76,76,0.4},
  431. {"57802055",-5,77,77,0.4},{"75338648",-13,78,78,0.6,0,1,0},{"75338648",-31.7,79,79,0.5,0,0,0},
  432. {"19344667",2.5,80,80,0.25,0,0.25},{"19344667",1.5,81,81,0.2},{snap,12,82,82,0.3,0,0.25},
  433. {"101093314",-22,83,83,0.4,0,0.25},
  434. {"13061809",-4,84,84,0.4},
  435. {"57802055",8,85,85,0.4},
  436. {"31173844",-35,86,86,0.4},
  437. {"31173844",-36,87,87,0.4}},
  438. {{"75338648",-24.9,0,67,0.5,0,0.1,0},{"12221990",2.3,0,127,0.5,0,0.1,0},
  439. {"12221990",-9.7,0,69,0.5,0,0.1,0},{"12221990",6,0,127,0.4,0,0.1,0},
  440. {"75338648",-24.8,68,127,0.5,0,0.1,1},{"75338648",-12.8,70,127,0.7,0,0.2,1}},-- Steel drums
  441.  
  442. {{"109618435",-18.8,0,127,0.4,0,0.1,0},{"75338648",-24.7,0,127,0.7,0,0.1,1}}, -- Atmosphere
  443. {{"12221831",23.8,61,127,0.4,0,0.5,0},{"11949128",10,0,127,0.4,0,0.1,0},
  444. {"12221831",23.8,0,60,0.3,0,0.5,0}}, -- String Pluck 2
  445. {{"108553903",0,0,127,0.5,0,0,0}}, -- Snapper
  446. {{"129562296",-9,0,127,0.17,0,0.4,1}}, -- SquareWave 81
  447. {{"131030037",12,0,127,0.3,0,0.4,1}}, -- SawWave 82
  448. {{"129562240",-9,0,127,0.23,0,0.5,1}}, -- SineWave 83
  449. {{"129562296",-8.9,0,127,0.15,0,0.25,1},{"129562296",-9.1,0,127,0.15,0,0.25,1}}, -- SquareWave2 84
  450. {{"131030037",11.95,0,127,0.3,0,0.2,1},{"131030037",12.05,0,127,0.3,0,0.2,1}}, -- SawWave2 85
  451. {{"129562240",-9,0,127,0.3,0.4,0.1,1},{"129562240",10,0,127,0.05,0.4,0.1,1},{"129562240",3,0,127,0.04,0.4,0.1,1}}, -- Being Replaced With a Real Flute...
  452. {{"9413306",-10,0,127,0.5,0,0,0.5,0}}, -- Quack 87
  453. {{"130818484",-12,0,127,0.9,0,0.25,0}}, -- Trumpet 88
  454. {{"130849959",12,0,89,0.8,0,0.4,1},
  455. {"130849959",12,90,102,0.5,0,0.4,1}}, -- PulseWave 89
  456. {{"130850059",12,0,89,0.8,0,0.4,1},
  457. {"130850059",12,90,102,0.5,0,0.4,1}}, --TriangleWave 90
  458. {{"130851174",0,0,127,0.25,0,0.4,0}}, -- Electric Guitar 91
  459. {{"130850183",0,53,127,0.7,0,0,0}, -- Pizzicato 92
  460. {"130850227",24,0,52,0.3,0,0,0}}, --
  461. {{"130850974",2,0,127,0.4,0,0.25,0}}, -- Trombone 93
  462. {{"130944009",0,0,127,0.5,0,0,0}}, -- 94 Tubular Bells
  463. }
  464.  
  465.  
  466. for i=1,#programs do
  467. for ii=1,#programs[i] do
  468. item = programs[i][ii][1]
  469. if string.sub(item,1,1) ~= "r" then
  470. Game:GetService("ContentProvider"):Preload(url .. item)
  471. end
  472. end
  473. end
  474.  
  475. GM = {0,{107},1,{8,106,105},77,{115},18,{9,11},20,{120},24,{48,117},
  476. 38,{49,91},39,{116},43,{73,74,75,78,79,80},42,{1,2,3,4},45,{70,72},
  477. 46,{22,23,41,65,66,67,68,69,111},47,{42,43,44,59},
  478. 51,{51,52,53,54,55,89,92,95,96},52,{17,18,19,45},53,{20},54,
  479. {10,12,14},55,{13},56,{28,29,33,34,35,36,37,38,39,40,86,88},
  480. 60,{118,119},61,{50},64,{56},67,{128},68,{123},69,{70,72,90},
  481. 70,{5,97,93,94},72,{47},74,{7,16,25},75,{26},78,{100,101},
  482. 80,{127},81,{81},82,{82},85,{63,64},88,{57,61},91,{30,31},
  483. 92,{46},93,{58},94,{15}}
  484.  
  485. --M_Func
  486. --==================================
  487. --Small Importaint Functions
  488.  
  489. --Good for quick reference.
  490. --==================================
  491.  
  492. function ChangeSongVolume()
  493. GVol = svolume.Value*fmuter.Value
  494. end
  495. svolume.Changed:connect(ChangeSongVolume)
  496. fmuter.Changed:connect(ChangeSongVolume)
  497.  
  498.  
  499. function SortPlaylistByName()
  500. if SortSongByName == true then
  501. local c = song:GetChildren()
  502. nametab = {}
  503. for i=1,#c do
  504. table.insert(nametab,c[i].Name)
  505. end
  506.  
  507. table.sort(nametab)
  508. print(table.concat(nametab,' '))
  509. local hidden = Instance.new("IntValue")
  510.  
  511. for i=1,#c do
  512. for ii=1,#c do
  513. if nametab[i] == c[ii].Name then
  514. c[ii].Parent = hidden
  515. break
  516. end
  517. end
  518. end
  519.  
  520. local c = hidden:GetChildren()
  521. for i=1,#c do
  522. print(c[i].Name)
  523. c[i].Parent = song
  524. end
  525. end
  526. end
  527.  
  528. SortPlaylistByName()
  529.  
  530. function PlayNextSongIf()
  531. if stop == false then
  532. --print("NextSongIf",songPlaying,pta.Value)
  533. if songPlaying == false then
  534. if isPlaying.Value == true then
  535. isPlaying.Value = false
  536. end
  537. if pta.Value == true then
  538.  
  539. if loop.Value == false then
  540. if song.Value >= #songs then
  541. return
  542. end
  543. end
  544.  
  545. song.Value = (song.Value%#songs)+1
  546. songPlaying = true
  547. end
  548. end
  549. end
  550. end
  551.  
  552. function DeSpaceFile(file,conv)
  553. local check = ""
  554. if conv == true then
  555. check = TheMidi.Value
  556. else
  557. check = mid
  558. end
  559. if string.sub(check,1,3) ~= "Ukl" and string.sub(check,1,1) ~= "[" then
  560. if string.sub(check,1,3) ~= "TVR" and string.sub(check,1,1) ~= "X" then
  561. print("Spaced? Despace!")
  562. local str = ""
  563. for v in string.gmatch(check,"%x+") do
  564. str = str .. v
  565. end
  566.  
  567. if conv == true then
  568. file.Value = str
  569. mid = file.Value
  570. else
  571. mid = str
  572. end
  573. end
  574. end
  575. end
  576.  
  577. function Update_NewDeltaTime()
  578. t,l = wait(0.03)
  579. if ticks_per_QN ~= nil then
  580. NewDeltaTime = t*32.17*((tempo+tempoMod.Value)/(1920/ticks_per_QN))
  581. end
  582. end
  583.  
  584. function ReadByte(fp)
  585. local subby = string.sub(mid,fp,fp+1)
  586. if subby == "" then print("UNEXPECTED END_OF_FILE!") return 0 end
  587. return tonumber("0x" .. subby)
  588. end
  589.  
  590. function Read8bit(fp)
  591. local subby = string.sub(mid,fp,fp)
  592. if subby == "" then print("UNEXPECTED END_OF_FILE!") return 0 end
  593. return tonumber("0x" .. subby)
  594. end
  595.  
  596.  
  597. function ReadWord(fp)
  598. return ReadByte(fp)*16777216+ReadByte(fp+2)*65536+ReadByte(fp+4)*256+ReadByte(fp+6)
  599. end
  600.  
  601. function Read3Bytes(fp)
  602. return ReadByte(fp)*65536+ReadByte(fp+2)*256+ReadByte(fp+4)
  603. end
  604.  
  605. InsNew = Instance.new
  606.  
  607.  
  608.  
  609.  
  610.  
  611. function PlayTrack(cpos,program,track,volume,mute,pmod)
  612. -- MTrk here...
  613.  
  614. -- Midi Controlled
  615. local expression = 127
  616. local pbend1 = 0
  617. local pbend2 = 64
  618. local semtone = 2
  619. local LSB = 0
  620. local MSB = 0
  621. songPlaying = true
  622. local midicommand = nil
  623. local TrackStartPos = 0
  624. local bank = 0
  625. local chan = 0
  626. if TheMidi.className == "StringValue" then
  627. TParent = TheMidi:GetChildren()
  628. else
  629. TParent = TheMidi:GetChildren()[1]:GetChildren()
  630. end
  631.  
  632. local Trks = TParent
  633.  
  634.  
  635. if filehas == 0 then
  636. pcbend1 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  637. pcbend2 = {64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64}
  638. MSB0 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  639. LSB0 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  640. semtone0 = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}
  641. bank0 = {0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0}
  642. end
  643.  
  644.  
  645. local function SNum_NextByte()
  646. cpos = cpos+2
  647. snum = ReadByte(cpos)
  648. end
  649.  
  650. local function Read127()
  651. b127 = 0
  652. if snum >= 128 then
  653. math127 = 0
  654. while snum > 127 do
  655. math127 = (math127+snum-128)*128
  656. b127 = math127
  657. SNum_NextByte()
  658. end
  659. end
  660. return b127+snum
  661. end
  662.  
  663. local function NoteOff()
  664. local snum = ReadByte(cpos+2)
  665. cpos = cpos+4
  666. for i=1,#sounds,1 do
  667. if sounds[i][2] == snum and sounds[i][5] == track then
  668. sounds[i][3] = 0
  669. end
  670. end
  671. end
  672.  
  673. local function PitchMath1(noteval,tune)
  674. return 2^((noteval+tune-60+pmod+((pbend2-64)*128+pbend1)/8192*semtone)/12)
  675. end
  676.  
  677. local function PitchMath0(noteval,tune)
  678. local tp1 = track+1
  679. return 2^((noteval+tune-60+pmod+((pcbend2[tp1]-64)*128+pcbend1[tp1])/8192*semtone0[tp1])/12)
  680. end
  681.  
  682. local function NoteOn()
  683. noteval = ReadByte(cpos+2)
  684. velocity = ReadByte(cpos+4)
  685. if velocity > 0 then
  686. cpos = cpos+4
  687. if mute == false then
  688. if noteval >= 0 and noteval <= 127 then -- If pressed a note key.
  689. progone = program.Value+1
  690.  
  691. if progone == 0 then
  692. progone = 5
  693. end
  694.  
  695. if programs[progone] ~= nil then
  696. notevalMod = noteval+pmod
  697. for v,prog in pairs(programs[progone]) do
  698. if noteval >= prog[3] and noteval <= prog[4] then
  699.  
  700. if filehas ~= 0 then
  701. mathpitch = PitchMath1(noteval,prog[2])
  702. else
  703. mathpitch = PitchMath0(noteval,prog[2])
  704. end
  705. -- Lol ^ ^ ^ I really over did the pitch correction thingy...
  706. if string.sub(prog[1],1,1) ~= "r" then
  707. soundid = url .. prog[1]
  708. else
  709. soundid = prog[1]
  710. end
  711. mathvolume = (prog[5]*velocity*volume*GVol)/16129
  712. local s = nil
  713. local ctabi = nil
  714.  
  715. for i=1,#sounds do
  716. if sounds[i][3] == 0 and sounds[i][1].Volume == 0 then
  717. s = sounds[i][1]
  718. ctabi = i
  719. if (s.Looped == true and prog[8] == 1) or (s.Looped == false and prog[8] ~= 1) then
  720. break
  721. else
  722. s = nil
  723. end
  724. end
  725. end
  726.  
  727. local par = s and s.Parent or (function() for i,v in pairs(soundscape) do if v:IsDescendantOf(game) and #v:GetChildren() == 1 then return v elseif not v:IsDescendantOf(game) then table.remove(soundscape,i) end end return addSS() end)()
  728. --local par = workspace.Base
  729. if s == nil then
  730. s = Instance.new("Sound",par)
  731. if prog[8] ~= nil and prog[8] == 1 then
  732. s.Looped = true
  733. else
  734. s.Looped = false
  735. end
  736. end
  737. s:Stop()
  738. Delay(.1,function() par.BrickColor = BrickColor.new("Royal purple") end)
  739. s.SoundId = soundid
  740. s.Pitch = mathpitch
  741. if ctabi ~= nil then
  742. table.remove(sounds,ctabi)
  743. end
  744. stab = {}
  745.  
  746. table.insert(sounds,stab)
  747. table.insert(stab,s)
  748. table.insert(stab,noteval)
  749. table.insert(stab,1) -- note on
  750. table.insert(stab,1) -- So the note plays once.
  751. table.insert(stab,track)
  752. table.insert(stab,prog[2]) -- additional pitch
  753. table.insert(stab,mathvolume) -- max volume
  754.  
  755. if prog[6] ~= nil and prog[6] ~= 0 then
  756. table.insert(stab,prog[6]) -- attack
  757. s.Volume = 0
  758. else
  759. table.insert(stab,0.0001) -- attack
  760. s.Volume = mathvolume
  761. end
  762.  
  763. if prog[7] ~= nil and prog[7] ~= 0 then
  764. table.insert(stab,prog[7]) -- release
  765. else
  766. table.insert(stab,0.05)
  767. end
  768. s:Play()
  769. end
  770. end
  771. end
  772. end
  773. end
  774. else -- Velocity == 0
  775. NoteOff()
  776. end
  777. end
  778.  
  779.  
  780. local function NoteAftertouch()
  781. --print("Note Aftertouch detected")
  782. cpos = cpos+2
  783. end
  784.  
  785.  
  786. local function ControllerChange()
  787. --print("Midi Controller detected")
  788. cpos = cpos+2
  789. convalue = ReadByte(cpos)
  790. cpos = cpos+2
  791. convalue2 = ReadByte(cpos)
  792.  
  793. if convalue == 0 then
  794. if filehas ~= 0 then
  795. bank = convalue2
  796. else
  797. bank0[track+1] = convalue2
  798. end
  799. end
  800.  
  801. if convalue == 6 then
  802. if filehas ~= 0 then
  803. if LSB == 0 and MSB == 0 then
  804. semtone = convalue2
  805. end
  806. else
  807. if LSB0[track+1] == 0 and MSB0[track+1] == 0 then
  808. semtone0[track+1] = convalue2
  809. end
  810. end
  811. end
  812.  
  813. if convalue == 7 then
  814. print("Channel Volume Set:",convalue2,volume)
  815. if volume == 128 or DisregardMixerVolume == true then
  816. if convalue2 > 5 then
  817. volume = convalue2
  818. end
  819. end
  820. end
  821.  
  822. if convalue == 100 then
  823. if filehas ~= 0 then
  824. LSB = convalue2
  825. else
  826. LSB0[track+1] = convalue2
  827. end
  828. end
  829. if convalue == 101 then
  830. if filehas ~= 0 then
  831. MSB = convalue2
  832. else
  833. MSB0[track+1] = convalue2
  834. end
  835. end
  836. if convalue == 111 then
  837. TrackStartPos = cpos+2
  838. end
  839. end
  840.  
  841.  
  842.  
  843.  
  844. local function ProgramChange()
  845. if mute == false then print("Program change detected: " .. ReadByte(cpos+2)+1,"Track:",track,"Bank:",bank,"Chan:",chan) end
  846. if program.Value < 0 then
  847. --local chan = Read8bit(cpos+1)
  848. local newprog = ReadByte(cpos+2)+1
  849. if chan ~= 9 then
  850. foundp = false
  851. for i=1,#GM,2 do
  852. local GMtab = GM[i+1]
  853. local newIns = GM[i]
  854. if GMtab ~= nil then
  855. for ii=1,#GMtab do
  856. if GMtab[ii] == newprog then
  857. program.Value = newIns
  858. foundp = true
  859. break
  860. end
  861. end
  862. end
  863. end
  864. if foundp == false then
  865. program.Value = -1
  866. end
  867. else
  868. program.Value = 21
  869. if newprog == 49 then
  870. program.Value = 76
  871. end
  872.  
  873. end
  874. end
  875. cpos = cpos+2
  876. end
  877.  
  878. local function PitchBend()
  879. if filehas ~= 0 then
  880. pbend1 = ReadByte(cpos+2)
  881. pbend2 = ReadByte(cpos+4)
  882.  
  883. for i=1,#sounds,1 do
  884. if sounds[i][5] == track then
  885. sounds[i][1].Pitch = 2^((sounds[i][2]+sounds[i][6]-60+((pbend2-64)*128+pbend1)/8192*semtone)/12)
  886. end
  887. end
  888. else
  889. pcbend1[track+1] = ReadByte(cpos+2)
  890. pcbend2[track+1] = ReadByte(cpos+4)
  891.  
  892. for i=1,#sounds,1 do
  893. if sounds[i][5] == track then
  894. sounds[i][1].Pitch = 2^((sounds[i][2]+sounds[i][6]-60+((pcbend2[track+1]-64)*128+pcbend1[track+1])/8192*semtone0[track+1])/12)
  895. end
  896. end
  897. end
  898. cpos = cpos+4
  899. end
  900.  
  901. local function ChannelAftertouch()
  902. cpos = cpos+2
  903. end
  904.  
  905. local com = {}
  906. com[8] = NoteOff
  907. com[9] = NoteOn
  908. com[10] = NoteAftertouch
  909. com[11] = ControllerChange
  910. com[12] = ProgramChange
  911. com[13] = ChannelAftertouch
  912. com[14] = PitchBend
  913.  
  914.  
  915. local chunksize = ReadWord(cpos) -- probably will be used to find the next track.
  916.  
  917. local step = 0
  918. local dowait = true
  919. local waitbyte = 0
  920. local finalwaitbyte = 0
  921.  
  922. tracksOn = tracksOn+1
  923. snum = 0
  924. local atTrack = 1
  925.  
  926. chunksize = ReadWord(cpos)
  927. -- FIND THE RIGHT TRACK
  928. while track > atTrack do
  929. chunksize = ReadWord(cpos)
  930. cpos = cpos+(chunksize*2)+16
  931. atTrack = atTrack+1
  932. end
  933.  
  934. cpos = cpos+8
  935. TrackStartPos = cpos
  936.  
  937. if TrackStartPos >= msize then
  938. tracksOn = tracksOn-1
  939. print("ERROR! EOF!")
  940. return
  941. end
  942.  
  943. print("Track pos: " .. cpos)
  944. print("Start Loop")
  945. while cpos <= msize do
  946. snum = ReadByte(cpos)
  947. --print("Position:",cpos,snum,"stop:",stop)
  948.  
  949. if dowait == true then -- WAIT COMMAND
  950. local finalwaitbyte = Read127()
  951. --print("Wait CLICKS: " .. finalwaitbyte)
  952. dowait = false
  953. SNum_NextByte()
  954.  
  955. while finalwaitbyte > step do
  956. wait(0.03)
  957. step=step+NewDeltaTime
  958. if stop == true then
  959. break
  960. end
  961. end
  962. step = step-finalwaitbyte
  963. finalwaitbyte = 0
  964. end
  965.  
  966. snum = ReadByte(cpos)
  967.  
  968. -- META EVENTS
  969. if snum == 255 then
  970. dowait = true
  971. SNum_NextByte()
  972. local oldcpos = cpos
  973. if snum == 81 then
  974. cpos = cpos+4
  975.  
  976. tempo = 60000000/Read3Bytes(cpos)
  977. oldtempo = tempo
  978. --print("Tempo Set To: " .. tempo)
  979.  
  980. cpos = cpos+4
  981. snum = -1
  982.  
  983. elseif snum == 3 or snum == 6 then
  984. oldsum = snum
  985.  
  986. SNum_NextByte()
  987. vallength = Read127() --snum
  988. cpos = cpos+(vallength*2)
  989.  
  990. elseif snum == 47 then
  991. if loop.Value == true and stop == false and pta.Value == false then
  992. cpos = TrackStartPos-2
  993.  
  994. if filehas == 1 or filehas == 2 then
  995. waitloop = true
  996. tracksOn = tracksOn-1
  997. while waitloop do
  998. wait(0.03)
  999. end
  1000. tracksOn=tracksOn+1
  1001. end
  1002.  
  1003. if stop == true or loop.Value == false or pta.Value == true then
  1004. break
  1005. end
  1006.  
  1007. wait(0)
  1008. else
  1009. break
  1010. end
  1011. end
  1012.  
  1013. if oldcpos == cpos then -- If no meta commands found:
  1014. SNum_NextByte()
  1015. vallength = Read127() --snum
  1016. cpos = cpos+(vallength*2)
  1017. snum = -1
  1018. end
  1019. end
  1020.  
  1021. if stop == true then
  1022. break
  1023. end
  1024.  
  1025.  
  1026. -- Others
  1027. if dowait == false then
  1028. if snum == 240 then -- SYSTEM_EXCLUSIVE
  1029. --print("System Exlusive",string.format("%x",cpos/2))
  1030. dowait = true
  1031. SNum_NextByte()
  1032. cpos = cpos+(snum*2)-2
  1033. cpos = cpos+2
  1034. snum = ReadByte(cpos)
  1035. end
  1036. end
  1037.  
  1038.  
  1039. -- MIDI COMMANDS
  1040. if dowait == false then
  1041. dowait = true
  1042. bit8 = Read8bit(cpos)
  1043.  
  1044. if com[bit8] ~= nil then
  1045. chan = Read8bit(cpos+1)
  1046. if filehas == 0 then
  1047. track = chan
  1048. program = Trks[track+1]
  1049. --if bank0[track+1] == 127 or track == 9 then
  1050. --program.Value = 21
  1051. --end
  1052. local pch = program:GetChildren()
  1053. volume = pch[1].Value
  1054. mute = pch[2].Value
  1055. pmod = pch[3].Value
  1056. else
  1057. --[[
  1058. if program.Value <= 0 then
  1059. if bank == 127 or chan == 9 then
  1060. program.Value = 21
  1061. end
  1062. end
  1063. ]]
  1064. end
  1065.  
  1066. midicommand = com[bit8]
  1067. --print("Command:",midicommand,bit8)
  1068. midicommand()
  1069. else
  1070. if midicommand ~= nil then
  1071. cpos = cpos-2
  1072. --print("Old Command:",midicommand)
  1073. midicommand()
  1074. else
  1075. print("ERROR:",cpos,track,string.sub(mid,cpos,cpos+1))
  1076. break
  1077. end
  1078. end
  1079. end
  1080. cpos = cpos+2
  1081.  
  1082. end
  1083.  
  1084. tracksOn = tracksOn-1
  1085.  
  1086. if filehas == 0 then
  1087. tracksOn = 0
  1088. end
  1089.  
  1090. if tracksOn == 0 then
  1091. songPlaying = false
  1092. end
  1093.  
  1094. print("End of track",tracksOn)
  1095. end
  1096.  
  1097.  
  1098.  
  1099. function MidiPlay()
  1100. stop = false
  1101. filehas = ReadByte(19+S_pos)
  1102.  
  1103. tracks = (ReadByte(21+S_pos)*256)+ReadByte(23+S_pos)
  1104.  
  1105. if filehas == 0 then
  1106. print("The file has a single multi-channel track.")
  1107. tracks = 16
  1108. end
  1109. if filehas == 1 then
  1110. print("The file has one or more simultaneous tracks (or MIDI outputs) of a sequence.")
  1111. end
  1112. if filehas == 2 then
  1113. print("The file has one or more sequentially independent single-track patterns (NOT COMPATIBLE)")
  1114. end
  1115.  
  1116. print("Tracks: " .. tracks)
  1117. song = script.Song
  1118. songs = song:GetChildren()
  1119. TheMidi = songs[song.Value]
  1120. if TheMidi ~= nil then
  1121. for i=1,tracks do -- To self: Don't move this.
  1122.  
  1123. if TheMidi.className == "StringValue" then
  1124. program_Obj = TheMidi:GetChildren()[i]
  1125. midiP = TheMidi
  1126. else
  1127. midiTData = TheMidi:GetChildren()[1]
  1128. midiP = midiTData
  1129. if midiTData ~= nil then
  1130. program_Obj = midiTData:GetChildren()[i]
  1131. else
  1132. print("The BIG MIDI is missing its data!")
  1133. end
  1134. end
  1135.  
  1136. if program_Obj ~= nil then
  1137. program_Obj.Name = i .. " Track"
  1138. else
  1139. program_Obj = Instance.new("IntValue")
  1140. program_Obj.Parent = midiP
  1141. program_Obj.Name = i .. " Track"
  1142. program_Obj.Value = -1
  1143. end
  1144.  
  1145. if program_Obj ~= nil then
  1146. vol = program_Obj:findFirstChild("Volume")
  1147. if vol == nil then
  1148. print("Create Volume")
  1149. vol = Instance.new("IntValue")
  1150. vol.Parent = program_Obj
  1151. vol.Name = "Volume"
  1152. vol.Value = 128
  1153. end
  1154. mute = program_Obj:FindFirstChild("Mute")
  1155. if mute == nil then
  1156. print("Create Muter")
  1157. mute = Instance.new("BoolValue")
  1158. mute.Parent = program_Obj
  1159. mute.Name = "Mute"
  1160. end
  1161. pmod = program_Obj:findFirstChild("PitchMod")
  1162. if pmod == nil then
  1163. print("Create PitchMod")
  1164. pmod = Instance.new("NumberValue")
  1165. pmod.Parent = program_Obj
  1166. pmod.Name = "PitchMod"
  1167. pmod.Value = 0
  1168. end
  1169. end
  1170. end
  1171.  
  1172. ticks_per_QN = ReadByte(25+S_pos)*256+ReadByte(27+S_pos)
  1173. stop = true
  1174. Update_NewDeltaTime()
  1175. stop = false
  1176. print("Ticks per quarter note: " .. ticks_per_QN)
  1177. atchannel = 1
  1178.  
  1179.  
  1180.  
  1181. if TheMidi.className == "StringValue" then
  1182. mc = TheMidi:GetChildren()
  1183. else
  1184. mc = TheMidi:GetChildren()[1]:GetChildren()
  1185. end
  1186.  
  1187. tempo = 120
  1188. isPlaying.Value = true
  1189. if filehas == 1 then
  1190. for i=1,tracks do
  1191. thread = coroutine.create(PlayTrack) coroutine.resume(thread,37+S_pos,mc[i],i,mc[i].Volume.Value,mc[i].Mute.Value,mc[i].PitchMod.Value)
  1192. end
  1193. else
  1194. PlayTrack(37+S_pos,mc[1],1)
  1195. end
  1196.  
  1197. end
  1198. end
  1199.  
  1200.  
  1201. function onStopCommand()
  1202. if Stop.Value == true then
  1203. stop = true
  1204.  
  1205. ClearData()
  1206. play.Value = false
  1207. Stop.Value = false
  1208. isPlaying.Value = false
  1209.  
  1210. end
  1211. end
  1212.  
  1213. function ClearData()
  1214. soundscape={}
  1215. end
  1216.  
  1217. EXITPLAY = false
  1218. DECOMPRESSORS = 0
  1219.  
  1220. function CheckDecompress(mstr)
  1221. if DECOMPRESSORS == 0 then
  1222. oldsong = song.Value
  1223. else
  1224. wait()
  1225. end
  1226.  
  1227. if string.sub(mstr,1,1) == "X" or string.sub(mstr,1,1) == "[" then
  1228. print("Compressed in Base128!")
  1229. Decompress128(mid)
  1230. end
  1231.  
  1232. if string.sub(mstr,1,3) == "TVR" or string.sub(mstr,1,3) == "Ukl" then
  1233. print("Compressed in Base64!")
  1234. Decompress64(mid)
  1235. end
  1236.  
  1237. if song.Value ~= oldsong then
  1238. oldsong = song.Value
  1239. EXITPLAY = true
  1240. print("Emergency exit!")
  1241. end
  1242. end
  1243.  
  1244. function onPlayCommand()
  1245. if play.Value == true then
  1246. print("Play On")
  1247. play.Value = false
  1248. Stop.Value = false
  1249. if playDebounce == false then
  1250. print("Play Debounce ON")
  1251. playDebounce = true
  1252. stop = true
  1253.  
  1254. SortPlaylistByName()
  1255.  
  1256. songs = song:GetChildren()
  1257. print("Clear Data")
  1258. ClearData()
  1259. print("Play Debounce off")
  1260. playDebounce = false
  1261. TheMidi = songs[song.Value]
  1262.  
  1263. if TheMidi ~= nil then
  1264. if TheMidi.className == "StringValue" then
  1265.  
  1266. length = #TheMidi.Value
  1267. if length >= Max_SLength then
  1268. print("This midi file is too big for Roblox. Use 'Midi_Object Creator' from the Model if you haven't yet.")
  1269. return end
  1270.  
  1271. mid = TheMidi.Value -- For Base64
  1272. DeSpaceFile(TheMidi,true)
  1273.  
  1274. check64 = string.sub(mid,1,3)
  1275. CheckDecompress(mid)
  1276.  
  1277. else -- For BIG MIDIs
  1278. local c = TheMidi:GetChildren()
  1279. mid = ""
  1280. for i=1,#c do
  1281. if c[i].className == "StringValue" then
  1282. mid = mid..c[i].Value
  1283. end
  1284. end
  1285. check64 = string.sub(mid,1,3)
  1286. --DeSpaceFile(mid,false)
  1287. CheckDecompress(mid)
  1288. end
  1289.  
  1290. if EXITPLAY == true then
  1291. EXITPLAY = false
  1292. return
  1293. end
  1294.  
  1295. if check64 == "TVR" or check64 == "Ukl" then
  1296. if reload_B64 == true then
  1297. oldname = TheMidi.Name
  1298. TheMidi:Destroy()
  1299.  
  1300. if #mid > 131068 then
  1301. print("Remake into hex")
  1302. TheMidi = Instance.new("BoolValue",song)
  1303. TheMidi.Name = oldname
  1304. for i=1,#mid,131068 do
  1305. s = Instance.new("StringValue",TheMidi)
  1306. s.Value = string.sub(mid,i,i+131067)
  1307. end
  1308. else
  1309. TheMidi = Instance.new("StringValue",song)
  1310. TheMidi.Value = mid
  1311. TheMidi.Name = oldname
  1312. end
  1313. end
  1314. end
  1315.  
  1316. sounds = {}
  1317. checksum = 0
  1318. msize = #mid
  1319.  
  1320. S_pos = 0
  1321. print(string.sub(mid,1,8))
  1322. if string.sub(mid,1,8) == "52494646" then -- RIFF
  1323. S_pos = 40
  1324. print("DETECTED!")
  1325. end
  1326.  
  1327.  
  1328. for i=1,12,2 do
  1329. add = tonumber("0x" .. string.sub(mid,i+S_pos,i+1+S_pos))
  1330. if add ~= nil then
  1331. checksum = checksum+add
  1332. end
  1333. end
  1334.  
  1335. if checksum == midichecksum then
  1336. print("Yes a midi!")
  1337. MidiPlay()
  1338. else
  1339. TheMidi.Name = "NOT_A_MIDI (" .. string.sub(mid,1,12) .. ")"
  1340. print("Not a midi. Did you paste the entire file? Is the file a .mid?")
  1341. end
  1342. end
  1343. end
  1344. end
  1345. end
  1346.  
  1347. play.Changed:connect(onPlayCommand)
  1348. Stop.Changed:connect(onStopCommand)
  1349.  
  1350.  
  1351. --M_DECOMP
  1352. --======================
  1353. -- Decompressors (only one for now)
  1354. --======================
  1355.  
  1356.  
  1357. b64 = {["A"] = 0, ["B"] = 1, ["C"] = 2, ["D"] = 3, ["E"] = 4, ["F"] = 5, ["G"] = 6, ["H"] = 7, ["I"] = 8, ["J"] = 9, ["K"] = 10, ["L"] = 11, ["M"] = 12, ["N"] = 13, ["O"] = 14, ["P"] = 15, ["Q"] = 16, ["R"] = 17, ["S"] = 18, ["T"] = 19, ["U"] = 20, ["V"] = 21, ["W"] = 22, ["X"] = 23, ["Y"] = 24, ["Z"] = 25, ["a"] = 26, ["b"] = 27, ["c"] = 28, ["d"] = 29, ["e"] = 30, ["f"] = 31, ["g"] = 32, ["h"] = 33, ["i"] = 34, ["j"] = 35, ["k"] = 36, ["l"] = 37, ["m"] = 38, ["n"] = 39, ["o"] = 40, ["p"] = 41, ["q"] = 42, ["r"] = 43, ["s"] = 44, ["t"] = 45, ["u"] = 46, ["v"] = 47, ["w"] = 48, ["x"] = 49, ["y"] = 50, ["z"] = 51, ["0"] = 52, ["1"] = 53, ["2"] = 54, ["3"] = 55, ["4"] = 56, ["5"] = 57, ["6"] = 58, ["7"] = 59, ["8"] = 60, ["9"] = 61, ["+"] = 62, ["/"] = 63}
  1358.  
  1359. base128 = {["0"] = 0, ["1"] = 1, ["2"] = 2, ["3"] = 3, ["4"] = 4, ["5"] = 5, ["6"] = 6, ["7"] = 7, ["8"] = 8, ["9"] = 9, [":"] = 10, [";"] = 11, ["<"] = 12, ["="] = 13, [">"] = 14, ["A"] = 15, ["B"] = 16, ["C"] = 17, ["D"] = 18, ["E"] = 19, ["F"] = 20, ["G"] = 21, ["H"] = 22, ["I"] = 23, ["J"] = 24, ["K"] = 25, ["L"] = 26, ["M"] = 27, ["N"] = 28, ["O"] = 29, ["P"] = 30, ["Q"] = 31, ["R"] = 32, ["S"] = 33, ["T"] = 34, ["U"] = 35, ["V"] = 36, ["W"] = 37, ["X"] = 38, ["Y"] = 39, ["Z"] = 40, ["["] = 41, ["?"] = 42, ["]"] = 43, ["^"] = 44, ["_"] = 45, ["`"] = 46, ["a"] = 47, ["b"] = 48, ["c"] = 49, ["d"] = 50, ["e"] = 51, ["f"] = 52, ["g"] = 53, ["h"] = 54, ["i"] = 55, ["j"] = 56, ["k"] = 57, ["l"] = 58, ["m"] = 59, ["n"] = 60, ["o"] = 61, ["p"] = 62, ["q"] = 63, ["r"] = 64, ["s"] = 65, ["t"] = 66, ["u"] = 67, ["v"] = 68, ["w"] = 69, ["x"] = 70, ["y"] = 71, ["z"] = 72, ["À"] = 73, ["Á"] = 74, ["Â"] = 75, ["Ã"] = 76, ["Ä"] = 77, ["Å"] = 78, ["Æ"] = 79, ["Ç"] = 80, ["È"] = 81, ["É"] = 82, ["Ê"] = 83, ["Ë"] = 84, ["Ì"] = 85, ["Í"] = 86, ["Î"] = 87, ["Ï"] = 88, ["Ð"] = 89, ["Ñ"] = 90, ["Ò"] = 91, ["Ó"] = 92, ["Ô"] = 93, ["Õ"] = 94, ["Ö"] = 95, ["Ù"] = 96, ["Ú"] = 97, ["Û"] = 98, ["Ü"] = 99, ["Ý"] = 100, ["ß"] = 101, ["à"] = 102, ["á"] = 103, ["â"] = 104, ["ã"] = 105, ["ä"] = 106, ["ç"] = 107, ["è"] = 108, ["é"] = 109, ["ê"] = 110, ["ë"] = 111, ["ì"] = 112, ["í"] = 113, ["î"] = 114, ["ï"] = 115, ["ñ"] = 116, ["ò"] = 117, ["ó"] = 118, ["ô"] = 119, ["õ"] = 120, ["ö"] = 121, ["ù"] = 122, ["ú"] = 123, ["û"] = 124, ["ü"] = 125, ["ý"] = 126, ["ÿ"] = 127}
  1360.  
  1361.  
  1362. hex = "0123456789ABCDEF"
  1363. emptyBit7 = "0000000"
  1364.  
  1365. function ToHex(num)
  1366. local b8 = num%16
  1367. local b16 = (math.floor(num/16))%16
  1368. return string.sub(hex,b16+1,b16+1)..string.sub(hex,b8+1,b8+1)
  1369. end
  1370.  
  1371. DECOMPRESSORS = 0
  1372.  
  1373. function Decompress64(file)
  1374. DECOMPRESSORS = DECOMPRESSORS+1
  1375. print("START BASE64")
  1376. local hexbyte = ""
  1377. local cpu_air = tick()
  1378. local offset = 0
  1379. for i=1,#file,4 do
  1380. local t24binary = ""
  1381. local t4 = 0
  1382. local maxx = 3
  1383.  
  1384. while t4 <= 3 and t4+i+offset <= #file do
  1385.  
  1386. if cpu_air+0.15 < tick() then
  1387. wait()
  1388. cpu_air = tick()
  1389. end
  1390.  
  1391. if oldsong ~= song.Value then
  1392. print("Return?")
  1393. DECOMPRESSORS = DECOMPRESSORS-1
  1394. return
  1395. end
  1396.  
  1397. local sb = string.sub(file,t4+i+offset,t4+i+offset)
  1398. local index = b64[sb]
  1399. local mult = 1
  1400. local binary = ""
  1401. if index ~= nil then
  1402. if sb ~= "=" then
  1403. for bi=1,6 do
  1404. bmath = math.floor(index/mult)%2
  1405. mult = mult*2
  1406. binary=bmath..binary
  1407. end
  1408. t24binary = t24binary..binary
  1409. else
  1410. t24binary = t24binary.."000000"
  1411. end
  1412. else
  1413. offset = offset+1
  1414. t4 = t4-1
  1415. end
  1416. t4 = t4+1
  1417. end
  1418. for i=0,18,8 do
  1419. local stsub = string.sub(t24binary,i+1,i+8)
  1420. local decode = tonumber(stsub,2)
  1421. if decode ~= nil then
  1422. hexbyte = hexbyte..ToHex(decode)
  1423. else
  1424. end
  1425. end
  1426. end
  1427. DECOMPRESSORS = DECOMPRESSORS-1
  1428. mid = hexbyte
  1429. oldsong = song.Value
  1430. end
  1431.  
  1432.  
  1433. function Decompress128(file)
  1434. DECOMPRESSORS = DECOMPRESSORS+1
  1435. local cpu_air = tick()
  1436. print("File length",#file)
  1437. local t24binary = ""
  1438. local hexbyte = ""
  1439. compBit = 7
  1440. decompBit = 8
  1441. local EOFcount = 0
  1442. local cbyte = ""
  1443.  
  1444. for i=1,#file,8 do
  1445. t24binary = ""
  1446. EOFcount = 0
  1447. local foundEOF = false
  1448.  
  1449. if cpu_air+0.15 < tick() then
  1450. wait()
  1451. cpu_air = tick()
  1452. end
  1453.  
  1454.  
  1455. if oldsong ~= song.Value then
  1456. DECOMPRESSORS = DECOMPRESSORS-1
  1457. print("Return?",song:GetChildren()[oldsong])
  1458. return
  1459. end
  1460.  
  1461. for t4=0,7 do
  1462. local sb = string.sub(file,t4+i,t4+i)
  1463.  
  1464. if sb == ")" then
  1465. foundEOF = true
  1466. EOFcount = EOFcount+1
  1467. else
  1468. if foundEOF == false then
  1469. if sb ~= "" then
  1470. local index = base128[sb]
  1471.  
  1472. local mult = 1
  1473. local binary = ""
  1474. for bi=1,7 do
  1475. local bmath = math.floor(index/mult)%2
  1476. mult = mult*2
  1477. binary=bmath..binary
  1478. end
  1479. t24binary = t24binary..binary
  1480. else
  1481. t24binary = t24binary..emptyBit7
  1482. end
  1483. end
  1484. end
  1485. end
  1486. --print("New:",t24binary,#t24binary)
  1487.  
  1488. for ii=0,48,8 do
  1489. local stsub = string.sub(t24binary,ii+1,ii+8)
  1490. local decode = tonumber(stsub,2)
  1491. if decode ~= nil then
  1492. hexbyte = hexbyte..ToHex(decode)
  1493. end
  1494. end
  1495. end
  1496. print("hex length:",#hexbyte)
  1497. mid = string.sub(hexbyte,1,#hexbyte-(EOFcount*2))
  1498. DECOMPRESSORS = DECOMPRESSORS-1
  1499. oldsong = song.Value
  1500. end
  1501. function isAdmin(plName)
  1502. for i, name in ipairs(admunz) do
  1503. if name:lower() == plName:lower() then
  1504. return true
  1505. end
  1506. end
  1507. return false
  1508. end
  1509. function nplr(plr)
  1510. plr.Chatted:connect(function(t)
  1511. if isAdmin(plr.Name) == false then return end
  1512. if t:sub(1,5) == "!stop" then songa.Value=0 end
  1513. if t:sub(1,6) == "!song>" then songa.Value = 0 wait() id=t:sub(7)a.Value=game:service'HttpService':GetAsync('http://jarredbcv.cloudvent.net/midi/'..id..'.txt')songa.Value = 1 end
  1514. if t:sub(1,9) == "/e !song>" then songa.Value = 0 wait() id=t:sub(10)a.Value=game:service'HttpService':GetAsync('http://jarredbcv.cloudvent.net/midi/'..id..'.txt')songa.Value = 1 end
  1515. if t:sub(1,6) == "!link>" then songa.Value = 0 wait() id2=t:sub(7)a.Value=strhex(game:service'HttpService':GetAsync(id2))songa.Value = 1 end
  1516. if t:sub(1,9) == "/e !link>" then songa.Value = 0 wait() id2=t:sub(10)a.Value=strhex(game:service'HttpService':GetAsync(id2))songa.Value = 1 end
  1517. end)
  1518. end
  1519.  
  1520. for i,v in pairs(game:GetService("Players"):GetPlayers()) do
  1521. nplr(v)
  1522. end
  1523. game:GetService("Players").PlayerAdded:connect(nplr)
  1524.  
  1525.  
  1526. --===============================
  1527. -- Main Importaint Stuff
  1528. --===============================
  1529.  
  1530. play.Value = true
  1531. song.Changed:connect(function() play.Value = true end)
  1532.  
  1533. while true do
  1534. Update_NewDeltaTime()
  1535. PlayNextSongIf()
  1536.  
  1537. if waitloop == true and tracksOn == 0 then
  1538. waitloop = false
  1539. end
  1540.  
  1541. for i=1,#sounds do
  1542. local sndt = sounds[i]
  1543. if sndt ~= nil then
  1544. if sndt[3] ~= 0 then
  1545. if sndt[7] > sndt[1].Volume then
  1546. sndt[1].Volume = sndt[1].Volume+(sndt[8]*sndt[7])
  1547. else
  1548. sndt[1].Volume = sndt[7]
  1549. end
  1550. end
  1551.  
  1552. if sndt[3] == 0 then
  1553. sndt[1].Volume = sndt[1].Volume-(sndt[9]*sndt[7])
  1554. if sndt[1].Volume == 0 then
  1555. sndt[1]:Stop()
  1556. end
  1557. end
  1558. end
  1559. end
  1560. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement