diff --git a/src/love/data/songs/2hot/2hot-chart.json b/src/love/data/songs/2hot/2hot-chart.json index 561ac6f8..cbd80e6e 100644 --- a/src/love/data/songs/2hot/2hot-chart.json +++ b/src/love/data/songs/2hot/2hot-chart.json @@ -12,7 +12,7 @@ { "t": 8901.0989010989, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 10549.4505494506, @@ -33,7 +33,7 @@ { "t": 40549.0989010989, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 42197.4505494506, @@ -52,7 +52,7 @@ { "t": 51098.0989010989, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 52746.4505494506, @@ -79,7 +79,7 @@ { "t": 80109.8901098901, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 81758.2417582417, @@ -96,7 +96,7 @@ { "t": 85384.0989010989, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 87032.4505494505, @@ -123,7 +123,7 @@ { "t": 117032.098901099, "e": "FocusCamera", - "v": { "char": 2, "x": 100, "y": 105 } + "v": { "char": 2, "x": 0, "y": 0 } }, { "t": 118680.450549451, diff --git a/src/love/lib/fft/ffthread.lua b/src/love/lib/fft/ffthread.lua index 5f3d101d..01913105 100644 --- a/src/love/lib/fft/ffthread.lua +++ b/src/love/lib/fft/ffthread.lua @@ -1,6 +1,7 @@ local fftSize = ... local fft = require("lib.fft.luafft") local inChannel = love.thread.getChannel("toFFT") +local util = require("modules.util") local fftSizeInv = 1 / fftSize -- Because multiplication is slightly faster local function postprocess(x) @@ -12,13 +13,22 @@ while true do -- Get input local toFFT = inChannel:pop() -- Perform FFT - local res = fft.fft(toFFT, false) - -- Process the results to build an intuitive FFT result - local fftArray = {} - for i = 1, fftSize / 2 do - fftArray[i] = postprocess(res[i]:abs() + res[#res-i+1]:abs()) - end - -- Send the result to the main thread - love.thread.getChannel("fft"):push(fftArray) + local res = {} + util.tryExcept( + function() + res = fft.fft(toFFT, false) + + -- Process the results to build an intuitive FFT result + local fftArray = {} + for i = 1, fftSize / 2 do + fftArray[i] = postprocess(res[i]:abs() + res[#res-i+1]:abs()) + end + -- Send the result to the main thread + love.thread.getChannel("fft"):push(fftArray) + end, + function(err) + love.thread.getChannel("fft"):push({}) + end + ) end end \ No newline at end of file diff --git a/src/love/lib/fft/lovefft.lua b/src/love/lib/fft/lovefft.lua index 8888621b..8de18184 100644 --- a/src/love/lib/fft/lovefft.lua +++ b/src/love/lib/fft/lovefft.lua @@ -74,7 +74,7 @@ function loveFFT:push() -- Launch a new FFT computation in a separate thread usi for i = 1, self.fftSize do toFFT[i] = 0 for j = 1, self.channelCount do - toFFT[i] = toFFT[i] + self.soundData:getSample(sample + i - 1, j) + util.tryExcept(function() toFFT[i] = toFFT[i] + self.soundData:getSample(sample + i - 1, j) end) end end -- Send to thread diff --git a/src/love/modules/util.lua b/src/love/modules/util.lua index ce03a095..26085b6e 100644 --- a/src/love/modules/util.lua +++ b/src/love/modules/util.lua @@ -106,6 +106,13 @@ function table.mergeValues(t1, t2) return t1 end +function util.tryExcept(try, except) + local status, err = pcall(try) + if not status and except then + except(err) + end +end + -- God like coding --[[ function util.🍰(🥰, 🥵)