Old 11-06-2018, 08:33 PM   #1
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 13,616
Default possible or not with scripts?

two things, little things but so are crabs and splinters, ... that have bothered me a long time and the DEV's seem blind and deaf to them so I dare to ask if scripting can deal with them:

1-in the FX Browser, when you add many of your own folder and want to move them up or down, the only way is endless move up or down menus clk's.... OK but how about a hot key to do it... one for up one for down...

Possible or no?

2- the other is in FX list window, when you select one FX and want to save it as a chain... [Save selected FX as chain]... again there is no key command to do it...
seems like a little thing but imagine you have a lot of FX there and want to save individual ones as 'chains' because of how we handle chains... [rename, sort into folders, etc]

OK thanks for any thoughts
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 11-06-2018, 09:41 PM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 521
Default

1. So it is actually about moving the folders in the FX-dialog or about scrolling through it?
Coding scrolling should be possible using Julian Sader's new extension-plugin, but moving the folders around is an entirely other thing.
It's probably better to ask the devs to finally add a new "FX-Chain"-section to the actionlist, rather than coding it with ReaScript.

2. It would require to actually get, in which Track_FX you are(which should be possible, I think) and getting, which FX are selected. And after that, saving it as an FX-chain-file.
But it would be needed to reimplement this X-chain-generation, as you can't use the code Reaper provides on his own.
I reverse-engineered the fileformat for RFXchain-files, but if someone is willing to reimplement that, dunno.

https://mespotin.uber.space/Mespotin....html#RfxChain
__________________
Reaper Fun Fact of the week: Font in the IDE is too small?
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.
mespotine is offline   Reply With Quote
Old 11-06-2018, 10:18 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,139
Default

Quote:
OK but how about a hot key to do it... one for up one for down...
Possible or no?
Even if you somehow parse and return back your changed reaper-fxfolders.ini, there is no way to refresh it on the fly and Reaper will overwrite it on exit.

Quote:
[Save selected FX as chain]... again there is no key command to do it
There is no "selected" definition in Reaper API for FX, so not possible.
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 11-07-2018, 12:00 AM   #4
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 13,616
Default

thanks mpl.... that is what I was afraid the answer would be

maybe some day the dev's will get it done
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 11-07-2018, 12:17 AM   #5
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by hopi View Post
thanks mpl.... that is what I was afraid the answer would be

maybe some day the dev's will get it done
yep, loading chain wasn't too hard to do in one my script, but saving fxchain is a completely different story, it doesn't worth the trouble.

@mespotine, i noticed, that your doc lacks JS_PINMAP section, it's between JS and JS_SER.

Last edited by doppelganger; 11-07-2018 at 12:38 AM.
doppelganger is offline   Reply With Quote
Old 11-07-2018, 04:39 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,177
Default

For 1. maybe this?
https://forum.cockos.com/showthread.php?t=170880 (not used myself)
nofish is offline   Reply With Quote
Old 11-07-2018, 06:55 PM   #7
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 13,616
Default

thanks nofish... it would be helpful if that app would actually work for me but for unknown reasons it does not... I've posted to the dev but no response as yet
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 11-08-2018, 01:06 AM   #8
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,152
Default

Quote:
Originally Posted by hopi View Post
2- the other is in FX list window, when you select one FX and want to save it as a chain... [Save selected FX as chain]... again there is no key command to do it...
seems like a little thing but imagine you have a lot of FX there and want to save individual ones as 'chains' because of how we handle chains... [rename, sort into folders, etc]

OK thanks for any thoughts
Any menu command can be simulated by sending a WM_COMMAND message to the window. In the case of "Save selected FX as chain" (and assuming that you are currently working in the FX List window, so it is in the foreground):
Code:
w = reaper.JS_Window_GetForeground()
if w and reaper.JS_Window_GetTitle(w, ""):match("FX: ") then
    reaper.JS_WindowMessage_Post(w, "WM_COMMAND", 0x09DCB, 0, 0, 0) 
end
Depending on settings such as "Ignore FX chain keyboard shortcuts (send to the main window)" in the FX window (which I am not overly familiar with), keyboard shortcuts will be passed through to the Main context, so you can add this little script and its shortcut to the Main context.

Last edited by juliansader; 11-08-2018 at 01:14 AM.
juliansader is online now   Reply With Quote
Old 11-08-2018, 03:47 AM   #9
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by juliansader View Post
Any menu command can be simulated by sending a WM_COMMAND message to the window. In the case of "Save selected FX as chain" (and assuming that you are currently working in the FX List window, so it is in the foreground):
Code:
w = reaper.JS_Window_GetForeground()
if w and reaper.JS_Window_GetTitle(w, ""):match("FX: ") then
    reaper.JS_WindowMessage_Post(w, "WM_COMMAND", 0x09DCB, 0, 0, 0) 
end
Depending on settings such as "Ignore FX chain keyboard shortcuts (send to the main window)" in the FX window (which I am not overly familiar with), keyboard shortcuts will be passed through to the Main context, so you can add this little script and its shortcut to the Main context.
Wow, it works! Magic
doppelganger is offline   Reply With Quote
Old 11-08-2018, 05:34 AM   #10
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,289
Default

Quote:
Originally Posted by juliansader View Post
Any menu command can be simulated by sending a WM_COMMAND message to the window. In the case of "Save selected FX as chain" (and assuming that you are currently working in the FX List window, so it is in the foreground):
Code:
w = reaper.JS_Window_GetForeground()
if w and reaper.JS_Window_GetTitle(w, ""):match("FX: ") then
    reaper.JS_WindowMessage_Post(w, "WM_COMMAND", 0x09DCB, 0, 0, 0) 
end
Depending on settings such as "Ignore FX chain keyboard shortcuts (send to the main window)" in the FX window (which I am not overly familiar with), keyboard shortcuts will be passed through to the Main context, so you can add this little script and its shortcut to the Main context.

How did you come up with 0x09DCB as the Menu identifier (IDM_*)?

The Spy++ Logger logs this when choosing "Save all FX as chain.."
Code:
<000001> 00110374 S WM_COMMAND wNotifyCode:0 (sent from a menu) wID:40137
<000002> 001704C8 S WM_COMMAND wNotifyCode:EN_SETFOCUS wID:1001 hwndCtl:000F0580
<000003> 0010044A S WM_COMMAND wNotifyCode:CBN_SETFOCUS wID:0 hwndCtl:001704C8
<000004> 0010044A R WM_COMMAND
<000005> 001704C8 R WM_COMMAND
<000006> 0010044A S WM_COMMAND wNotifyCode:CBN_SELENDCANCEL wID:0 hwndCtl:001704C8
<000007> 0010044A R WM_COMMAND
<000008> 0010044A S WM_COMMAND wNotifyCode:CBN_KILLFOCUS wID:0 hwndCtl:001704C8
<000009> 0010044A R WM_COMMAND
0x09DCB is 40395 in decimal, but such an action does not exist..


I am an idiot! :S .. Ok, return value for "save selected FX as chain" is 40395

Last edited by amagalma; 11-08-2018 at 06:23 AM.
amagalma is offline   Reply With Quote
Old 11-08-2018, 06:58 AM   #11
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,152
Default

Quote:
Originally Posted by amagalma View Post
How did you come up with 0x09DCB as the Menu identifier (IDM_*)?
I'm not sure why your Spy++ is reporting all these other commands. Perhaps check that it only logs the "FX: Track something" window, not all system windows?

If you set Spy++ to show "Raw Message Parameters", it will also report the wParam and lParam that the script must use when posting the message.

Alternatively, anyone that doesn't have Visual Studio and Spy++ can use this script to check the WM_COMMAND in REAPER's IDE:
Code:
-- Change this to however you prefer to select the window
w = reaper.JS_Window_FromPoint(reaper.GetMousePosition()) --Find("FX: Track 1", true)

t = {}
function loop()
    pOK, pass, time, wLow, wHigh, lLow, lHigh = reaper.JS_WindowMessage_Peek(w, "WM_COMMAND")
    if time ~= prevTime then
        prevTime = time
        t[#t+1] = {time = time, wLow = wLow, wHigh = wHigh, lLow = lLow, lHigh = lHigh}
    end
    reaper.defer(loop)
end

reaper.atexit(reaper.JS_WindowMessage_ReleaseWindow(w))

if w then 
    title = reaper.JS_Window_GetTitle(w, "")
    reaper.JS_WindowMessage_ReleaseWindow(w)
    iOK = reaper.JS_WindowMessage_Intercept(w, "WM_COMMAND", true)
    loop() 
end
(I checked in Linux, Windows x64 and x32, and they all seem to use the same number for the menu command, so I think it is safe to use.)
juliansader is online now   Reply With Quote
Old 11-08-2018, 07:44 AM   #12
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,289
Default

I was checking all windows. I followed your advice and now Spy++ gives me what I want!
Code:
<000001> 003502EC S WM_COMMAND wNotifyCode:0 (sent from a menu) wID:40395 [wParam:00009DCB lParam:00000000]

One more thing demystified! Thank you!


P.S. Could you check your private messages please? I have another question there. Thanks!
amagalma is offline   Reply With Quote
Old 11-08-2018, 11:15 AM   #13
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 521
Default

Quote:
Originally Posted by doppelganger View Post
@mespotine, i noticed, that your doc lacks JS_PINMAP section, it's between JS and JS_SER.
In which doc? I have made too many
__________________
Reaper Fun Fact of the week: Font in the IDE is too small?
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.
mespotine is offline   Reply With Quote
Old 11-08-2018, 01:18 PM   #14
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by mespotine View Post
In which doc? I have made too many
we were talking about RfxChain, some JS plugins have one more section: <JS_PINMAP..>
PARMLEARN is missing too, but i guess you're aware of that, saw your note in the beginning.
doppelganger is offline   Reply With Quote
Old 11-08-2018, 08:39 PM   #15
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 13,616
Default

Quote:
Originally Posted by juliansader View Post
Any menu command can be simulated by sending a WM_COMMAND message to the window. In the case of "Save selected FX as chain" (and assuming that you are currently working in the FX List window, so it is in the foreground):
Code:
w = reaper.JS_Window_GetForeground()
if w and reaper.JS_Window_GetTitle(w, ""):match("FX: ") then
    reaper.JS_WindowMessage_Post(w, "WM_COMMAND", 0x09DCB, 0, 0, 0) 
end
Depending on settings such as "Ignore FX chain keyboard shortcuts (send to the main window)" in the FX window (which I am not overly familiar with), keyboard shortcuts will be passed through to the Main context, so you can add this little script and its shortcut to the Main context.
julian [my hero] thanks so much and from what you say that should do one of my wishes....

but is that code a lua script or something else?

EDIT: so I copied that code and saved it as a .lua named, JS_Save Selected FX as Chain.lua, and added it to the actions, with a key command to run it
I have the FX List window open for a track and one FX selected so the window is the forefront window... and then I
run the script via the hot keys but get this:

JS_Save Selected FX as Chain.lua:1: attempt to call a nil value (field 'JS_Window_GetForeground')

EDIT 2:
really weird ... when using the quote from JS original post... where he has a w as the start of the code line, we get a v... look at my quote copy and compare with the original and compare with other quotes above...

but no matter... tried the code with the w and also with changed to v and still get the same error
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain

Last edited by hopi; 11-08-2018 at 11:52 PM.
hopi is offline   Reply With Quote
Old 11-09-2018, 12:39 AM   #16
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

@hopi, you need to install js_ReaScriptAPI extension:
https://forum.cockos.com/showthread.php?t=212174
doppelganger is offline   Reply With Quote
Old 11-09-2018, 05:24 AM   #17
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 521
Default

Quote:
Originally Posted by doppelganger View Post
we were talking about RfxChain, some JS plugins have one more section: <JS_PINMAP..>
PARMLEARN is missing too, but i guess you're aware of that, saw your note in the beginning.
Thanx, I will look into it. Can you tell me, how to trigger these two entries (I suppose, they are in the track/itemstatechunks as well at runtime)? Then I could document it properly...

And yes, there's still a lot of it missing. The only doc on that page really finished is the one for the reaper-kb.ini. The other fileformats are definately missing stuff.
__________________
Reaper Fun Fact of the week: Font in the IDE is too small?
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.
mespotine is offline   Reply With Quote
Old 11-09-2018, 10:12 AM   #18
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 312
Default

Quote:
Originally Posted by mespotine View Post
Thanx, I will look into it. Can you tell me, how to trigger these two entries (I suppose, they are in the track/itemstatechunks as well at runtime)? Then I could document it properly...

And yes, there's still a lot of it missing. The only doc on that page really finished is the one for the reaper-kb.ini. The other fileformats are definately missing stuff.

Reaper Fun Fact of the week: Font in the IDE is too small?
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.

JS_PINMAP shows up, when you modify pins of plugin, re-assign, add new channels, etc.

PARMLEARN shows up, when you learn some fx parameters to midi controller, there can be more than 1 such line, they are situated before PARM_TCP. (not sure, but i think this parameter can be triggered by OSC learn too)

Both are present in track's fxchain chunk, item(take)'s fx chunk and rfxchain file AFAICT.

Fun Fact of the week extended: Font in the IDE can be changed via ctrl+scroll too, hehe
doppelganger is offline   Reply With Quote
Old 11-09-2018, 11:44 AM   #19
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,405
Default

Quote:
Originally Posted by doppelganger View Post
PARMLEARN is missing too, but i guess you're aware of that, saw your note in the beginning.
For me the most important parameter, unfortunately too few lua scripts adding extra functionality for handling those. Luckily there is ReaLearn for some time, which can copy paste in text form to/from clipboard. ReaLearn kind of solved many if not all PARMLEARN related topics.

Is it possible to start e.g. notepad.exe from a lua script?

Last edited by TonE; 11-09-2018 at 11:49 AM.
TonE is offline   Reply With Quote
Old 11-09-2018, 11:56 AM   #20
Arthur McArthur
Human being with feelings
 
Join Date: Sep 2016
Location: Toronto
Posts: 409
Default

Quote:
Originally Posted by TonE View Post
Is it possible to start e.g. notepad.exe from a lua script?
Yes Lokasenna made: Script: Lokasenna_Create action to open a file... .lua

I prefer python for this as it doesn't pop up the (slightly distracting) command windows :

import subprocess
subprocess.Popen(['C:\\Users\\Owner\\Documents\\AutoHotkey Scripts\\REAPER\\MIDI Editor Hide show.exe'])
Arthur McArthur is offline   Reply With Quote
Old 11-09-2018, 12:32 PM   #21
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,405
Default

Thanks Arthur. Cool you are ahk user as well, exactly that would be one use case scenario. The python variant looks simpler however. Wow now we have 3 solutions.
1- lua
2- python
3- adding as external editor (what I was using currently)


PHP Code:
--[[
DescriptionCreate action to open a file...
Version1.2.1
Author
Lokasenna
Donation
https://paypal.me/Lokasenna
Changelog:
    
Name change for consistency
Links
:
    
Forum Thread http://forum.cockos.com/showthread.php?t=189152
    
Lokasenna's Website http://forum.cockos.com/member.php?u=10417
About
    Automates the creation of ReaScripts that will open files or folders
    in their native app. Handy for shortcuts to plugin manuals, or commonly
    used folders, etc.
    
    Note: Due to Reaper limitations, creating a shortcut to a folder equires you
          to select a file IN that folder, and then manually erase the filename
          from the path. Sorry. :/
--]]

-- Licensed under the GNU GPL v3

local ret, path, csv, alias

reaper.ShowMessageBox("To create an action that opens a folder:\n\n1. Use the next window to select a file in that folder.\n2. Click '
OK'.\n3. Another window will pop up; manually erase the filename there.\n\nThis is a Reaper limitation - sorry for the inconvenience.", "Create action to open a file...", 0)

ret, path = reaper.GetUserFileNameForRead("", "Select a file", "")
if not ret then return 0 end

-- Cheers to @mpl for this.
local num = path:reverse():find('
[%/%\\]')
local alias = path:sub(-num + 1) .. " "
    --reduced_name = reduced_name:sub(0,-1-reduced_name:reverse():find('
%.')) -- cut extension also


ret, csv = reaper.GetUserInputs("Create action to open a file... ", 2, "File/folder path:,File alias:,extrawidth=128", path..","..alias)
if not ret or csv == "" then return 0 end

path, alias = string.match(csv, "([^,]+),([^,]*)")
if not path then return 0 end

local str =        "-- Created with Lokasenna_Create action to open a file... .lua\n"

        ..        [[os.execute( ( string.match( reaper.GetOS(), "Win") and ('
start "" "') or ('open "" "') ) .. "]]     
        ..        path 
        ..         '" )'
str = string.gsub(str, [[\]], [[\\]])

local info = debug.getinfo(1,'S');
local script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]
local file_name = script_path .. "
Open a file " .. alias .. ".lua"

local file, err = io.open( file_name , "
w+")
if not file then
    reaper.ShowMessageBox("
Couldn't create file:\n" .. file_name .. "\n\nError: " .. tostring(err), "Whoops", 0)
    return 0
end

file:write(str)

reaper.ShowMessageBox( "Successfully created file:\n" 
                    .. ( string.len(file_name) > 64 and ( "..." .. string.sub(file_name, -56) ) 
                                                    or     file_name), 
                        "Yay!", 0)

io.close(file)

reaper.AddRemoveReaScript( true, 0, file_name, true ) 
TonE is offline   Reply With Quote
Old 11-09-2018, 12:37 PM   #22
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,405
Default

Just for the interested this opens up, editing capabilities of reaper, be it of midi items or audio items, to any external processors. Those could be implemented in java or c, no matter what. Now somewhere we should create a list of useful command line midi/audio processors, as if the options inside Reaper were not enough. But yes, in some areas, Reaper is toooo far behind what is already available from science world. I am sure you want an example, here we go:
https://mir.sechsachtel.de/midi/

Quote:
MIDI Optimizer is a program for converting performance-based MIDI files into semantically enriched score-like MIDI files. It determines the musical beat grid from a given performance MIDI file and uses this information to map all MIDI events to a musically meaningful time axis without changing their absolute time positions in seconds. Hence the output of this program can be used as an input for existing MIDI quantization software like music notation programs.
And Reaper has notation.

Last edited by TonE; 11-09-2018 at 12:42 PM.
TonE is offline   Reply With Quote
Old 11-09-2018, 12:37 PM   #23
Arthur McArthur
Human being with feelings
 
Join Date: Sep 2016
Location: Toronto
Posts: 409
Default

Yes, AHK has been a big help. Although with Julian Sader's incredible new extension, it seems like there's much less need for it.
Arthur McArthur is offline   Reply With Quote
Old 11-09-2018, 12:43 PM   #24
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,405
Default

Depends on for what you were using ahk.
TonE is offline   Reply With Quote
Old 11-13-2018, 09:02 AM   #25
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 521
Default

Quote:
Originally Posted by doppelganger View Post
Fun Fact of the week extended: Font in the IDE can be changed via ctrl+scroll too, hehe
Holy Shit, I didn't knew that! Thank you very much for that. I always hated having to change that by hand
__________________
Reaper Fun Fact of the week: Font in the IDE is too small?
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.
mespotine is offline   Reply With Quote
Old 11-14-2018, 07:39 PM   #26
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 13,616
Default

Hi Jack... how ya doin'?

thanks to Julian this is now working nicely for me...

Quote:
Perhaps the keyboard shortcut isn't passed through to the main window?

In the FX window, enable Options -> Ignore FX chain shortcuts (send to main window). If the script now runs after enabling that option, it means that the FX window was intercepting the shortcut.
He told me to do that now it works great...

Thanks so much Julian
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.