From e1530057a62db05cffbae5870f93d15eab7e5a8e Mon Sep 17 00:00:00 2001 From: 20kdc Date: Sat, 9 Jun 2018 22:55:35 +0100 Subject: [PATCH] Fix nbcompose and knbs bugs --- repository/apps/app-nbcompose.lua | 16 ++++++++++------ repository/data/app-claw/local.lua | 4 ++-- repository/libs/knbs.lua | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/repository/apps/app-nbcompose.lua b/repository/apps/app-nbcompose.lua index c7417d1..f97c208 100644 --- a/repository/apps/app-nbcompose.lua +++ b/repository/apps/app-nbcompose.lua @@ -212,7 +212,9 @@ function genMain() file.ticks[songPosition][layer][1] = defInst nt = file.ticks[songPosition][layer][2] end - nb.playNote(iTranslation[defInst] or 0, nt - 33, file.layers[layer][2] / 100) + if nb then + nb.playNote(iTranslation[defInst] or 0, nt - 33, file.layers[layer][2] / 100) + end require("knbs").correctSongLH(file) update() theStatusBar.update(window) @@ -220,7 +222,9 @@ function genMain() file.ticks[songPosition] = file.ticks[songPosition] or {} local note = noteKey:find(string.char(a), 1, true) - 1 file.ticks[songPosition][layer] = {defInst, note + 33} - nb.playNote(iTranslation[defInst] or 0, note, file.layers[layer][2] / 100) + if nb then + nb.playNote(iTranslation[defInst] or 0, note, file.layers[layer][2] / 100) + end require("knbs").correctSongLH(file) update() theStatusBar.update(window) @@ -299,13 +303,13 @@ function genMain() neoux.tcbutton(30, 2, "Layers", function (w) window.reset(genLayers()) end), - neoux.tcrawview(39, 2, {"qT/S"}), + neoux.tcrawview(39, 2, {"cT/S"}), neoux.tcfield(43, 2, 8, function (tx) if tx then local txn = tonumber(tx) or 0 - file.tempo = math.min(math.max(0, math.floor(txn * 4)), 65535) + file.tempo = math.min(math.max(0, math.floor(txn)), 65535) end - return tostring(math.floor(file.tempo / 25)) + return tostring(file.tempo) end), theStatusBar, table.unpack(theNotePane) @@ -323,7 +327,7 @@ function tick() local temp = 1 / math.max(file.tempo / 100, 0.01) if os.uptime() >= uptime + temp then -- execute at this song position - if file.ticks[songPosition] then + if file.ticks[songPosition] and nb then for i = 0, file.height - 1 do local tck = file.ticks[songPosition][i] if tck then diff --git a/repository/data/app-claw/local.lua b/repository/data/app-claw/local.lua index 98b09e5..454c749 100644 --- a/repository/data/app-claw/local.lua +++ b/repository/data/app-claw/local.lua @@ -166,7 +166,7 @@ return { }, ["app-nbcompose"] = { desc = "Music player/composer using the NBS format", - v = 0, + v = 1, deps = { "neo", "lib-knbs", @@ -219,7 +219,7 @@ return { -- libraries ["lib-knbs"] = { desc = "NBS reader/writer library", - v = 0, + v = 1, deps = { "zzz-license-pd" }, diff --git a/repository/libs/knbs.lua b/repository/libs/knbs.lua index 3ce12b4..818affd 100644 --- a/repository/libs/knbs.lua +++ b/repository/libs/knbs.lua @@ -125,7 +125,7 @@ return { nbs.layers[i] = nil end -- add layers up to target - for i = nbs.height - 1, layers - 1 do + for i = nbs.height, layers - 1 do nbs.layers[i] = {"L" .. i, 100} end -- clean up song