Skip to content
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "loveframes"]
path = demo/loveframes
url = https://github.com/NikolaiResokav/LoveFrames
url = https://github.com/linux-man/LoveFrames.git
2 changes: 1 addition & 1 deletion demo/conf.lua
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion demo/loveframes
Submodule loveframes updated 242 files
25 changes: 14 additions & 11 deletions demo/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
-- love .

local sfxr = require("sfxr")
local lf = require('loveframes/loveframes')

-- Global stuff
local source
Expand Down Expand Up @@ -504,18 +505,18 @@ 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

lf.skins.available["Orange"].DrawForm(o)
lf.GetActiveSkin().form(o)
end
f.Draw = draw

Expand Down Expand Up @@ -606,14 +607,14 @@ 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)
local t = love.timer.getTime()
wavecanvas:clear()
love.graphics.setCanvas(wavecanvas)
love.graphics.setColor(255, 255, 255)
love.graphics.clear(unpack(lf.GetActiveSkin().controls.frame_body_color))
love.graphics.setColor(1, 1, 1)
love.graphics.setLineStyle("rough")

-- Iterate through the passed table and draw all lines to the canvas
Expand All @@ -628,7 +629,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()
Expand All @@ -644,15 +645,17 @@ function updateStatistics()
end

function love.load()
require("loveframes")
lf = loveframes
lf.util.SetActiveSkin("Orange")
lf.SetActiveSkin("Orange")

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()

Expand Down
16 changes: 8 additions & 8 deletions sfxr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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")
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down