As someone who likes to time his reverb (pre-delay and delay) as well as other fx (like the hz on a chorus) it would be amazing to have a script (or two individual ones) that tell you the value in ms or hz of the particular tempo it is actually in the song in the position you have the edit or time cursor in case the song has different tempo or time signature changes.
There are websites/apps that allow you to do this (i even made a excel file for the calculation) but it would be a lot faster and easier to just
click a button inside reaper
example:
120BPM 4/4
2 measures 4000.00 ms
1 measure 2000.00 ms
1/2• note 1500.00 ms
1/2 note 1000.00 ms
1/2T note 666.67 ms
1/4• note 750.00 ms
1/4 note 500.00 ms
1/4T note 333.33 ms
1/8• note 375.00 ms
1/8 note 250.00 ms
1/8T note 166.67 ms
1/16• note 187.50 ms
1/16 note 125.00 ms
1/16T note 83.33 ms
1/32• note 93.75 ms
1/32 note 62.50 ms
1/32T note 41.67 ms
1/64• note 46.88 ms
1/64 note 31.25 ms
1/64T note 20.83 ms
After a half hour of failed experiments i got it to also display 1/2, whole notes and two whole notes. (not bad for someone with absolute ZERO knowledge of this XD)
I wish i knew more about programming to make it also calculate according to the time signature
Hi - I've just started making tutorial videos for my JSFX, and there's one task I end up doing a lot, and I'd love to know if it's already an action (or if it could be).
The task is: split all items at the start and end of the current time selection, shrink all items in this range by some fixed factor (e.g. 3x), and move all future items back by an appropriate amount so that there's no longer a gap.
Bumping this - it would be really useful for me, and enable me to make more video guides/demos for my effects.
Last edited by geraintluff; 03-27-2018 at 03:26 AM.
I have a bunch of presets and project templates which make everything else pretty smooth, so this editing is now the most time-consuming part (aside from writing the script), and having it as a keyboard shortcut would be a life-saver!
I have a bunch of presets and project templates which make everything else pretty smooth, so this editing is now the most time-consuming part (aside from writing the script), and having it as a keyboard shortcut would be a life-saver!
Thanks for the video!
I still have one question:
Is it necessary to time-stretch items (by changing playrates) instead of just setting their lengths to "1/3 of the time selection length"?
Is it necessary to time-stretch items (by changing playrates) instead of just setting their lengths to "1/3 of the time selection length"?
Ideally, yeah - if I say something like "we can use these dials to get the sound we want" and then twiddle multiple things around or click between screens, it's good to show the changes I make in fast-motion, instead of just BAM ten dials jump at once.
If that's a load of work, fair enough. I can muddle through doing it by hand as before, it's just fiddly and time-consuming which doesn't make me excited about making more videos.
Ideally, yeah - if I say something like "we can use these dials to get the sound we want" and then twiddle multiple things around or click between screens, it's good to show the changes I make in fast-motion, instead of just BAM ten dials jump at once.
If that's a load of work, fair enough. I can muddle through doing it by hand as before, it's just fiddly and time-consuming which doesn't make me excited about making more videos.
That shouldn't be too much work
I still have to add code to reposition items (I'll post the script soon):
local reaper = reaper
-- Settings ------------------------------
local new_playrate = 3
local new_volume = -6 -- new volume in dBs
local overlap = 0.005 -- in seconds (cross-fade length)
------------------------------------------
function main()
local time_sel_start, time_sel_end = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
local time_sel_len = time_sel_end - time_sel_start
if time_sel_len == 0 then
return
end
reaper.Undo_BeginBlock()
reaper.Main_OnCommand(40289, 0) -- Unselect all items
-- Split items at time selection
-- (this action also selects the split items)
reaper.Main_OnCommand(40061, 0)
local sel_item_count = reaper.CountSelectedMediaItems(0)
for i=1, sel_item_count do
local sel_item = reaper.GetSelectedMediaItem(0, i-1)
if sel_item then
local tr = reaper.GetMediaItemTrack(sel_item) -- Get item parent track
if tr then
local item_number = reaper.GetMediaItemInfo_Value(sel_item, "IP_ITEMNUMBER")
reaper.SetMediaItemInfo_Value(sel_item, "D_VOL", 10^(new_volume / 20))
reaper.SetMediaItemInfo_Value(sel_item, "D_LENGTH", time_sel_len/new_playrate)
reaper.SetMediaItemInfo_Value(sel_item, "D_FADEOUTLEN_AUTO", overlap) -- fade out
-- Set new values for split item (and for all takes it has)
for t=1, reaper.CountTakes(sel_item) do
local take = reaper.GetMediaItemTake(sel_item, t-1)
if take then
reaper.SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", new_playrate)
end
end
-- Move later items
for j=item_number+1, reaper.CountTrackMediaItems(tr)-1 do
local item = reaper.GetTrackMediaItem(tr, j)
if item then
local item_pos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
reaper.SetMediaItemInfo_Value(item, "D_POSITION", item_pos - time_sel_len + time_sel_len/new_playrate - overlap)
if j == item_number+1 then
reaper.SetMediaItemInfo_Value(item, "D_FADEINLEN_AUTO", overlap) -- fade in
end
end
end
end
end
end
reaper.UpdateArrange()
reaper.Undo_EndBlock("Trim items in time selection", -1)
end
main()
@geraintluff
I'll change the code so that it moves items on every track. Currently it doesn't do that (see the gif from 7s ->).
Also, envelope points are not moved with items. Calling "Time selection: Remove contents of time selection (moving later items)" from the script would fix that and would be the easiest way.
@geraintluff
I'll change the code so that it moves items on every track. Currently it doesn't do that (see the gif from 7s ->).
I hadn't written any Lua or ReaScripts before, but your code was readable and nicely commented, so I had a go!
This seems to solve the problem:
Code:
local reaper = reaper
-- Settings ------------------------------
local shrink_factor = 3
local new_volume = -6 -- new volume in dBs
local overlap = 0.005 -- in seconds (cross-fade length)
------------------------------------------
function main()
local time_sel_start, time_sel_end = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
local time_sel_len = time_sel_end - time_sel_start
if time_sel_len == 0 then
return
end
reaper.Undo_BeginBlock()
reaper.Main_OnCommand(40289, 0) -- Unselect all items
-- Split items at time selection
-- (this action also selects the split items)
reaper.Main_OnCommand(40061, 0)
for item_index=1, reaper.CountMediaItems(0) do
item = reaper.GetMediaItem(0, item_index-1)
local start = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
local length = reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
-- Change the position and/or rate
if start > time_sel_start - overlap then
if (start + length < time_sel_end + overlap) then
-- in the selection
-- change the volume
local vol = reaper.GetMediaItemInfo_Value(item, "D_VOL")
reaper.SetMediaItemInfo_Value(item, "D_VOL", vol*10^(new_volume/20))
-- move it backwards
reaper.SetMediaItemInfo_Value(item, "D_POSITION", time_sel_start + (start - time_sel_start)/shrink_factor - overlap)
reaper.SetMediaItemInfo_Value(item, "D_LENGTH", length/shrink_factor)
-- shrink it
for t=1, reaper.CountTakes(item) do
local take = reaper.GetMediaItemTake(item, t-1)
if take then
local playrate = reaper.GetMediaItemTakeInfo_Value(take, "D_PLAYRATE")
new_playrate = playrate;
reaper.SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", playrate*shrink_factor)
end
end
else
-- after the selection: move it backwards
reaper.SetMediaItemInfo_Value(item, "D_POSITION", start - (time_sel_end - time_sel_start)*(1 - 1/shrink_factor) - overlap*2)
end
end
-- Fade out items that (originally) finish at the start/end of selection
if (start + length >= time_sel_start - overlap and start + length <= time_sel_start + overlap)
or (start + length >= time_sel_end - overlap and start + length <= time_sel_end + overlap) then
local fade = reaper.GetMediaItemInfo_Value(item, "D_FADEOUTLEN_AUTO")
if (fade < overlap) then
reaper.SetMediaItemInfo_Value(item, "D_FADEOUTLEN_AUTO", overlap)
end
end
-- Fade in items that (originally) start at the start/end of selection
if (start >= time_sel_start - overlap and start <= time_sel_start + overlap)
or (start >= time_sel_end - overlap and start <= time_sel_end + overlap) then
local fade = reaper.GetMediaItemInfo_Value(item, "D_FADEINLEN_AUTO")
if (fade < overlap) then
reaper.SetMediaItemInfo_Value(item, "D_FADEINLEN_AUTO", overlap)
end
end
end
reaper.UpdateArrange()
reaper.Undo_EndBlock("Shrink items in time selection", -1)
end
main()
This version doesn't bother inspecting which items have been split, or which tracks they're on. Instead, it just knows that after the split, every item will be either before, after or inside the selection (not crossing either boundary) so it loops through and handles those three cases appropriately, then adds fades to anything that starts/ends at the selection boundaries.
(This is just an adaptation of your code - anything else like automation is still a mystery, but this is all I needed for my particular case.)
So thank you again - not only will this script save me a whole bunch of time, but it's also been a really clear and nice introduction to Lua and ReaScripting.
Last edited by geraintluff; 03-29-2018 at 04:47 PM.
So thank you again - not only will this script save me a whole bunch of time, but it's also been a really clear and nice introduction to Lua and ReaScripting.
I'm glad I could help and thanks for your JSFXs - really nice work!
Willing to pay for a script that can change the value of the video delay compensation value in preferences via a toggle action from say 0 to 90 ms.
Is this possible? It'd fine that I'll have to stop and start for the change to occur but I wasn't sure if this was even accessible via scripting?
The reason for it is I now have speakers that have a normal low latency minimal phase mode but also have a linear phase mode with a delay of around 90 ms so need a action button I can click to adjust video playback latency so that it matches the speaker delay.
Happy to pay a bit for it and a bit more if it's a pain because maybe it's got to be written low level or something. (like sws stuff)
Fingers crossed that it's possible!
Thanks.
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
Willing to pay for a script that can change the value of the video delay compensation value in preferences via a toggle action from say 0 to 90 ms.
Is this possible? It'd fine that I'll have to stop and start for the change to occur but I wasn't sure if this was even accessible via scripting?
The reason for it is I now have speakers that have a normal low latency minimal phase mode but also have a linear phase mode with a delay of around 90 ms so need a action button I can click to adjust video playback latency so that it matches the speaker delay.
Happy to pay a bit for it and a bit more if it's a pain because maybe it's got to be written low level or something. (like sws stuff)
Fingers crossed that it's possible!
Thanks.
Hi,
that seems to be possible (and it's really short script):
Code:
function main()
local is_new_value ,filename, section_id, command_id, mode, resolution, val = reaper.get_action_context()
local current_video_delay_compensation = reaper.SNM_GetIntConfigVar("video_delayms", -10000000)
if current_video_delay_compensation ~= -10000000 then
if current_video_delay_compensation >= 90 then
reaper.SNM_SetIntConfigVar("video_delayms", 0)
reaper.SetToggleCommandState(section_id, command_id, 0)
else
reaper.SNM_SetIntConfigVar("video_delayms", 90)
reaper.SetToggleCommandState(section_id, command_id, 1)
end
reaper.RefreshToolbar2(section_id, command_id)
end
end
reaper.defer(main)
...but it might need some adjustments:
It sets the delay compensation value to
0 ms if the value is currently 90 ms or more.
90 ms if the value is currently less than 90 ms
EDIT: value changes seem to be applied immediately
One question though would be, is there a way to to make it so a toolbar button will be active/lit up when it's in the 90ms mode and inactive/not lit when in the 9ms mode?
I've not dabbled much in this area before so I don't know if it can be queried like that or maybe I should put it into 2 actions and use sws custom actions to differentiate the active state?
Thanks.
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
One thing I wanted to ask is, is there a way for it to recall the last setting it was at when you quit reaper because now it defaults to the last setting in the actual preference but the button always starts off at "0"/off when it would be great if it knew which state it was still in.
No worries if that's not possible though. Small price to pay!
Again thanks!
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
Also, Just realised that I might as well compensate for the monitor/TVs lag/delay too which means in "0" mode I probably need to set it to a negative number.
If I just replace all the 0s in the script with say "-21" then it should still work right? Won't break it by using negative numbers?
EDIT: just tried the above and seems to work fine with negatives, woo hoo!
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
Last edited by musicbynumbers; 04-01-2018 at 10:03 AM.
Just wanted to make sure you got the donation as don't think I got a receipt from PayPal yetand don't want you to think I didn't appreciate it!
Thanks.
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
One thing I wanted to ask is, is there a way for it to recall the last setting it was at when you quit reaper because now it defaults to the last setting in the actual preference but the button always starts off at "0"/off when it would be great if it knew which state it was still in.
No worries if that's not possible though. Small price to pay!
Again thanks!
Thank you for the donation!
I tried to figure this out last night, but didn't get it working yet. I'll try to do another script that refreshes the toolbar button that is assigned to the (main) script.
It should be run as "global startup action" (there's "SWS/S&M: Set global startup action")
Quote:
Originally Posted by musicbynumbers
Also, Just realised that I might as well compensate for the monitor/TVs lag/delay too which means in "0" mode I probably need to set it to a negative number.
If I just replace all the 0s in the script with say "-21" then it should still work right? Won't break it by using negative numbers?
EDIT: just tried the above and seems to work fine with negatives, woo hoo!
I could use the SWS global action thing as suggested. Thanks.
I'll give it a go.
Not too concerned with which state it starts in but more that the button reflects the actual state.
I guess it's hard to do for this since it's not a on/off state so you don't get any feedback from reaper itself.
__________________ subproject FRs click here note: don't search for my pseudonym on the web. The "musicbynumbers" you find is not me or the name I use for my own music.
for example say we have short movie and need to export dialog time codes according to player names ..
Mr x
Mrs y
Child 1
Child 2
create 4 pre-named markers and add them to time line via action(s)
and export full time code at once via using:
X-Raym_Export markers as YouTube timecode for video description.lua
I have two interfaces connected to my laptop and frequently change between them.
Is it possible to make a script that switches between two interfaces with a key command?
That would be more convenient than repeatedly going to the prefs.
Cheers
With the help of Spk77 Ive already acheived a massive improvement in my.workflow by having a Script to autonatically Insert show my favorite Pro Q2 on the condition that mouse is over track and keycommand is pressed.
Now my further enhancement question is how would you script that it automatically enable the ProQ2 option to toggle FULLSCREEN VIEW of the plugin?
Id like to press the keycommand and make ProQ2 insert or Show already in full screen view if possible?
I could use the SWS global action thing as suggested. Thanks.
I'll give it a go.
Not too concerned with which state it starts in but more that the button reflects the actual state.
I guess it's hard to do for this since it's not a on/off state so you don't get any feedback from reaper itself.
I think I finally got it working...set this as "global startup action" (this is needed for syncing)
Code:
local button_off_val = -21 -- This value is set when the button is "OFF"
local button_on_val = 90 -- This value is set when the button is "ON"
function main()
local state = 0
local delay = 0
local is_new_value, filename, section_id, command_id, mode, resolution, val = reaper.get_action_context()
local toggle_state = reaper.GetToggleCommandStateEx(section_id, command_id)
if toggle_state == -1 then
if reaper.HasExtState("musicbynumbers", "video output delay") then
delay = tonumber(reaper.GetExtState("musicbynumbers", "video output delay"))
if delay == button_on_val then
state = 1
else
state = 0
end
else
--reaper.ShowConsoleMsg("No ext state" .. "\n")
state = 0
delay = button_off_val
end
else
if toggle_state == 1 then
state = 0
delay = button_off_val
else
state = 1
delay = button_on_val
end
end
reaper.SetToggleCommandState(section_id, command_id, state)
reaper.RefreshToolbar2(section_id, command_id)
reaper.SNM_SetIntConfigVar("video_delayms", delay)
reaper.SetExtState("musicbynumbers", "video output delay", tostring(delay), true)
end
reaper.defer(main)
A cheat sheet window that lists user selected commands and modifiers.
Without the Cheatsheet...
Code:
What was that key command I'm trying to remember again?
Opens Action list
What was it called now? Something 'select item', maybe 'track' too? [253 results]
Scrolls
Scrolls
I think 'enable' was in the action name? [0 results]
vs with...
Code:
What was that key command I'm trying to remember again?
Presses the Cheat Sheet button
Oh there it is H+shift+ctrl+opt etc etc
This would be available on the Main page, MIDI editor and Media Explorer.
Commands could be added with Action ID, selecting from the Action list (a la cycle action editor), or with manual text input.
The script would automatically retrieve the key commands name and shortcut (e.g. shift+T)
The user would be able to:
re-order the commands
Add subheadings to organise the list
A key command would toggle the Cheatsheet visibility OR it would be Visible while pressed.[possible?]
I recently got into a conversation of a user who needs to go to markers 11 to lets say 30 (or 20 would also be enough).
He wants to press . Then enter marker number 11 and it goes there.
Ive tried to bypass Reaper using autohotkey for Windows and all I am able to do is hold . Plus press 1 or 2 or 3.... and it sends a complex and improbable keycommand to trigger the go to markers action.
Can any one of you do something like this in Eel script please I really want to solve this out and learn at the same time from your code
Yes its a good feature I've seen it and it does what I need in the essence of it.
But is there a way to trick Reaper by doing something like "double tap Numpad1 to trigger marker 11" or "press . to open a tiny dialog that gets input 11 then closes itself". I'm looking for an instant method that would be as quick as triggering 1, 2, 3, 4...
In my workflow, I need a convenient adaptive deletion function. Is there an item? By pressing the "Delete" button, it is deleted. Is the area selected? By pressing the "Delete" button, the one that was selected is deleted. Is the track selected? When the button is pressed, it is deleted, etc.
The Reaper has its own action "Remove items / tracks / envelope points (depending on focus), 40697", it works fine, but has a big drawback - it ignores the selected area, removing the entire item. This makes it useless for me.
In search of a solution, I found a simple script that shares the action on the work area:
Code:
isSet = reaper.GetSet_LoopTimeRange( 0, 0, 0, 0, 0 )
focus = reaper.GetCursorContext()
if isSet == 0 then
reaper.Main_OnCommand(40697, 0)
else
if focus == 1 then
reaper.Main_OnCommand(reaper.NamedCommandLookup('40312'), 0)
elseif focus == 2 then
reaper.Main_OnCommand(40089, 0)
end
end
But it also has drawbacks. If the selection is start from the zero position, the entire item is deleted, but not the area. Secondly, if an area is selected, I can not delete items and tracks, until I remove the selection. This makes it useless for me.
I tried to replace the action with "_XENAKIOS_TSADEL", but it solved only one problem - selection from the zero position. But now I can not delete tracks and any selection of the area still blocks the removal of items.
As a result, in this script I use the cut function instead of the delete: "Edit: Cut items / tracks / envelope points (depending on focus) within time selection, if any (smart cut), 41384". This is the lesser of evils. Selecting an area blocks only deleting tracks, but not items. And the second - I constantly have some unexpected things on the clipboard.
I'm not one to give up easily. But I'm not a programmer. And I would be glad if someone helped me to solve my problem.
Perhaps, I always went the wrong way, using this script as a basis.
Move selected track to the end of tracklist (right side of mixer)
Hey guys, here's another request.
I would find it extremely useful if there was a command to move the selected track to the right side of the mixer. The only thing close i found was X-Raym script to move only one place "Script: X-Raym_Move selected tracks down on visible track list.lua".
I would be very much obliged if anyone could program an eel script like:
integer t= total number of tracks
integer s= track number of selected track
integer i= t-s
and the loop X-Raym's script for i times