Advertisement
eea

music

eea
May 30th, 2023 (edited)
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.66 KB | None | 0 0
  1. local pre = "rbxassetid://"
  2. local bass = pre.."5706402256"
  3. local sine = pre.."146750669"
  4. local square = pre.."9040512330"
  5. local piano = pre.."179578660"
  6. local sawtooth = pre.."9040512075"
  7. local static = pre.."9040512492"
  8. local waid = 1/8
  9. --{id, length}
  10. local instruments = {
  11.     ["bass"] = {bass, nil};
  12.     ["sine"] = {sine, 2*waid};
  13.     ["square"] = {square, 2*waid};
  14.     ["sawtooth"] = {sawtooth, waid*1.5};
  15.     ["static"] = {static, waid*1.5};
  16.     ["piano"] = {piano, nil};
  17. }
  18.  
  19. function preload()
  20.     for i, v in pairs(instruments) do
  21.         local sound = Instance.new("Sound", script)
  22.         sound.SoundId = v[1]
  23.         if not sound.IsLoaded then
  24.             sound.Loaded:Wait()
  25.         end
  26.         instruments[i] = {sound, v[2]}
  27.     end
  28. end
  29. preload()
  30.  
  31. local char = workspace:WaitForChild("kaibrown4")
  32. local track, loop, instrument, shift = ...
  33. track = track or 2
  34. loop = loop or false
  35. instrument = instrument or "sine"
  36. shift = shift or 0
  37. shift = tonumber(shift)
  38. track = tonumber(track)
  39. loop = loop == "true" and true or false
  40.  
  41. local vol = 0.08
  42.  
  43. function convrang(x, minx, maxx, miny, maxy)
  44.     return ((x - minx)/(maxx-minx))*(maxy - miny) + miny
  45. end
  46. local s = {6, 3, 6, 6, 3, 6, 3, 3, 5, 3, 5, 5, 1, 5, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, -2, 1, -2, -2, -4, -2, -4, -4, 3, -4, 3, 3, 3, 3, 3, 3, 5, 3, 5, 5, 8, 5, 8, 8, 5, 8, 5, 5, 3, 5, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, [-1] = -4; [-2] = 64; [-3] = 1; [-4] = "that one part from kerosene";}
  47. local b = {
  48.     [1] = {48};
  49.     [2] = {55, 72, 48, 51};
  50.     [3] = {51, 48};
  51.     [4] = {55, 67, 48};
  52.     [5] = {55, 48};
  53.     [6] = {55, 48, 60};
  54.     [7] = {60, 48};
  55.     [8] = {48, 55, 72};
  56.     [9] = {48};
  57.     [10] = {55, 48, 67};
  58.     [11] = {48};
  59.     [12] = {55, 60, 48};
  60.     [13] = {48};
  61.     [14] = {55, 72, 48};
  62.     [15] = {48};
  63.     [16] = {58, 63, 51};
  64.     [17] = {51};
  65.     [18] = {58, 75, 55, 51};
  66.     [19] = {55, 51};
  67.     [20] = {51, 70, 58};
  68.     [21] = {58, 70, 51};
  69.     [22] = {51, 58, 63};
  70.     [23] = {63, 51};
  71.     [24] = {51, 58, 75};
  72.     [25] = {51};
  73.     [26] = {51, 58, 70};
  74.     [27] = {70, 51};
  75.     [28] = {51, 58, 63};
  76.     [29] = {51};
  77.     [30] = {75, 58, 51};
  78.     [31] = {75, 51};
  79.     [32] = {57, 62, 50};
  80.     [33] = {62, 50};
  81.     [34] = {57, 54, 74, 50};
  82.     [35] = {50, 54, 74};
  83.     [36] = {69, 50, 57};
  84.     [37] = {69, 57, 50};
  85.     [38] = {57, 50, 62};
  86.     [39] = {62, 50};
  87.     [40] = {50, 57, 74};
  88.     [41] = {50};
  89.     [42] = {69, 50, 57};
  90.     [43] = {69, 50};
  91.     [44] = {50, 57, 62};
  92.     [45] = {50};
  93.     [46] = {51, 58, 74};
  94.     [47] = {57, 50};
  95.     [48] = {49, 56, 61};
  96.     [49] = {61, 49};
  97.     [50] = {49, 73, 53, 56};
  98.     [51] = {53, 49, 73};
  99.     [52] = {56, 68, 49};
  100.     [53] = {49, 68, 56};
  101.     [54] = {49, 56, 61};
  102.     [55] = {61, 49};
  103.     [56] = {56, 73, 49};
  104.     [57] = {73, 49};
  105.     [58] = {49, 56, 68};
  106.     [59] = {68, 49};
  107.     [60] = {49, 56, 61};
  108.     [61] = {61, 49};
  109.     [62] = {49, 73, 56};
  110.     [63] = {49, 73};
  111.     [0] = {60, 48, 55};
  112.     [-1] = 48;
  113.     [-2] = 64;
  114.     [-4] = "random song i made";
  115. }
  116.  
  117. local c = {
  118. [32] = {57, 67};
  119. [34] = {55, 67};
  120. [4] = {52};
  121. [6] = {54};
  122. [8] = {54};
  123. [10] = {52};
  124. [12] = {54};
  125. [14] = {54};
  126. [16] = {52};
  127. [62] = {54};
  128. [18] = {54};
  129. [60] = {52};
  130. [20] = {54};
  131. [56] = {54};
  132. [22] = {56, 68};
  133. [50] = {66, 54};
  134. [24] = {57, 68};
  135. [48] = {52};
  136. [26] = {56, 68};
  137. [44] = {54, 66};
  138. [28] = {52, 68};
  139. [38] = {54, 66};
  140. [30] = {55, 67};
  141. [36] = {52, 67};
  142. [-1] = 52;
  143. [-2] = 64;
  144. [-4] = "another song i made";
  145. }
  146.  
  147. local d = {
  148. [0] = {74};
  149. [4] = {84, 72};
  150. [70] = {81};
  151. [72] = {70, 82, 58};
  152. [76] = {65, 82, 58, 70};
  153. [78] = {84};
  154. [16] = {74, 62};
  155. [126] = {74};
  156. [18] = {86, 74};
  157. [124] = {71, 55, 67, 62};
  158. [20] = {84, 72};
  159. [122] = {67};
  160. [22] = {80, 68};
  161. [120] = {67, 55};
  162. [88] = {57, 69};
  163. [118] = {71};
  164. [26] = {67, 79};
  165. [116] = {55, 74, 67, 59};
  166. [28] = {77, 65};
  167. [114] = {79};
  168. [30] = {79, 67};
  169. [112] = {67, 55, 83};
  170. [96] = {56, 68};
  171. [110] = {82};
  172. [108] = {80, 68, 63, 56};
  173. [104] = {80, 56, 68};
  174. [36] = {84, 72};
  175. [102] = {79};
  176. [38] = {81, 69};
  177. [100] = {80, 60, 56, 68};
  178. [40] = {83, 71};
  179. [94] = {76};
  180. [92] = {64, 57, 73, 69};
  181. [90] = {69};
  182. [44] = {79, 67};
  183. [86] = {73};
  184. [46] = {77, 65};
  185. [84] = {57, 61, 69, 76};
  186. [48] = {74, 62};
  187. [82] = {81};
  188. [50] = {86, 74};
  189. [80] = {69, 57, 85};
  190. [52] = {84, 72};
  191. [6] = {81, 69};
  192. [54] = {81, 69};
  193. [8] = {83, 71};
  194. [56] = {79, 67};
  195. [14] = {77, 65};
  196. [58] = {77, 65};
  197. [12] = {79, 67};
  198. [60] = {79, 67};
  199. [64] = {58, 70};
  200. [62] = {81, 69};
  201. [68] = {70, 58, 62, 82};
  202. [-1] = 80;
  203. [-2] = 126;
  204. [-4] = "that one song about the funny skeleton (the other song)"
  205. }
  206.  
  207. local e = {
  208. [0] = {73, 57};
  209. [2] = {68, 61};
  210. [4] = {73, 64};
  211. [6] = {68, 61};
  212. [8] = {73, 64};
  213. [10] = {61, 68};
  214. [12] = {73, 57};
  215. [14] = {61, 68};
  216. [16] = {73, 64};
  217. [18] = {61, 68};
  218. [20] = {73, 64};
  219. [22] = {68, 61};
  220. [24] = {66, 54};
  221. [26] = {58, 64};
  222. [28] = {68, 61};
  223. [30] = {58};
  224. [32] = {61, 64};
  225. [94] = {59};
  226. [34] = {66, 58};
  227. [92] = {68, 64};
  228. [36] = {71, 54};
  229. [90] = {59};
  230. [38] = {70, 58};
  231. [88] = {69, 64};
  232. [40] = {71, 61};
  233. [86] = {59};
  234. [42] = {73, 58};
  235. [84] = {56, 71};
  236. [44] = {70, 61};
  237. [82] = {61, 73};
  238. [46] = {58, 66};
  239. [80] = {71, 64};
  240. [48] = {73, 50};
  241. [78] = {69, 61};
  242. [50] = {66, 54};
  243. [76] = {73, 64};
  244. [52] = {73, 57};
  245. [74] = {69, 61};
  246. [54] = {66, 54};
  247. [72] = {57, 73};
  248. [56] = {73, 57};
  249. [70] = {53};
  250. [58] = {66, 54};
  251. [68] = {74, 57};
  252. [60] = {73, 49};
  253. [66] = {65, 53};
  254. [62] = {65, 53};
  255. [64] = {73, 57};
  256. [-1] = 60;
  257. [-2] = 94;
  258. [-4] = "fallen down - Toby Fox";
  259. }
  260.  
  261.  
  262. print(math.min(table.unpack(s)))
  263. print(math.max(table.unpack(s)))
  264.  
  265. --print(convrang(3-1, 0, 3, 0, 11+1))
  266. local tracks = {s, b, c, d, e}
  267. local sel = tracks[track]
  268.  
  269. print("track: "..track, "loop: "..tostring(loop))
  270.  
  271. owner.Chatted:Connect(function(msg)
  272.     if msg:sub(1, 6) == "shift:" then
  273.         local nshift = tonumber(msg:sub(8, -1))
  274.         if not nshift then error("invalid pitch-shift") end
  275.         shift = tonumber(msg:sub(8, -1))
  276.     end
  277.     if msg:sub(1, 6) == "instr:" then
  278.         local instr = msg:sub(8, -1)
  279.         if not instruments[instr] then error("invalid instrument") end
  280.         instrument = instr
  281.     end
  282.     if msg:sub(1, 4) == "vol:" then
  283.         local nvol = tonumber(msg:sub(6, -1))
  284.         if not nvol then error("invalid volume") end
  285.         vol = nvol
  286.     end
  287.     if msg:sub(1, 6) == "speed:" then
  288.         local s_speed = tonumber(msg:sub(8,-1))
  289.         if not s_speed then error("invalid speed") end
  290.         waid = 1/(8*s_speed)
  291.     end
  292. end)
  293.  
  294. local times = 0
  295.  
  296. local wm = Instance.new("WorldModel", script)
  297.  
  298. local displaypart = Instance.new("Part", wm)
  299. displaypart.Anchored = true
  300. displaypart.Size = Vector3.one
  301. displaypart.Transparency = 0.8
  302.  
  303. local billboardg = Instance.new("BillboardGui", displaypart)
  304. billboardg.Size = UDim2.fromScale(20,4)
  305. billboardg.MaxDistance = 55
  306. billboardg.Adornee = displaypart
  307.  
  308. local text = Instance.new("TextLabel", billboardg)
  309. text.Size = UDim2.fromScale(1,1)
  310. text.TextScaled = true
  311. text.Position = UDim2.fromScale(0,-0.5)
  312. text.BackgroundTransparency = 1
  313. text.TextColor3 = Color3.new(1,1,1)
  314. text.TextStrokeColor3 = Color3.new()
  315. text.TextStrokeTransparency = 0
  316.  
  317. local prog = Instance.new("Part", wm)
  318. prog.Size = Vector3.new(0.5, 0.5, 128)
  319. prog.Color = Color3.new(1,1,1)
  320. prog.Transparency = 0.5
  321. prog.Anchored = true
  322. prog.Material = "SmoothPlastic"
  323.  
  324. print(instrument, instruments[instrument])
  325.  
  326. function play(pos)
  327.     times = times + 1
  328.     displaypart.Position = pos + Vector3.yAxis*3/2
  329.     text.Text = "Now Playing: "..sel[-4]
  330.     for i = sel[-3] or 0,sel[-2]-1+(sel[-3] or 0) do
  331.         local val = sel[i]
  332.         prog.Position = Vector3.new(-i, 3, 63.5)/2 + pos
  333.         if type(sel[i]) == "number" then sel[i] = {val} end
  334.         if not val then task.wait(waid) continue end
  335.         for j = 1,#sel[i] do
  336.             local val2 = sel[i][j]
  337.             local sound = instruments[instrument][1]:Clone()
  338.             sound.Parent = prog
  339.             sound.Pitch = 2 * 2 ^ ((val2 - sel[-1] + shift)/12)
  340.             sound.Volume = vol
  341.             sound.PlaybackRegionsEnabled = true
  342.             sound.RollOffMinDistance = 80
  343.             sound.RollOffMaxDistance = 80
  344.             --sound.Pitch = convrang(s[i], 1, 8, 0.5, 1)
  345.             --local pitch = Instance.new("PitchShiftSoundEffect", sound)
  346.             --pitch.Octave = convrang(s[i], 0, 8, 1, 1+1)
  347.             if times == 1 then
  348.                 local part = Instance.new("Part", wm)
  349.                 part.Material = "Neon"
  350.                 part.Position = Vector3.new(-i, 3,  val2 + shift)/2 + pos
  351.                 part.Size = Vector3.one/2
  352.                 part.Anchored = true
  353.                 part.Color = Color3.fromHSV(((val2 - sel[-1]) % 12)/12, 1, 0.6)
  354.             end
  355.             local len = instruments[instrument][2] or sound.TimeLength/2
  356.             sound.PlaybackRegion = NumberRange.new(sound.TimeLength/2 - len, sound.TimeLength/2 + len)
  357.             sound:Play()
  358.             print(sound.IsLoaded)
  359.         end
  360.         task.wait(waid)
  361.     end
  362. end
  363.  
  364. if loop then
  365.     local headpos = owner.Character.Head.Position
  366.     play(headpos)
  367.     while task.wait() do
  368.         play(headpos)
  369.     end
  370. else
  371.     play(owner.Character.Head.Position)
  372. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement