1 day, until you can finally:
Get the current Marker/Region at mouse-position, the graphical-size they are drawn as into the arrangeview:
Code:
-- Ultraschall-API demoscript by Meo Mespotine 30.11.2018
--
-- shows, which markers/regions are underneath the mouse-cursor
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
function main()
-- get mouseposition, markers and regions as well as the mouse-context
x,y=reaper.GetMousePosition()
marker=ultraschall.GetMarkerByScreenCoordinates(x, false)
region=ultraschall.GetRegionByScreenCoordinates(x, false)
window = reaper.BR_GetMouseCursorContext()
-- if the markers/regions underneath the mouse have changed and if mouse is in ruler,
-- show the currently found markers and regions in the ReaConsole-window
if (marker~=oldmarker or region~=oldregion) and window=="ruler" then
if marker=="" then marker="\n\n\n" end -- small hack to avoid the output being
-- too jumpy when no marker is found
reaper.ClearConsole()
reaper.ShowConsoleMsg("Found Markers: \n"..marker.."\n\nFoundRegions:\n"..region)
end
-- keep the old values to check next defer-cycle, whether anything has changed
oldmarker=marker
oldregion=region
-- start the next defer-cycle
reaper.defer(main)
end
main()
and to show something else as well:
...you can store extstates for MediaTracks
Code:
-- Ultraschall-API demoscript by Meo Mespotine 11.12.2018
--
-- store new ExtStates for the first selected MediaTrack
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
-- get the first selected MediaTrack and it's name
track=reaper.GetSelectedTrack(0,0)
if track==nil then return end
retval, name = reaper.GetTrackName(track,"")
if name==nil then name="" end
-- get the extstates stored with this MediaTrack
storedextstates=""
for i=1, 5 do
temp, temp2 = ultraschall.GetTrackExtState(track, tostring(i))
if temp2==nil then temp2="" end
storedextstates=storedextstates..tostring(temp2)..","
end
-- show the inputdialog, with the already stored extstates as default
retval, retvals_csv = reaper.GetUserInputs("Set TrackExtStates "..name, 5, "01,02,03,04,05,extrawidth=300", tostring(storedextstates))
if retval==false then return end
-- separate the returned inputfields into an array
count, vals = ultraschall.CSV2IndividualLinesAsArray(retvals_csv, ",")
-- set the new ExtStates to the MediaTrack
for i=1, 5 do
retval = ultraschall.SetTrackExtState(track, tostring(i), vals[i],true)
end
Code:
-- Ultraschall-API demoscript by Meo Mespotine 11.12.2018
--
-- retrieve and display ExtStates for the first selected MediaTrack
-- will be displayed in the ReaScript-Console
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
-- prepare some variables
oldoutput=""
oldtrack=""
function main()
-- get the first selected MediaTrack and it's name
track=reaper.GetSelectedTrack(0,0)
if track~=nil then
retval, name = reaper.GetTrackName(track, "")
-- Get the ExtStates store with the first selected MediaTrack
output=""
for i=1, 5 do
temp, temp2 = ultraschall.GetTrackExtState(track, tostring(i))
if temp2==nil then temp2="" end
output=output.." "..i..": "..temp2.."\n"
end
-- if extstates have been changed or the selected MediaTrack has changed, display the
-- extstates into the ReaConsole-window
if oldoutput~=output or oldtrack~=track then reaper.ClearConsole() reaper.ShowConsoleMsg("Showing ExtState for track: "..name.."\n\n"..output) end
oldoutput=output
oldtrack=track
end
-- repeat the whole thing
reaper.defer(main)
end
-- let's boogie
main()
as well as for MediaItems. When ItemNotes are not enough:
Code:
-- Ultraschall-API demoscript by Meo Mespotine 11.12.2018
--
-- store new ExtStates for the first selected MediaItem
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
-- get the first selected MediaItem and it's name
item=reaper.GetSelectedMediaItem(0,0)
if item==nil then return end
name = ultraschall.GetItemName(item)
if name==nil then name="" end
-- get the extstates stored with this MediaItem
storedextstates=""
for i=1, 5 do
temp, temp2 = ultraschall.GetItemExtState(item, tostring(i))
if temp2==nil then temp2="" end
storedextstates=storedextstates..tostring(temp2)..","
end
-- show the inputdialog, with the already stored extstates as default
retval, retvals_csv = reaper.GetUserInputs("Set ItemExtStates "..name, 5, "01,02,03,04,05,extrawidth=300", tostring(storedextstates))
if retval==false then return end
-- separate the returned inputfields into an array
count, vals = ultraschall.CSV2IndividualLinesAsArray(retvals_csv, ",")
-- set the new ExtStates to the MediaItem
for i=1, 5 do
retval = ultraschall.SetItemExtState(item, tostring(i), vals[i],true)
end
Code:
-- Ultraschall-API demoscript by Meo Mespotine 11.12.2018
--
-- retrieve and display ExtStates for the first selected MediaItem
-- will be displayed in the ReaScript-Console
dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")
-- prepare some variables
oldoutput=""
olditem=""
function main()
-- get the first selected MediaItem and it's name
item=reaper.GetSelectedMediaItem(0,0)
if item~=nil then
name = ultraschall.GetItemName(item)
if name==nil then name="" end
-- Get the ExtStates store with the selected MediaItem
output=""
for i=1, 5 do
temp, temp2 = ultraschall.GetItemExtState(item, tostring(i))
if temp2==nil then temp2="" end
output=output.." "..i..": "..temp2.."\n"
end
-- if extstates have been changed or the selected MediaItem has changed, display the
-- extstates into the ReaConsole-window
if oldoutput~=output or olditem~=item then reaper.ClearConsole() reaper.ShowConsoleMsg("Showing ExtState for Item: "..name.."\n\n"..output) end
oldoutput=output
olditem=item
end
-- repeat the whole thing
reaper.defer(main)
end
-- let's boogie
main()