Prev Previous Post   Next Post Next
Old 07-28-2020, 06:10 PM   #1
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 1,201
Default Help needed for Parameter-Modulations in Ultraschall-API

Note: Monitoring-Demo-Script and information about it in posts:
https://forum.cockos.com/showpost.ph...72&postcount=5 and
https://forum.cockos.com/showpost.ph...73&postcount=6




After some time, I finally started working on functions for programming parameter-modulation and I just finished a get function.
Now here's the thing: I never use parameter-modulation. You probably do. So you can help me getting the stuff right.

So, if you code and would like to program ParmModulation, please test the following function, which returns a table with all settings available from a certain Parameter-Modulation. Please test if they work properly, look for nil-error-bugs or for constellations, where the function doesn't return valid values, even though it should according to its documentation.

And have a first look, if the table, as it is, is handy, the names of the table-entries are properly named, etc etc. Any feedback is welcome.
If the get-function works, I can add Add/Set/Count/Delete as well into Ultraschall-API.

IMPORTANT: This is code in progress, so you shouldn't use it in productive code, yet.

See the docs for more information: https://mespotin.uber.space/Ultrasch...tionTable.html

And here's the function to test:
Code:
function ultraschall.GetParmModulationTable(FXStateChunk, index)
  if ultraschall.type(FXStateChunk)~="string" then ultraschall.AddErrorMessage("GetParmModulationTable", "FXStateChunk", "must be a string", -1) return nil end
  if ultraschall.IsValidFXStateChunk(FXStateChunk)==false then ultraschall.AddErrorMessage("GetParmModulationTable", "FXStateChunk", "must be a valid FXStateChunk", -2) return nil end
  if ultraschall.type(index)~="number: integer" then ultraschall.AddErrorMessage("GetParmModulationTable", "index", "must be an integer", -3) return nil end
  if index<1 then ultraschall.AddErrorMessage("GetParmModulationTable", "index", "must be bigger than 0", -4) return nil end
  local count=0
  local found=""
  ParmModTable={}
  for k in string.gmatch(FXStateChunk, "\n    <PROGRAMENV.-\n    >") do
    count=count+1
    if count==index then found=k break end
  end
  if found=="" then ultraschall.AddErrorMessage("GetParmModulationTable", "index", "no such index", -5) return nil end
  found=string.gsub(found, "\n", " \n")
  
--  print_update(found)

  -- <PROGRAMENV
  ParmModTable["PARAM_NR"], ParmModTable["PARAMOD_ENABLE_PARAMETER_MODULATION"]=found:match("<PROGRAMENV (.-) (.-) ")
  if tonumber(ParmModTable["PARAM_NR"])~=nil then
    ParmModTable["PARAM_NR"]=tonumber(ParmModTable["PARAM_NR"])
    ParmModTable["PARAM_TYPE"]=""
  else
    ParmModTable["PARAM_TYPE"]=ParmModTable["PARAM_NR"]:match(":(.*)")
    ParmModTable["PARAM_NR"]=tonumber(ParmModTable["PARAM_NR"]:match("(.-):"))
  end
  ParmModTable["PARAM_NR"]=ParmModTable["PARAM_NR"]+1
  ParmModTable["PARAMOD_ENABLE_PARAMETER_MODULATION"]=tonumber(ParmModTable["PARAMOD_ENABLE_PARAMETER_MODULATION"])==0

  -- PARAMBASE
  ParmModTable["PARAMOD_BASELINE"]=tonumber(found:match("PARAMBASE (.-) "))
  
  ParmModTable["LFO"]=tonumber(found:match("LFO (.-) "))==1

  -- LFOWT  
  ParmModTable["LFO_STRENGTH"], 
  ParmModTable["LFO_DIRECTION"]=found:match("LFOWT (.-) (.-) ")
  ParmModTable["LFO_STRENGTH"]=tonumber(ParmModTable["LFO_STRENGTH"])
  ParmModTable["LFO_DIRECTION"]=tonumber(ParmModTable["LFO_DIRECTION"])

  -- AUDIOCTL
  ParmModTable["AUDIOCONTROL"]=tonumber(found:match("AUDIOCTL (.-) "))==1
  
  -- AUDIOCTLWT
  ParmModTable["AUDIOCONTROL_STRENGTH"], 
  ParmModTable["AUDIOCONTROL_DIRECTION"]=found:match("AUDIOCTLWT (.-) (.-) ")
  ParmModTable["AUDIOCONTROL_STRENGTH"]=tonumber(ParmModTable["AUDIOCONTROL_STRENGTH"])
  ParmModTable["AUDIOCONTROL_DIRECTION"]=tonumber(ParmModTable["AUDIOCONTROL_DIRECTION"])
  
  -- PLINK
  ParmModTable["PARMLINK_SCALE"], 
  ParmModTable["PARMLINK_LINKEDPLUGIN"],
  ParmModTable["PARMLINK_LINKEDPARMIDX"],
  ParmModTable["PARMLINK_OFFSET"]
  =found:match(" PLINK (.-) (.-) (.-) (.-) ")
  
  ParmModTable["PARMLINK_SCALE"]=tonumber(ParmModTable["PARMLINK_SCALE"])
  if ParmModTable["PARMLINK_LINKEDPLUGIN"]~=nil then
    if ParmModTable["PARMLINK_LINKEDPLUGIN"]:match(":")~=nil then 
      ParmModTable["PARMLINK_LINKEDPLUGIN"]=tonumber(ParmModTable["PARMLINK_LINKEDPLUGIN"]:match("(.-):"))+1
    else
      ParmModTable["PARMLINK_LINKEDPLUGIN"]=tonumber(ParmModTable["PARMLINK_LINKEDPLUGIN"])
    end
  end
  ParmModTable["PARMLINK_LINKEDPARMIDX"]=tonumber(ParmModTable["PARMLINK_LINKEDPARMIDX"])
  if ParmModTable["PARMLINK_LINKEDPARMIDX"]~=nil and ParmModTable["PARMLINK_LINKEDPARMIDX"]>-1 then ParmModTable["PARMLINK_LINKEDPARMIDX"]=ParmModTable["PARMLINK_LINKEDPARMIDX"]+1 end
  ParmModTable["PARMLINK_OFFSET"]=tonumber(ParmModTable["PARMLINK_OFFSET"])

  ParmModTable["PARMLINK"]=ParmModTable["PARMLINK_SCALE"]~=nil

  -- MIDIPLINK
  ParmModTable["MIDIPLINK_BUS"], 
  ParmModTable["MIDIPLINK_CHANNEL"],
  ParmModTable["MIDIPLINK_MIDICATEGORY"],
  ParmModTable["MIDIPLINK_MIDINOTE"]
  =found:match("MIDIPLINK (.-) (.-) (.-) (.-) ")
  ParmModTable["MIDIPLINK_BUS"]=tonumber(ParmModTable["MIDIPLINK_BUS"])
  ParmModTable["MIDIPLINK_CHANNEL"]=tonumber(ParmModTable["MIDIPLINK_CHANNEL"])
  ParmModTable["MIDIPLINK_MIDICATEGORY"]=tonumber(ParmModTable["MIDIPLINK_MIDICATEGORY"])
  ParmModTable["MIDIPLINK_MIDINOTE"]=tonumber(ParmModTable["MIDIPLINK_MIDINOTE"])

  ParmModTable["MIDIPLINK"]=ParmModTable["MIDIPLINK_MIDINOTE"]~=nil
  
  -- LFOSHAPE
  ParmModTable["LFO_SHAPE"]=tonumber(found:match("LFOSHAPE (.-) "))
  
  -- LFOSYNC
  ParmModTable["LFO_TEMPOSYNC"], 
  ParmModTable["LFO_SHAPEOLD"],
  ParmModTable["LFO_PHASERESET"]
  =found:match("LFOSYNC (.-) (.-) (.-) ")
  ParmModTable["LFO_TEMPOSYNC"] = tonumber(ParmModTable["LFO_TEMPOSYNC"])==1
  ParmModTable["LFO_SHAPEOLD"]  = tonumber(ParmModTable["LFO_SHAPEOLD"])
  ParmModTable["LFO_PHASERESET"]= tonumber(ParmModTable["LFO_PHASERESET"])
  
  -- LFOSPEED
  ParmModTable["LFO_SPEED"], 
  ParmModTable["LFO_PHASE"]
  =found:match("LFOSPEED (.-) (.-) ")
  ParmModTable["LFO_SPEED"]=tonumber(ParmModTable["LFO_SPEED"])
  ParmModTable["LFO_PHASE"]=tonumber(ParmModTable["LFO_PHASE"])
  
  if found:match("CHAN (.-) ")~=nil then
    ParmModTable["AUDIOCONTROL_CHAN"]  =tonumber(found:match("CHAN (.-) "))+1
  end
  ParmModTable["AUDIOCONTROL_STEREO"]=tonumber(found:match("STEREO (.-) "))

  -- RMS
  ParmModTable["AUDIOCONTROL_ATTACK"], 
  ParmModTable["AUDIOCONTROL_RELEASE"]
  =found:match("RMS (.-) (.-) ")
  ParmModTable["AUDIOCONTROL_ATTACK"]=tonumber(ParmModTable["AUDIOCONTROL_ATTACK"])
  ParmModTable["AUDIOCONTROL_RELEASE"]=tonumber(ParmModTable["AUDIOCONTROL_RELEASE"])
  
  --DBLO and DBHI
  ParmModTable["AUDIOCONTROL_MINVOLUME"]=tonumber(found:match("DBLO (.-) "))
  ParmModTable["AUDIOCONTROL_MAXVOLUME"]=tonumber(found:match("DBHI (.-) "))
  
  -- X2, Y2
  ParmModTable["X2"]=tonumber(found:match("X2 (.-) "))
  ParmModTable["Y2"]=tonumber(found:match("Y2 (.-) "))

  -- MODHWND
  ParmModTable["WINDOW_ALTEREDOPEN"], 
  ParmModTable["WINDOW_XPOS"],
  ParmModTable["WINDOW_YPOS"],
  ParmModTable["WINDOW_RIGHT_READONLY"],
  ParmModTable["WINDOW_BOTTOM_READONLY"]
  =found:match("MODWND (.-) (.-) (.-) (.-) (.-) ")
  ParmModTable["WINDOW_OPENED"]=tonumber(ParmModTable["WINDOW_OPENED"])==1
  ParmModTable["WINDOW_XPOS"]  =tonumber(ParmModTable["WINDOW_XPOS"])
  ParmModTable["WINDOW_YPOS"]  =tonumber(ParmModTable["WINDOW_YPOS"])
  ParmModTable["WINDOW_RIGHT"] =tonumber(ParmModTable["WINDOW_RIGHT"])
  ParmModTable["WINDOW_BOTTOM"]=tonumber(ParmModTable["WINDOW_BOTTOM"])
  
  return ParmModTable
end
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish

Last edited by Meo-Ada Mespotine; 08-01-2020 at 06:25 AM.
Meo-Ada Mespotine is online now   Reply With Quote
 

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:59 AM.


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