Old 06-14-2016, 08:06 AM   #1
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default Lua: Save VST Preset to preset.ini file

Save preset for last touched VST or JS.
The script saves the FX current state as a preset with a new name to a fx-preset.ini file
====


====
Save_FX_Preset
__________________
ReaScripts

Last edited by eugen2777; 06-24-2016 at 03:59 PM. Reason: Update
eugen2777 is offline   Reply With Quote
Old 06-14-2016, 10:45 AM   #2
Pet
Human being with feelings
 
Pet's Avatar
 
Join Date: Nov 2015
Location: Germany
Posts: 1,015
Default

eugen, you're so cool!! Thanks
__________________
If the v5 Default Theme is too bright for you take a gander at my mod of it: Default v5 Dark Theme
Pet is offline   Reply With Quote
Old 06-15-2016, 04:22 PM   #3
Spacemen Tree
Human being with feelings
 
Spacemen Tree's Avatar
 
Join Date: Mar 2013
Posts: 515
Default

This is great!! I was thinking about trying to write something like this a few weeks ago but no time. My idea was to convert internal VST presets into reaper presets with one click.
Very nice!!!

Thanks eugen.
__________________
"After silence, that which comes nearest to expressing the inexpressible is music", Aldous Huxley
Spacemen Tree is offline   Reply With Quote
Old 06-17-2016, 06:16 PM   #4
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Decoding function is fully updated, now it works 7-8 times faster, very fast.
The rest of the script will be updated later
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 06-24-2016, 07:58 AM   #5
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 271
Default

Some updates.
JSFX support added.
__________________
ReaScripts

Last edited by eugen2777; 06-24-2016 at 04:13 PM.
eugen2777 is offline   Reply With Quote
Old 10-03-2019, 02:30 AM   #6
Perken
Human being with feelings
 
Perken's Avatar
 
Join Date: May 2019
Location: Los Angeles / God forbid…
Posts: 191
Default

Would it be possible to automatically save the preset name to the plugin's original preset name ?

Getting it to work in conjunction with X-Raym's «rename tracks with first VSTi and its preset name» would make templating sooo quick and easy
Perken is offline   Reply With Quote
Old 10-03-2019, 04:54 PM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

I made a mod of this script for saving preset. Not shared publicly yet. PM me if needed.




@eugen2777
I hope you will come back soon !


EDIT: link of my mod is here : https://gist.github.com/X-Raym/448e8...b520ca12ddc698

Last edited by X-Raym; 01-04-2021 at 04:33 PM.
X-Raym is offline   Reply With Quote
Old 10-04-2019, 04:23 AM   #8
HoJo
Human being with feelings
 
Join Date: Dec 2007
Location: Germany
Posts: 253
Default

X-Raym,

yes I would be interested as well!

BR,
HoJo

PS: Sending you a PM
HoJo is offline   Reply With Quote
Old 10-09-2019, 03:49 AM   #9
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 305
Default

I'm sorry but while I've been dreeming of a native ABC snapshots and see at this script I've got a idea:
Will it be hard to create to one save patches only in current project folder or do new project folder in presets at lest?
Ivannn Bennnettt is offline   Reply With Quote
Old 10-09-2019, 04:39 AM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Ivann
There is no presets folder management (as far as I know) and all presets are stored in the same file (one per FX). the best you can is Prefix your presets I guess.
X-Raym is offline   Reply With Quote
Old 10-10-2019, 02:12 AM   #11
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 305
Default

Quote:
Originally Posted by X-Raym View Post
@Ivann
There is no presets folder management (as far as I know) and all presets are stored in the same file (one per FX). the best you can is Prefix your presets I guess.
Yeah, a prefix with a project name would be not so bad I suppose.
How can I do that?
Ivannn Bennnettt is offline   Reply With Quote
Old 10-10-2019, 02:34 AM   #12
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Custom mod is the only way :P
X-Raym is offline   Reply With Quote
Old 12-02-2020, 12:08 PM   #13
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

I am trying to run the x-raym version of this script, and I'm getting:

Save_VST_Preset_Action.lua:83: attempt to index a nil value (local 'Preset_Chunk')

I have an fx window open... when the function is called, I'm printing to the console, and get this:

fxnum = 0,name = Lead Bass

So it's finding the effect and preset.

Thoughts?

I can post the code here, if x-raym doesn't mind, but since he didn't originally, I'm checking in case there was a reason...


Edit: enabling this message:
reaper.ShowConsoleMsg("\n\n"..fxnum.."\n"..FX_Chun k.."\n")

it prints:
<VST "VSTi: Reaktor 6 (Native Instruments GmbH) (2->


doesn't seem like the full chunk??
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 12-03-2020, 04:38 AM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@woodslanding
Pretty sure the ">" character in the VST names breaks the parsing on this VST chunk.


Code:
VST: Reaktor5 (x86) (Native Instruments GmbH) (2->8ch)

You can either fine tune the pattern matching, or make a more complex way to parse FX chink (using line per line method).


Another temp fix would be to just made a search and replace of this particular FX name, then do the parsing, then restore it back to its initial name.
X-Raym is offline   Reply With Quote
Old 12-06-2020, 11:42 AM   #15
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

I guess I have to ask: can anybody explain how to fine tune this pattern matching? I can't really get my head around how one would know that the '>' doesn't end the chunk....

Printing out the chunk, it looks like the data is not initially plain text, so maybe there is a way to parse out the lines before conversion?

Code:
AAAgAAAAAQAAAAIAAAABAAAAAQAAAAEAAAABAAAApQAAAAAAAACZBQAAAQAAACAAAAABAAAAAgAAAAEAAAABAAAAAQAAAAEAAAAIAQAAAAAAAJoFAAABAAAAIAAAAAEAAAACAAAAAQAAAAEAAAABAAAA

...etc,etc (boring)

AAAAAAD/////AAAAAIeHh8AEAAAAAQAAAAUAAAAAAAAAAQAAAAAA
AAAAAAAAAAAAAAEAAAACAAAAAQ==
AFNob3dkb3duABAAAAA=
>
PRESETNAME Showdown
FLOATPOS 24 28 916 769
FXID {C70F3593-89C3-4FEC-BC9F-109B66DE7732}
WAK 0 0
BYPASS 0 0 0
<JS "ReaTeam JSFX/Utility/mschnell_MIDI Volume Control.jsfx" 
...etc--start of next fx....
I notice the > is on a line by itself. Does anyone know if that's something we can count on??? If so, I guess i could just get lines until a line = '>'. I think I can handle that much pattern matching

I'll see if I can figure that out.... I still would need to get the chunk BEFORE converting it, right?
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 12-06-2020, 11:54 AM   #16
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Okay, so somewhere between these two console printouts, the data changes from gobblety-gook to text, but I can't figure out where... all it is doing is matching things, right?

Code:
  local ret, Track_Chunk =  reaper.GetTrackStateChunk(track,"",false)
  reaper.ShowConsoleMsg(Track_Chunk)  
  --SHOWS:  all the muck from the post above.  
  --Does NOT start with plain text
  --but DOES have '>' on a line by itself at the end of that data

  ------------------------------------
  -- Find FX_Chunk(use fxnum) --------
  ------------------------------------
  local s, e = Track_Chunk:find("<FXCHAIN")            
  -- find VST(or JS) chunk
  for i=1, fxnum+1 do
      s, e = Track_Chunk:find("<%u+%s.->", e)
  end
    local FX_Type = string.match(Track_Chunk:sub(s+1,s+3), "%u+") 
    if not(FX_Type=="VST" or FX_Type=="JS") then return end
    local FX_Chunk = Track_Chunk:match("%b<>", s)
    reaper.ShowConsoleMsg("\n\n"..fxnum.."\n"..FX_Chunk.."\n")  
    --SHOWS: 1 /n <VST "VSTi: Reaktor5 (Native Instruments GmbH) (2->
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 12-07-2020, 11:25 AM   #17
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Okay, I have a feeling Ultraschall has addressed all this in her fxchunk handling stuff. I am going diving into her docs.... I'll keep y'all posted.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 01-04-2021, 04:35 PM   #18
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Not sur if it is still relevant but the mode I made at this time was this one: https://gist.github.com/X-Raym/448e8...b520ca12ddc698


Not tested since months, but maybe it works.


I may put it in reateam repo at some point to make it more public.
X-Raym is offline   Reply With Quote
Old 01-04-2021, 05:07 PM   #19
Thunderfinger
Human being with feelings
 
Join Date: Jun 2020
Posts: 48
Default

Thank you for sharing X-Raym, this will be very useful to me.
Thunderfinger is offline   Reply With Quote
Old 01-05-2021, 02:01 PM   #20
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default Save Preset: Ultraschall version

Okay, here is the lean mean all the work done behind the scenes version of save vst preset. Just the core functionality. Posting it here in case someone else needs it. To reiterate, Eugen's original code failed on parsing a '>' in the reaktor VST name, so I looked for an answer in the ultraschall methods.

This is just the base code, swap out for the Save_VST_Preset method in Xraym's code, if you use reaktor, or have other parsing issues. Also, I'm pretty sure this only works for vsts, so further work would be needed to save jsfx.

EDIT: well, if you have big files, this is extremely slow, so I am looking into that. Also, please note you will need to install the ultraschall api.

cheers,
-e

Code:
--[[  PRESET FILE FORMAT:
    Filename presets/vst-VST_DLL_NAME
        [General]
        NbPresets=N

        [PresetN]
        Data =
        Data_1 =
        Name =
        Len =
    ]]


dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua")

local function get_CtrlSum(HEX)
    local Sum = 0
    for i=1, #HEX, 2 do  Sum = Sum + tonumber( HEX:sub(i,i+1), 16) end
    return string.sub( string.format("%X", Sum), -2, -1 )
end


function WritePreset(trackNum, fxNum, presetName, vstName)
    --get track data
    local found, data = ultraschall.GetTrackStateChunk_Tracknumber(trackNum)
    if not found then MSG('Track chunk not found: ',trackNum, fxNum) end
    data = ultraschall.GetFXStateChunk(data)
    data = ultraschall.GetFXFromFXStateChunk(data, fxNum + 1)  --ultraschall fx are 1-based
    data = ultraschall.GetFXSettingsString_FXLines(data)
    data = ultraschall.Base64_Decoder(data)
    data = ultraschall.ConvertAscii2Hex(data)
    --MSG('data',data)
    --local data = getPresetHex(chanNum, fxNum)
    --prepare for writing file
    local presetFile = reaper.GetResourcePath()..'/presets/vst-'..vstName..'.ini'
    MSG('path = ', presetFile)
    local presetCount, key, section
    if reaper.file_exists(presetFile) then
        ultraschall.GetIniFileValue()
         _, presetCount =  reaper.BR_Win32_GetPrivateProfileString("General", "NbPresets", "", presetFile)
        section = 'Preset'..math.tointeger(presetCount)
    else section, presetCount = 'Preset0', 1
    end
    --Update/write number of presets
    presetCount = math.tointeger(presetCount + 1)
    ultraschall.SetIniFileValue('General', 'NbPresets', presetCount, presetFile)
    local presetLength = #data
    local stringPos = 1
    for i = 1, math.ceil(presetLength/32768) do
        if i == 1 then key = 'Data' else key = 'Data_'..(i - 1) end
        local chunk = data:sub(stringPos, stringPos + 32767)
        local sum = get_CtrlSum(chunk)
        ultraschall.SetIniFileValue(section, key, chunk..sum, presetFile)
        stringPos = stringPos + 32768
    end
    ultraschall.SetIniFileValue(section,'Name', presetName, presetFile)
    ultraschall.SetIniFileValue(section,'Len', presetLength//2, presetFile)
end
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 01-06-2021 at 09:57 AM.
woodslanding is offline   Reply With Quote
Old 01-06-2021, 11:56 AM   #21
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Well, I figured out a way to change the parsing in Eugen's script to work with Reaktor, but with the large reaktor ensemble I am storing presets for (27 blocks of data) Eugen's method seems to be even slower.... I am taking the opportunity to write this while I attempt to save a single preset.

Edit: and coming back to edit it while it's still saving.

So I am feeling the need to find a way to do this without using track chunks. I guess when you use the menu, the script dies at the point it waits for user input for the preset name. Wish there were separate 'save' and 'save as' buttons for the rpl's.

I may look into saving fxbs. I guess they are binary data. Not sure if that would be faster or not.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 01-06-2021, 12:10 PM   #22
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Curiouser and Curiouser.

Reaper writes out this large data file in a fraction of a second, but more importantly, it does not seem to match what's in the track chunk.

Reaper writes out 71 blocks of data (data - data70) but the track chunk only contains 27 of these, according to ultraschall's method. I gave up on Eugen's after 15 minutes. Maybe I'll double-check that his doesn't give a different size result over the lunch hour.

Okay, Eugen's method does save prism snaps in about 15 seconds, so it is working....

Not sure why the ensemble 'photon' requires 35x the data of 'prism'!


But after many hours of messing around, it's looking like I'm back to saving presets manually with the little + button

Any suggestions welcomed!
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 01-06-2021, 12:15 PM   #23
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

SIGH!

Seems that even natively created rpls can't recall the state of a reaktor ensemble correctly.

Note to self: test these things before embarking on a script idea.

Edit: Maybe I did test it... now it is working natively. That at least is a relief, since I discovered that different reaktor ensembles have different fxb formats.
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 01-06-2021 at 12:20 PM.
woodslanding is offline   Reply With Quote
Old 01-06-2021, 08:08 PM   #24
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Alright, so I figured out how to save and load trackFXchunk data to a file without any kind of encoding, which goes quite fast.

Unfortunately, this chunk of data is not enough, despite its substantial size, to reload the reaktor ensemble. It wil load the correct preset to an existing ensemble, but not restore the ensemble.

Native reaper-generated rpls will.

SO bummed.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 03-07-2024, 05:30 AM   #25
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,132
Default

A good use case for the script is saving config of a plugin which failed to load
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file
Buy One is online now   Reply With Quote
Old 03-07-2024, 06:00 AM   #26
Subz
Human being with feelings
 
Subz's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 3,210
Default

Quote:
Originally Posted by Spacemen Tree View Post
This is great!! I was thinking about trying to write something like this a few weeks ago but no time. My idea was to convert internal VST presets into reaper presets with one click.
Very nice!!!

Thanks eugen.

this would be useful
Subz is offline   Reply With Quote
Old 03-07-2024, 09:06 AM   #27
PitchSlap
Human being with feelings
 
PitchSlap's Avatar
 
Join Date: Jan 2008
Location: Vancouver, BC
Posts: 3,792
Default

Really cool!

What I'd love is something like this that would allow you to quickly browse through embedded plugin presets that don't populate Reaper's menu and save them as Reaper presets but the original preset name.

For plugin presets that are individually saved in a folder, it's possible you could point the script to the folder and it would read the file name. This is mostly for when you want to batch re-save them all.

Keyboard shortcut in the plugin for next preset, keyboard shortcut to the script to save a Reaper preset and done almost instantly!

A more complex, but flexible way could be something that works a bit like LICEcap. Determine the co-ordinates for the area of the screen where the plugin displays the preset name, send a screenshot of that area using a Python library with that functionality, then feed into another Python library for high quality OCR like Google's which returns the text of the preset name to the script.
You might even be able to use macro software so the switching/saving of presets is done automatically for the most part.

(I made a simple Python script that converts Reaper presets into Valhalla presets when I wanted to switch to the VST3 version but had years of Reaper presets that wouldn't work otherwise. The opposite direction wouldn't be hard. Eventide presets are easy too because the developers are nice enough to use XML instead of some totally unnecessary binary encoding.)
__________________
FRs: v5 Media Explorer Requests, Global Quantization, Session View
Win10 Pro 64-bit, Reaper 6(x64), AMD 3950x, Aorus X570 Master, 64GB DDR4 3600, PowerColor Red Devil 5700XT, EVO 970 2TB, 10TB HD, Define R6

Last edited by PitchSlap; 03-07-2024 at 09:41 AM.
PitchSlap is offline   Reply With Quote
Old 03-08-2024, 05:40 AM   #28
Codesound
Human being with feelings
 
Codesound's Avatar
 
Join Date: Apr 2017
Posts: 121
Default

Linux Mint 21.3_x64 - Reaper 7.11 - save_fx_preset_1.02
Hi,

THIS SCRIPT is AMAZING! Many THANKS!
I don't understand why it doesn't save tool presets .clap
thanks again....


Last edited by Codesound; 03-08-2024 at 05:48 AM.
Codesound is offline   Reply With Quote
Old 03-08-2024, 06:14 AM   #29
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,132
Default

Quote:
Originally Posted by Codesound View Post
Linux Mint 21.3_x64 - Reaper 7.11 - save_fx_preset_1.02
Hi,

THIS SCRIPT is AMAZING! Many THANKS!
I don't understand why it doesn't save tool presets .clap
thanks again....
The available version only supports VST and JS plugins

Try replacing the line

PHP Code:
if not(FX_Type=="VST" or FX_Type=="JS"then return end         -- Only VST and JS supported 
With this

PHP Code:
if not(FX_Type=="VST" or FX_Type=="JS" or FX_Type=="CLAP" or FX_Type=="LV2" or FX_Type=="AU"
    
then return end         -- VSTJSCLAPLV2AU are supported 
AND PLEASE REPORT BACK

.
.
.
.
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file
Buy One is online now   Reply With Quote
Old 03-08-2024, 08:24 AM   #30
Codesound
Human being with feelings
 
Codesound's Avatar
 
Join Date: Apr 2017
Posts: 121
Default

Hi,
thanks for your interest.... The problem persists.....
I want to say that the script is in
"/home/USER/.config/REAPER/Scripts/X-Raym Scripts/"

thanks again


Codesound is offline   Reply With Quote
Old 03-08-2024, 02:05 PM   #31
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,132
Default

I was able to make the script recognize a CLAP plugin and read CLAP config data but unfortunately the data which was then stored in the preset ini file after conversion from base64 to hexadecimal could not be read back by the plugin. And when i saved the same data using REAPER save preset dialogue the code which was stored was completely different from the one stored by the script.

That's about as far as my knowledge goes. I cannot troubleshoot the base64 to hexadecimal conversion function because i don't understand the data structure. Maybe someone knowledgeable will come along and be able to make it work for CLAP and other architectures.

Sorry.
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file
Buy One is online now   Reply With Quote
Old 03-10-2024, 12:41 AM   #32
Codesound
Human being with feelings
 
Codesound's Avatar
 
Join Date: Apr 2017
Posts: 121
Default

Quote:
Originally Posted by Buy One View Post
I was able to make the script recognize a CLAP plugin and read CLAP config data but unfortunately the data which was then stored in the preset ini file after conversion from base64 to hexadecimal could not be read back by the plugin. And when i saved the same data using REAPER save preset dialogue the code which was stored was completely different from the one stored by the script.

That's about as far as my knowledge goes. I cannot troubleshoot the base64 to hexadecimal conversion function because i don't understand the data structure. Maybe someone knowledgeable will come along and be able to make it work for CLAP and other architectures.

Sorry.
no worry, Thanks for your try!

This script is useful for certain plugins that have somewhat complicated presets saving procedures (see Dexed or Osirus, in which you export the cartdrige)
thanks again. I hope for one update of this script
Codesound 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 06:01 AM.


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