Old 07-22-2018, 07:52 PM   #1
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default ReaScript/Python RPR_TrackFX_GetParam

Hello,

I just have a couple of questions regarding RPR_TrackFX_GetParam in Python (2.7 as it was what was autdetected):

1- What does minvalOut and maxvalOut do? They seem to have no effect...

2- Is there any way to have the return value translated automagically to an integer from 0-127? I can't make sense of the return results - different min/max in the plugin = different min/max from the function). If there's no built-in way, I'd have to only hope I can glean the parameters min and max values, then try to brute-force some sort of formula(s)...

What I'm ultimately trying to do, is achieve midi feedback to my BCR2000 and I'm really close, other than translating these parameter values to it. Figured out the core components:
- How to send midi to the BCR
- How to get a mapped param value from a plugin
- How to do that continuously after the script is fired

If I can figure out a sane way to translate FX parameter values to midi values (0-127) then I'm on the home stretch...
experimentfailed is offline   Reply With Quote
Old 07-22-2018, 08:14 PM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

- They give you whatever the plugin is reporting as that parameter's min and max. A lot seem to just be 0-1, in my experience.

- Every plugin and parameter is different, potentially. I spent a couple of hours (I was new at the time) writing a script just to figure out what 1 cent equals in ReaSamplomatic's Pitch Offset.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-22-2018, 08:32 PM   #3
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

I'm not sure what you mean on your first point.

the second does not sound encouraging...
experimentfailed is offline   Reply With Quote
Old 07-22-2018, 08:35 PM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

The values returned for min and max are dependent on the plugin.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-23-2018, 08:21 AM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,107
Default

Sounds like maybe you need a 'mapping values' function ?
I picked this up somewhere (forgot where exactly*):

Code:
return ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
It's not Python but I assume it should be straightforward to adapt ?
x in this case would be your current plugin value, out_min: 0, out_max: 127, in_min: minvalOut, in_max: maxvalOut.

*probably here:
https://www.arduino.cc/reference/en/...ions/math/map/

edit:
Regarding MIDI feedback, I also have a BCR2000 and for getting feedback for learned paramaters I use ReaLearn which has a parameter feedback option and works nicely for me. So maybe no need to reinvent the wheel...

https://www.helgoboss.org/projects/realearn/
https://forum.cockos.com/showthread.php?t=178015

Last edited by nofish; 07-23-2018 at 11:38 AM.
nofish is offline   Reply With Quote
Old 07-23-2018, 12:02 PM   #6
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

Yes that appears it will be easy to adapt to Python (if not drop in as-is). I was just trying to muddle through a similar function from scratch, but was struggling, so thank you!

As for ReaLearn, I looked at it before starting this - there is no Linux build yet and it appears to be closed source. For now, I am intentionally opting out of using Windows plugins in my environment (though it is apparently possible). Besides, I always wanted to learn ReaScript - just couldn't think of any reason to until now

I think I'll like my solution more, anyway, as it will allow building my maps via one FXChain save file. Then, any time the script sees a selected plugin defined therein, I get feedback to my BCR - never having to add an additional plugin, nor does the FXChain have to be loaded (only have to load it to edit the map). Therefore, the map follows each plugin across tracks and projects with no additional steps other than firing the script at REAPER startup (which I read somewhere there is also a way to do that...maybe with SWS, I don't recall).
experimentfailed is offline   Reply With Quote
Old 07-24-2018, 05:33 AM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,107
Default

This sounds like an interesting approach to the 'getting MIDI feedback' quest.
Are you planning to share it when done ?
nofish is offline   Reply With Quote
Old 07-24-2018, 07:00 AM   #8
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

Yes, it will be open source. However, I ran into another issue last night that may not have such an easy solution, which is FX names in REAPER/ReaScript (at least as returned by RPR_TrackFX_GetFXName) are different from those saved in FXChain save files...So I will have to find a way to get the "correct" name or another way to associate FX saved in the file with FX in a project

Last edited by experimentfailed; 07-24-2018 at 07:16 AM.
experimentfailed is offline   Reply With Quote
Old 07-24-2018, 08:25 AM   #9
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Are you just using the FXChain for convenience? If it's awkward, you could instead have a script save the information you need to a text file with whatever formatting you want.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-24-2018, 09:49 AM   #10
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

The goal is to have some way to use REAPER's Learned mapping in a way that can be saved/restored easily and also shared with the script. Every idea I am coming up with though, seems to be flawed. Even if the plugins were named the same in FX chain files, they are limited in that I need the mappings to follow the plugin ALWAYS - not just when loaded by an FX chain (plus, I mix and match plugins a lot which FX chains also limit).

It's almost like I'll have to put my script between REAPER and the hardware controller (I mean that's essentially what I'm doing, but only limiting to output right now - I'd have to also handle input from the controller with the script), which I think is doable but might be too slow. I don't think RPR_defer("main()") is run very often (which would be on top of how long the script takes to do it's job each time). I haven't benchmarked it, but visually looks like it's only run every few millisecond or so. That wouldn't be very good for making fine/fluid adjustments.

I don't think saving to a file would work, because I still need some way to apply the mappings to the plugins in REAPER when they are loaded =/

Thanks!

Last edited by experimentfailed; 07-24-2018 at 10:05 AM.
experimentfailed is offline   Reply With Quote
Old 07-24-2018, 10:30 AM   #11
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,107
Default

Just an idea, maybe referring to GUID's (Global Unique Identifiers) may help to associate FX saved in the file with FX in a project.

You can get the GUID's for track / take FX
https://www.extremraym.com/cloud/rea...ckFX_GetFXGUID
https://www.extremraym.com/cloud/rea...keFX_GetFXGUID

also

https://www.extremraym.com/cloud/rea.../#guidToString

and they are also stored in the project file for the FX.

nofish is offline   Reply With Quote
Old 07-24-2018, 10:59 AM   #12
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

Brilliant, thank you! That should at least give me a way forward, though still I don't like that I'm limited to FX chains.

If only there was a way to feed mappings into REAPER...Again, ideally in such a way that any time a given plugin is added, a default mapping is applied.

Does anybody know what State Chunks are? E.g. https://www.reaper.fm/sdk/reascript/...rackStateChunk

I'll see what they contain later when I get home...

EDIT: This might be my answer: https://github.com/ReaTeam/Doc/blob/...%20Definitions - I don't see where midi learn settings are in there, but they are in FX chains and that definition shows an FX chain section....if they are in the state chunk and I can set the state chunk (see previous link), then it's a little convoluted but might work...

For completeness, here's another bit of code that might help me suss this out: https://github.com/MichaelPilyavskiy...X%20chains.lua

Last edited by experimentfailed; 07-24-2018 at 11:16 AM.
experimentfailed is offline   Reply With Quote
Old 07-24-2018, 03:38 PM   #13
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

Ok, I've confirmed that I can indeed get the PARMLEARN data out of the track chunk. I have some things to do tonight but when I get home again, I'll see if i can set those from the script (and based on the fact that there is a setter function and I've seen it discussed/used before, I have very high hopes). If it pans out, I will officially have all the pieces and will just need to put them all together

EDIT: After realizing I could just access the PARMLEARN settings directly from the selected track, I then realized I no longer have to worry about FX chain files or FXIDs/names. This will allow way more flexibility and make the whole script way more general-purpose. I don't even have to worry about writing back to the chunk. My only concern will be performance, parsing the chunk every time RPR_defer() is fired. I'm not so worried about delays in updating the controller, as much as my script bottle-necking REAPER, so hopefully it'll either be way fast enough OR I can put an additional timer on it to fire it less often. I could even add an "i'll never use the mouse" mode, so it only has to care when the FX selection changes...

Last edited by experimentfailed; 07-24-2018 at 08:02 PM.
experimentfailed is offline   Reply With Quote
Old 07-25-2018, 06:14 PM   #14
experimentfailed
Human being with feelings
 
Join Date: Jan 2012
Location: USA/Michigan
Posts: 93
Default

Here it is (well, first working prototype at least, at the time of this writing / GPLv3 as promised):

https://forums.cockos.com/showthread...72#post2015772
https://bitbucket.org/experimentfail...ck/src/master/

Last edited by experimentfailed; 07-25-2018 at 08:30 PM.
experimentfailed 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 10:37 PM.


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