Skip to content

Commit

Permalink
Release RS5K Mapper v1.1 (#1279)
Browse files Browse the repository at this point in the history
Region shortcuts
Colored pitch key
  • Loading branch information
tiagolr authored Oct 22, 2023
1 parent d857a9e commit 2f8a40a
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions FX/tilr_RS5K Mapper.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
-- @description RS5K Mapper
-- @author tilr
-- @version 1.0
-- @version 1.1
-- @changelog
-- Region shortcuts
-- Colored pitch key
-- @provides tilr_RS5K Mapper/rtk.lua
-- @screenshot https://raw.githubusercontent.com/tiagolr/rs5kmapper/master/doc/rs5kmapper.gif
-- @about
Expand Down Expand Up @@ -35,7 +38,7 @@ globals = {
win_x = nil,
win_y = nil,
win_w = 768,
win_h = 385,
win_h = 370,
key_h = 30,
key_w = 6,
region_h = 254,
Expand Down Expand Up @@ -94,6 +97,7 @@ function make_region(keymin, keymax, velmin, velmax)
selected = false,
updated = false,
track = 0,
nfx = 0,
fxid = '',
file = '',
}
Expand Down Expand Up @@ -121,7 +125,8 @@ end
function draw_pitch_key()
for _, reg in ipairs(regions) do
if reg.selected then
gfx.set(1, .5, 0, 1)
local red, green, blue, _ = rtk.color.rgba(colors[(reg.track % #colors) + 1])
gfx.set(red, green, blue, 1)
key = reg.keymin - reg.pitch
if key < 0 or key > 127 then
return
Expand All @@ -131,6 +136,28 @@ function draw_pitch_key()
end
end

function draw_region_shortcuts()
local regs = {}
for _, reg in ipairs(regions) do table.insert(regs, reg) end
table.sort(regs, function (a,b)
return a.track == b.track and a.nfx < b.nfx or a.track < b.track
end)
for i, reg in ipairs(regs) do
local red, green, blue, _ = rtk.color.rgba(colors[(reg.track % #colors) + 1])
gfx.set(red, green, blue, reg.selected and 0.75 or 0.5)
local w = math.max(math.min(18, math.floor(g.win_w / #regs)), 3)
local h = 18
local x = (i - 1) * w
local y = g.win_h - g.key_h - g.region_h - h
gfx.rect(x, y, w, h, 1)
gfx.set(red, green, blue, reg.selected and 1 or 0)
gfx.rect(x, y, w, h, 0)
if mouse.toggled and rtk.point_in_box(rtk.mouse.x, rtk.mouse.y, x, y, w, h) then
select_region(reg)
end
end
end

function draw_guides()
for i=0, 127, 12 do
gfx.set(1, 1, 1, .25)
Expand Down Expand Up @@ -220,6 +247,7 @@ function create_region_from_fx(track, nfx, ntrack)
reg.track = ntrack
reg.file = file
reg.fxid = fxid
reg.nfx = nfx
reg.pitch = tonumber(pitch)
return reg
end
Expand Down Expand Up @@ -490,6 +518,7 @@ function draw()
draw_pitch_key()
draw_guides()
draw_regions()
draw_region_shortcuts()
draw_ui()
update_widget_drag()
if mouse.toggled then
Expand Down

0 comments on commit 2f8a40a

Please sign in to comment.