From d4c5a2fbf87a8e51d3c8cfb54bb126cfdfb1d2ab Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:00:08 -0400 Subject: [PATCH 1/9] update color literals to love11+ (0,1) range --- demo/main.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/main.lua b/demo/main.lua index 7136455..e00e2db 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -504,14 +504,14 @@ function createOther() local draw = function(o) if source then - love.graphics.setColor(255, 255, 255) + love.graphics.setColor(1, 1, 1) love.graphics.draw(wavecanvas, 495, 25) -- Draw a fancy position cursor local pos = source:tell("samples") local max = sounddata:getSampleCount() local x = 495 + (pos / max) * 125 - love.graphics.setColor(255, 153, 0) + love.graphics.setColor(1, 0.6, 0) love.graphics.line(x, 25, x, 165) end @@ -613,7 +613,7 @@ function updateWaveCanvas(waveview) local t = love.timer.getTime() wavecanvas:clear() love.graphics.setCanvas(wavecanvas) - love.graphics.setColor(255, 255, 255) + love.graphics.setColor(1, 1, 1) love.graphics.setLineStyle("rough") -- Iterate through the passed table and draw all lines to the canvas @@ -628,7 +628,7 @@ function updateWaveCanvas(waveview) end -- Draw the zero line - love.graphics.setColor(255, 80, 51, 200) + love.graphics.setColor(1, 0.314, 0.2, 0.784) love.graphics.line(0, 70, 125, 70) love.graphics.setCanvas() From fcaf02be04bb35aa98b5ddb4b8b364437235fda9 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:00:39 -0400 Subject: [PATCH 2/9] update conf.lua to reflect 11.3 assumption --- demo/conf.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/conf.lua b/demo/conf.lua index c94e801..1494c73 100644 --- a/demo/conf.lua +++ b/demo/conf.lua @@ -1,5 +1,5 @@ function love.conf(t) - t.version = love._version:match("0%.9%.%d+") or "0.9.x" + t.version = 11.3 t.window.width = 640 t.window.height = 600 t.window.title = "sfxr.lua Demo" From 4578dd1125ee2f547630582546b33e34697ae876 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:01:08 -0400 Subject: [PATCH 3/9] move to maintained fork of LoveFrames --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index e4ad5eb..6647b25 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "loveframes"] path = demo/loveframes - url = https://github.com/NikolaiResokav/LoveFrames + url = https://github.com/linux-man/LoveFrames.git From 5ac67575d67bd2351e923e7c435b7df00d86ee51 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:01:53 -0400 Subject: [PATCH 4/9] move to HEAD on maintained fork of loveframes --- demo/loveframes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/loveframes b/demo/loveframes index a02fafd..36e3d58 160000 --- a/demo/loveframes +++ b/demo/loveframes @@ -1 +1 @@ -Subproject commit a02fafd9023442e98f88ad8a4c09bea5450cd47e +Subproject commit 36e3d5874c7624ce95b9ed5ebbdb40ae457a03eb From 47310a90106d31313c3371b180d5c82610a6a811 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:04:24 -0400 Subject: [PATCH 5/9] field name in the sound table is waveform not wavetype... this is probably a longstanding bug brought to the fore by the fact that loveframes now crashes if the choice value is nil --- demo/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/main.lua b/demo/main.lua index e00e2db..56b7802 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -606,7 +606,7 @@ function updateParameters() s:SetValue(v) t:SetText("Repeat Speed " .. tostring(math.floor(v * 100) / 100)) - guiparams.waveform:SetChoice(waveFormList[sound.wavetype]) + guiparams.waveform:SetChoice(waveFormList[sound.waveform]) end function updateWaveCanvas(waveview) From fbc589955385b7769de428bcca89aa894e692d9f Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:07:47 -0400 Subject: [PATCH 6/9] skin stuff, update clear call --- demo/main.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/demo/main.lua b/demo/main.lua index 56b7802..8caab23 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -2,6 +2,7 @@ -- love . local sfxr = require("sfxr") +local lf = require('loveframes/loveframes') -- Global stuff local source @@ -515,7 +516,7 @@ function createOther() love.graphics.line(x, 25, x, 165) end - lf.skins.available["Orange"].DrawForm(o) + lf.GetActiveSkin().form(o) end f.Draw = draw @@ -611,8 +612,8 @@ end function updateWaveCanvas(waveview) local t = love.timer.getTime() - wavecanvas:clear() love.graphics.setCanvas(wavecanvas) + love.graphics.clear(unpack(lf.GetActiveSkin().controls.frame_body_color)) love.graphics.setColor(1, 1, 1) love.graphics.setLineStyle("rough") @@ -644,9 +645,7 @@ function updateStatistics() end function love.load() - require("loveframes") - lf = loveframes - lf.util.SetActiveSkin("Orange") + lf.SetActiveSkin("Orange") love.graphics.setBackgroundColor(200, 200, 200) From 6b173609a043f108eb47ff3bdf933c18adbe2cb1 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:33:07 -0400 Subject: [PATCH 7/9] fix version check so that it doesn't fail of the loaded version is equal to the expected version. --- sfxr.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sfxr.lua b/sfxr.lua index d1e0342..254817d 100644 --- a/sfxr.lua +++ b/sfxr.lua @@ -1381,7 +1381,7 @@ function sfxr.Sound:load(f) local params, version = assert(loadstring(code))() -- check version compatibility - assert(version > sfxr.VERSION, "incompatible version: " .. tostring(version)) + assert(version >= sfxr.VERSION, "incompatible version: loaded " .. tostring(version) .. " wanted >= " .. tostring(sfxr.VERSION)) self:resetParameters() -- merge the loaded table into the own From 4e859aec86c2c2755f18323c5667c77197359bd4 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:34:28 -0400 Subject: [PATCH 8/9] replace reference to globals freq and bits with rate and depth --- sfxr.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sfxr.lua b/sfxr.lua index 254817d..f36493a 100644 --- a/sfxr.lua +++ b/sfxr.lua @@ -868,7 +868,7 @@ function sfxr.Sound:generateSoundData(rate, depth, sounddata) return nil end - local data = sounddata or love.sound.newSoundData(count, freq, bits, 1) + local data = sounddata or love.sound.newSoundData(count, rate, depth, 1) for i = 0, #tab - 1 do data:setSample(i, tab[i + 1]) @@ -1264,10 +1264,10 @@ function sfxr.Sound:exportWAV(f, rate, depth) w32(16) -- chunk size w16(1) -- compression code (1 = PCM) w16(1) -- channel number - w32(freq) -- sampling rate - w32(freq * bits / 8) -- bytes per second - w16(bits / 8) -- block alignment - w16(bits) -- bits per sample + w32(rate) -- sampling rate + w32(rate * depth / 8) -- bytes per second + w16(depth / 8) -- block alignment + w16(depth) -- bits per sample -- Write the header of the data chunk ws("data") @@ -1292,9 +1292,9 @@ function sfxr.Sound:exportWAV(f, rate, depth) -- Seek back to the stored positions seek(pos_fsize) - w32(pos_csize - 4 + samples * bits / 8) -- remaining file size + w32(pos_csize - 4 + samples * depth / 8) -- remaining file size seek(pos_csize) - w32(samples * bits / 8) -- chunk size + w32(samples * depth / 8) -- chunk size if close then f:close() From fdbfe2d6d21863165ed038a7ac3a76f76c3f27b2 Mon Sep 17 00:00:00 2001 From: geoffbeier Date: Fri, 5 Jun 2020 03:45:04 -0400 Subject: [PATCH 9/9] use non-deprecated function to check for sounds directory and assert that it was created/exists --- demo/main.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/main.lua b/demo/main.lua index 8caab23..d9481d6 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -649,9 +649,13 @@ function love.load() love.graphics.setBackgroundColor(200, 200, 200) - if not love.filesystem.isDirectory("sounds") then + local pathinfo = love.filesystem.getInfo("sounds") + if pathinfo == nil then love.filesystem.createDirectory("sounds") + pathinfo = love.filesystem.getInfo("sounds") end + assert(pathinfo.type == 'directory', '"sounds" exists in ' .. + love.filesystem.getRealDirectory('sounds') .. ' but is not a directory') sound = sfxr.newSound()