Old 04-19-2018, 07:59 AM   #1
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default Creating envelope and LFO via Reascript

Hi everyone!

How would you go about automatically creating an envelope for automation for a VST:s plugin (audio effect on an audio track) using Reascript? I've tried a few different functions from the API, but I can't really wrap my head around how to use them in conjuction to create this envelope and assign it to a specific parameter.

Bonus question: Is there any way to also, via Reascript, assign the LFO to said envelope?
Could you point me in the right direction on which functions to use from the API?

Thanks!
IReap is offline   Reply With Quote
Old 04-19-2018, 10:46 AM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

See ReaPack/mpl_Insert 1 measure long automation item for last touched parameter.lua or ReaPack/mpl_Generate track volume automation item from audio take.lua for example. "Creating envelope" is probably action FX: Activate/bypass track envelope for last touched FX parameter

Quote:
Is there any way to also, via Reascript, assign the LFO to said envelope?
You need to dig into Get/SetTrackStateChunk() hell here.
mpl is offline   Reply With Quote
Old 04-20-2018, 04:23 AM   #3
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default

Quote:
Originally Posted by mpl View Post
See ReaPack/mpl_Insert 1 measure long automation item for last touched parameter.lua or ReaPack/mpl_Generate track volume automation item from audio take.lua for example. "Creating envelope" is probably action FX: Activate/bypass track envelope for last touched FX parameter


You need to dig into Get/SetTrackStateChunk() hell here.
Thanks a lot! I've started to dig into your scripts to try to get it work, much appreciated!

Regarding automation and assigning a VST-parameter: Hmm everywhere I turn it seems like it always comes down to the function last touched parameter, is there any workarounds to this? Without requiring clicking/touching the parameter?

Just to give you some context..

My goal is to create a test script that runs without any user input/requirements..

For maintainabilty a template project isn't really a good solution.

It needs to:

1) Load a track.
2) Assign a media item (sine.wav).
3) Load a fx plugin (3rd party) # Seems like there is no way to control which format (VST, AU)? Big issue!
4) Automate some parameters of the plugin through the duration of sine.wav # With random? With lfo? Work in progress
5) Render the processed sine.wav # Work in progress

Pretty simple in other words. As of today I'm at step 4). But I really need to fix the issue on step 3)

I recognize that the API leans more towards hands on use in an actual session, not really for this type of use. At least that's the impression I've got so far.

Thankful for any other tips!

Regards
IReap is offline   Reply With Quote
Old 04-20-2018, 06:17 AM   #4
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default

Oh... It seems this is where I need to start digging to resolve the VST, AU and LFO "problem"?

http://wiki.cockos.com/wiki/index.ph...nk_Definitions

I think I've opened a can of worms with this automated test...

*sigh*
IReap is offline   Reply With Quote
Old 04-23-2018, 06:01 AM   #5
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default

Does anyone else know if it's impossible to access Reapers "FX Parameter List" of a 3rd party plugin without demanding the cursor to touch the actual GUI parameter?

I understand why the API is constructed the way it is, because the end user will use it in realtime to make music/mix. But I would want to access everything without manual input. Is there anyway to remedy this problem without using a mouse driver?

Again thanks for any input!
IReap is offline   Reply With Quote
Old 04-23-2018, 06:10 AM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by IReap View Post
Does anyone else know if it's impossible to access Reapers "FX Parameter List" of a 3rd party plugi
TrackFX_GetNumParams, TrackFX_GetParamName...?

If you are asking about being able to reuse the actual FX parameters window, no I don't think that is possible from ReaScript or the extension API. If you need a similar GUI, you will need to create that from scratch yourself.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 04-23-2018 at 11:00 AM.
Xenakios is offline   Reply With Quote
Old 04-24-2018, 04:30 AM   #7
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default

Quote:
Originally Posted by Xenakios View Post
TrackFX_GetNumParams, TrackFX_GetParamName...?

If you are asking about being able to reuse the actual FX parameters window, no I don't think that is possible from ReaScript or the extension API. If you need a similar GUI, you will need to create that from scratch yourself.
Got it to work thanks to your hint, could not see the forest for the trees-scenario. Do you know if it's possible to access the "Parameter modulation/link" window? Next step is that I want to assign a LFO to the different parameters. MPL hinted that I need to delve into statechunks, but I don't know where to start.

Again thanks for any input!
IReap is offline   Reply With Quote
Old 04-24-2018, 06:24 AM   #8
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by IReap View Post
MPL hinted that I need to delve into statechunks, but I don't know where to start.
Yeah, I think you will need to use the text state chunks. I try to avoid doing anything with those as much as possible, so I don't know what you should do to get the parameter modulations assigned.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 04-24-2018, 08:34 AM   #9
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Quote:
Originally Posted by IReap View Post
don't know where to start
Rough lua code for Set/Replace LFO for last touched FX parameter
Code:
param_chunk =
[[
PARAMBASE 0
LFO 1
LFOWT 1 1
LFOSHAPE 0
LFOSYNC 0 0 0
LFOSPEED 0.124573 0    
]]
  
  st = 'Set LFO for last touched FX parameter'
  for key in pairs(reaper) do _G[key]=reaper[key]  end  
  ----------------------------------------------------
  function msg(s) ShowConsoleMsg(s..'\n') end
  ----------------------------------------------------
  function MPL_SetLFO(tr,  fxnumber, paramnumber, insert_ch)
    local data = {}
    if not tr then return end
    local fx_guid =  TrackFX_GetFXGUID( tr, fxnumber):gsub('[{}-]','')
    -- chunk stuff
      local _, chunk = GetTrackStateChunk(  tr, '', false )
      local t= {} for line in chunk:gmatch('[^\n\r]+') do t[#t+1] = line end
      for i = 1, #t do 
        if t[i]:match('FXID') and t[i]:gsub('[{}-]','') and t[i]:gsub('[{}-]',''):match(fx_guid) then search_PM = true search_PM_id = i end
        if search_PM and (t[i]:match('<PROGRAMENV '..paramnumber) or t[i]:match('<PARMENV') )then erase_chunk = true end
        if erase_chunk and t[i]:find('>') then 
          erase_chunk = false 
          t[i] = ''
        end
        if erase_chunk then
          t[i] = ''
        end
      end
      if search_PM_id and t[search_PM_id+1] then t[search_PM_id] = t[search_PM_id]..'\n'..insert_ch end
    SetTrackStateChunk(  tr, table.concat(t, '\n'), true )
    --msg(table.concat(t, '\n'))    
  end
  ----------------------------------------------------------------
  
  local retval, tracknumber, fxnumber, paramnumber = GetLastTouchedFX()
  if retval then
    local insert_chunk = '<PROGRAMENV '..paramnumber..'\n'..param_chunk..'\n>'
    local tr =  CSurf_TrackFromID( tracknumber, false )
    Undo_BeginBlock()
    MPL_SetLFO(tr, fxnumber, paramnumber, insert_chunk)       
    Undo_EndBlock(st, 1)
  end
Can/should be optimized in some cases probably (I guess SWS chunk parser is currently the only way to build something stable around stuff like that), use at your own risk.

Last edited by mpl; 04-24-2018 at 08:42 AM.
mpl is offline   Reply With Quote
Old 04-26-2018, 05:23 AM   #10
IReap
Human being with feelings
 
Join Date: Apr 2018
Posts: 13
Default

Quote:
Originally Posted by mpl View Post
Rough lua code for Set/Replace LFO for last touched FX parameter

Code...

Can/should be optimized in some cases probably (I guess SWS chunk parser is currently the only way to build something stable around stuff like that), use at your own risk.
Wow! Bal'shoye spaseeba, it worked fine. It's a bit over my head right now but I'll delve into understanding the code blocks. Could you possibly elaborate/comment through the blocks? When/if you have time of course! There have been two(!) updates the last couple of weeks (today being the latest) and I was really hoping for my issue of not being able to address loading different format via Reascript (AU, VST) and having access to the lfo via the API.

The struggle!

Sigh
IReap 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 11:26 AM.


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