Skip to content

Commit

Permalink
Release Keyboard splitter v1.1 (#1278)
Browse files Browse the repository at this point in the history
Region shortcuts
Colored pitch key
Pitch key follows note transpose
  • Loading branch information
tiagolr authored Oct 22, 2023
1 parent 5561e72 commit d857a9e
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions Tracks/tilr_Keyboard splitter.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-- @description Keyboard splitter
-- @author tilr
-- @version 1.0
-- @version 1.1
-- @changelog
-- Region shortcuts
-- Colored pitch key
-- Pitch key follows note transpose
-- @provides
-- tilr_Keyboard splitter/rtk.lua
-- [effect] tilr_Keyboard splitter/MIDI Keyvel Filter.jsfx
Expand Down Expand Up @@ -35,7 +39,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 @@ -118,8 +122,9 @@ end

function draw_pitch_key()
for _, reg in ipairs(regions) do
gfx.set(1, .5, 0, 1)
gfx.rect(reg.keymin * g.key_w, g.win_h - g.key_h, g.key_w, g.key_h)
local red, green, blue, _ = rtk.color.rgba(colors[(reg.track % #colors) + 1])
gfx.set(red, green, blue, 1)
gfx.rect(reg.keymin * g.key_w + (reg.transpose * g.key_w), g.win_h - g.key_h, g.key_w, g.key_h)
end
end

Expand Down Expand Up @@ -150,6 +155,27 @@ function draw_regions()
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
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 = 18
local x = (i - 1) * w
local y = g.win_h - g.key_h - g.region_h - w
gfx.rect(x, y, w, w, 1)
gfx.set(red, green, blue, reg.selected and 1 or 0)
gfx.rect(x, y, w, w, 0)
if mouse.toggled and rtk.point_in_box(rtk.mouse.x, rtk.mouse.y, x, y, w, w) then
select_region(reg)
end
end
end

-- recalc regions after window resize
function recalc_regions ()
for _, reg in ipairs(regions) do
Expand Down Expand Up @@ -198,7 +224,7 @@ function create_regions ()
local fxi = reaper.TrackFX_AddByName(track, 'MIDI Keyvel Filter', false, -1000)
if fxi == -1 then
reaper.PreventUIRefresh(-1)
reaper.MB('MIDI Keyvel Filter JSFX is missing. Make sure you install it via ReaPack.', '', 0)
reaper.MB('MIDI Keyvel Filter JSFX is missing. Please reinstall this package.', '', 0)
reaper.Undo_EndBlock('keysplitter - create_regions', 0)
return
end
Expand Down Expand Up @@ -516,6 +542,7 @@ function draw()
draw_pitch_key()
draw_guides()
draw_regions()
draw_region_shortcuts()
draw_ui()
update_widget_drag()
if mouse.toggled then
Expand Down Expand Up @@ -593,7 +620,6 @@ function init()
ui_transpose = ui_hbox:add(rtk.Text{'', w=60, cursor=rtk.mouse.cursors.SIZE_NS })
ui_transpose.onmousedown = function () start_widget_drag('transpose') end


ui_helpbox = window:add(rtk.Text{'No region selected', padding=10})

ui_right_side = window:add(rtk.HBox{w=g.win_w, padding=10})
Expand Down

0 comments on commit d857a9e

Please sign in to comment.