Skip to content
The Chat Archive
gpt-4o-2024-08-06· OpenAI WildChat-4.8M (AI2)

function Loop() local txt = " " local retval, tracknumber, fxnumber, paramnumber =…

  1. User

    function Loop() local txt = " " local retval, tracknumber, fxnumber, paramnumber = reaper.GetLastTouchedFX() if retval then if (tracknumber >> 16) == 0 then -- Track FX or Input FX local track = reaper.CSurf_TrackFromID(tracknumber, false) local _, track_name = reaper.GetTrackName(track) if tracknumber == 0 then track_name = 'Master Track' else track_name = ''..tostring(tracknumber)..' | '..track_name end local _, fx_name = reaper.TrackFX_GetFXName(track, fxnumber, "") local _, param_name = reaper.TrackFX_GetParamName(track, fxnumber, paramnumber, "") local fx_id = "" if (fxnumber >> 24) == 1 then fx_id = "Input FX: " end local _, f_value = reaper.TrackFX_GetFormattedParamValue(track, fxnumber, paramnumber,'') txt = track_name..' | '..fx_id..fx_name..'\n'..param_name..' : '..f_value else -- ITEM FX >>>>> local track = reaper.CSurf_TrackFromID((tracknumber & 0xFFFF), false) local _, track_name = reaper.GetTrackName(track) track_name = 'Track '..tostring(tracknumber & 0xFFFF) ..' - ' ..track_name local takenumber = (fxnumber >> 16) fxnumber = (fxnumber & 0xFFFF) local item_index = (tracknumber >> 16)-1 local item = reaper.GetTrackMediaItem(track, item_index) local take = reaper.GetTake(item, takenumber) local _, fx_name = reaper.TakeFX_GetFXName(take, fxnumber, "") local _, take_param_name = reaper.TakeFX_GetParamName(take, fxnumber, paramnumber, "") local _, f_value = reaper.TakeFX_GetFormattedParamValue(take, fxnumber, paramnumber,'') txt = track_name..'\nItem '..tostring(item_index+1).." Take "..tostring(takenumber+1)..'\nFX: '..fx_name..'\nParam: '..take_param_name..' Value: '..f_value end end local str_w, str_h = gfx.measurestr(txt) gfx.x, gfx.y = (1), (gfx.h - str_h) / 2 gfx.drawstr(txt) gfx.update() if gfx.getchar() >= 0 then reaper.defer(Loop) end end

    local title = 'Last Touched Param' local wnd_w, wnd_h = 300,20 local __, __, scr_w, scr_h = reaper.my_getViewport(0, 0, 0, 0, 0, 0, 0, 0, 1) gfx.init(title, wnd_w, wnd_h, 0, (scr_w - wnd_w) / 2, (1)) gfx.setfont(1,"calibri", 13)

    -- Optional: set window topmost if reaper.APIExists('JS_Window_FindTop') then local hwnd = reaper.JS_Window_FindTop(title, true) if hwnd then reaper.JS_Window_SetZOrder(hwnd, "TOPMOST", hwnd) end end Loop()

    turn this reaper lua script into a rtk borderless window

  2. Assistant

    To convert your REAPER Lua script with gfx to use the rtk library for a borderless window, you would first need to ensure you have access to the rtk library in your environment. Assuming you have rtk available, here's a sample code that approximates what you want using rtk for creating a borderless window:

    local rtk = require 'rtk'
    
    -- Create a new app
    local app = rtk.Application()
    
    -- Create a new window without a border
    local window = app:new_window({
        w = 300,
        h = 20,
        title = "Last Touched Param",
        borderless = true,  -- Make window borderless
    })
    
    -- Center the window on screen
    window:center()
    
    -- Set up a text widget
    local text_widget = rtk.Label{align='center', fontsize=13}
    window:add(text_widget, {fillw=true})
    
    -- Function that updates the text widget
    local function update_widget()
        local txt = " "
        local retval, tracknumber, fxnumber, paramnumber = reaper.GetLastTouchedFX()
        if retval then
            if (tracknumber >> 16) == 0 then -- Track FX or Input FX
                local track = reaper.CSurf_TrackFromID(tracknumber, false)
                local _, track_name = reaper.GetTrackName(track)
                if tracknumber == 0 then track_name = 'Master Track' else track_name = ''..tostring(tracknumber)..' | '..track_name end
                local _, fx_name = reaper.TrackFX_GetFXName(track, fxnumber, "")
                local _, param_name = reaper.TrackFX_GetParamName(track, fxnumber, paramnumber, "")
                local fx_id = "" if (fxnumber >> 24) == 1 then fx_id = "Input FX: " end
                local _, f_value = reaper.TrackFX_GetFormattedParamValue(track, fxnumber, paramnumber,'')
                txt = track_name..' |  '..fx_id..fx_name..'\n'..param_name..' : '..f_value
            else -- ITEM FX >>>>>
                local track = reaper.CSurf_TrackFromID((tracknumber & 0xFFFF), false)
                local _, track_name = reaper.GetTrackName(track)
                track_name = 'Track '..tostring(tracknumber & 0xFFFF) ..' - ' ..track_name
                local takenumber = (fxnumber >> 16)
                fxnumber = (fxnumber & 0xFFFF)
                local item_index = (tracknumber >> 16)-1
                local item = reaper.GetTrackMediaItem(track, item_index)
                local take = reaper.GetTake(item, takenumber)
                local _, fx_name = reaper.TakeFX_GetFXName(take, fxnumber, "")
                local _, take_param_name = reaper.TakeFX_GetParamName(take, fxnumber, paramnumber, "")
                local _, f_value = reaper.TakeFX_GetFormattedParamValue(take, fxnumber, paramnumber,'')
                txt = track_name..'\nItem '..tostring(item_index+1).."  Take "..tostring(takenumber+1)..'\nFX: '..fx_name..'\nParam: '..take_param_name..' Value: '..f_value
            end
        end
        -- Update the widget with the new txt
        text_widget.text = txt
    end
    
    -- Add logic to run the update function continuously
    function loop()
        update_widget()
        app:defer(loop)
    end
    
    -- Start the update loop
    loop()
    
    -- Call run to start the app
    app:run()
    

    Changes Made:

    1. Require rtk: Start by requiring rtk which you need to manage the UI elements.
    2. Initialize an rtk Application: Create an rtk.Application that handles the main event loop.
    3. Create a Window: Use rtk.Window with borderless=true to make it borderless.
    4. Add a Label: Add an rtk.Label as a placeholder for dynamic text.
    5. Update Logic: Keep your text update logic but update the rtk.Label instead of drawing in a gfx context.
    6. Loop Functionality: Implement a loop using app:defer to update continuously.
    7. Run the Application: Start the application loop with app:run.

    This should provide you with a borderless window using the rtk library instead of directly using gfx. Make sure rtk is installed and available in your REAPER setup to avoid runtime issues.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.