nonogamer9

test

Jan 18th, 2026 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. term.setGraphicsMode(2)
  2. term.setFrozen(true)
  3.  
  4. local filename = "qqwomk.raw"
  5. if not fs.exists(filename) then
  6. local success = shell.run("wget", "https://files.catbox.moe/qqwomk.raw", filename)
  7. if not success then
  8. filename = nil
  9. end
  10. end
  11.  
  12. local speaker = peripheral.find("speaker")
  13. local audioThread = nil
  14. if speaker and filename then
  15. audioThread = coroutine.create(function()
  16. local file = fs.open(filename, "rb")
  17. if not file then coroutine.yield() return end
  18.  
  19. local samples = {}
  20. while true do
  21. local byte = file.read()
  22. if not byte then break end
  23. samples[#samples + 1] = byte - 128
  24. end
  25. file.close()
  26.  
  27. local inputRate = 64000
  28. local outputRate = 48000
  29. local ratio = inputRate / outputRate
  30. local resampled = {}
  31.  
  32. for i = 1, math.floor(#samples / ratio) do
  33. local src = (i - 1) * ratio + 1
  34. local idx = math.floor(src)
  35. local frac = src - idx
  36. local s1 = samples[idx] or 0
  37. local s2 = samples[idx + 1] or s1
  38. resampled[i] = s1 + (s2 - s1) * frac
  39. end
  40.  
  41. local volume = 2
  42. local chunkSize = 64 * 1024
  43. local totalSamples = #resampled
  44. local position = 1
  45.  
  46. while true do
  47. local chunk = {}
  48. for i = 1, chunkSize do
  49. local idx = position + i - 1
  50. if idx > totalSamples then
  51. position = 1
  52. break
  53. end
  54. local sample = math.floor(resampled[idx] * volume + 0.5)
  55. sample = math.max(-128, math.min(127, sample))
  56. chunk[i] = sample
  57. end
  58. if #chunk > 0 then
  59. while not speaker.playAudio(chunk) do
  60. os.pullEvent("speaker_audio_empty")
  61. end
  62. end
  63. position = position + #chunk
  64. if position > totalSamples then
  65. position = 1
  66. end
  67. end
  68. end)
  69. coroutine.resume(audioThread)
  70. end
  71.  
  72. local sin = math.sin
  73. local cos = math.cos
  74. local w, h = term.getSize(2)
  75. local barCount = math.min(200, h)
  76. local stripWidth = 12
  77. local halfStrip = stripWidth / 2
  78. local centerX = math.floor(w / 2)
  79. local t = 0
  80.  
  81. local copperSize = 64
  82. for i = 0, copperSize - 1 do
  83. local hue = (i * 0.1 + t * 0.5) % 6.283185
  84. local r = (sin(hue) * 0.5 + 0.5) ^ 0.7
  85. local g = (sin(hue + 2.0944) * 0.5 + 0.5) ^ 0.7
  86. local b = (sin(hue + 4.1888) * 0.5 + 0.5) ^ 0.7
  87. term.setPaletteColor(i, r, g, b)
  88. end
  89.  
  90. local redMetal = {180, 181, 182, 183}
  91. term.setPaletteColor(180, 0.55, 0.08, 0.08)
  92. term.setPaletteColor(181, 0.75, 0.12, 0.12)
  93. term.setPaletteColor(182, 0.95, 0.22, 0.22)
  94. term.setPaletteColor(183, 0.65, 0.10, 0.10)
  95.  
  96. local goldMetal = {190, 191, 192, 193}
  97. term.setPaletteColor(190, 0.55, 0.45, 0.08)
  98. term.setPaletteColor(191, 0.75, 0.65, 0.12)
  99. term.setPaletteColor(192, 0.95, 0.85, 0.22)
  100. term.setPaletteColor(193, 0.65, 0.55, 0.10)
  101.  
  102. while true do
  103. term.clear()
  104.  
  105. for y = 0, h - 1 do
  106. local c = math.floor(((y * 0.8 + t * 15) % copperSize + copperSize) % copperSize)
  107. term.drawPixels(0, y, c, w, 1)
  108. end
  109.  
  110. for i = barCount, 1, -1 do
  111. local height = i
  112. local y = barCount - i
  113.  
  114. local x = math.floor(
  115. centerX
  116. + centerX
  117. * sin(t + i / 20)
  118. * sin(t + i / 48)
  119. )
  120.  
  121. for band = 0, halfStrip - 1 do
  122. local xx = x + band
  123. if xx >= 0 and xx < w then
  124. local col = redMetal[(band % #redMetal) + 1]
  125. term.drawPixels(xx, y, col, 1, height)
  126. end
  127. end
  128.  
  129. for band = 0, halfStrip - 1 do
  130. local xx = x + halfStrip + band
  131. if xx >= 0 and xx < w then
  132. local col = goldMetal[(band % #goldMetal) + 1]
  133. term.drawPixels(xx, y, col, 1, height)
  134. end
  135. end
  136. end
  137.  
  138. if audioThread and coroutine.status(audioThread) ~= "dead" then
  139. coroutine.resume(audioThread)
  140. end
  141.  
  142. t = t + 0.05
  143. term.setFrozen(false)
  144. sleep(0.04)
  145. term.setFrozen(true)
  146. end
  147.  
Add Comment
Please, Sign In to add comment