Old 10-28-2020, 08:37 AM   #1
mendel
Human being with feelings
 
mendel's Avatar
 
Join Date: Oct 2020
Posts: 6
Default Save / restore ripple (get and set ripple mode scripts)

Hi folks,

Perhaps a solution for this already existed, but I couldn't find it. Maybe everyone who needs such a thing is already a competent enough programmer that they don't need such a basic script.

I was looking for a script to save the current ripple mode, and then another script to load that saved mode. To rephrase for SEO: get and set ripple state.

With these two scripts, I could then bookend a custom action, so that it could change ripple for its needs and then restore it to whatever mode it was before the action ran.

I hope you may find this useful. Maybe you'll be able to install them through ReaPack soon, but you can also use the following code to make your own .Lua ReaScript

https://github.com/bowlneudel/ReaScr...4d983cb644ea72

Code:
-- @description Save ripple mode to persistent ExtState
-- @author mendel
-- @version 1.0
-- @about
--   # Save ripple mode to persistent ExtState
--
--   A most basic script that simply gets the current ripple mode, and saves it as a persistent ExtState. This state may be recalled by another script, and the ripple mode restored.
--
--   These two scripts are intended to be used in conjunction: as bookends to custom actions that require a programmatic change of the ripple mode.

Ra = reaper.GetToggleCommandState(41991)
R1 = reaper.GetToggleCommandState(41990)

function Save_Ripple_State()
  if Ra==1 then
    reaper.SetExtState("Ripple","RippleState","A",1)
    -- reaper.ShowMessageBox("Ripple Mode Saved: All Tracks", "Ripple Mode", 0)
  end
  if R1==1 then
    reaper.SetExtState("Ripple","RippleState","P",1)
    -- reaper.ShowMessageBox("Ripple Mode Saved: Per Track", "Ripple Mode", 0)
  end
  if Ra+R1==0 then
    reaper.SetExtState("Ripple","RippleState","N",1)
    -- reaper.ShowMessageBox("Ripple Mode Saved: Off", "Ripple Mode", 0)
  end
end

Save_Ripple_State()

---

https://github.com/bowlneudel/ReaScr...e2352eb736adff

Code:
-- @description Restore ripple mode from persistent ExtState
-- @author mendel
-- @version 1.0
-- @about
--   # Restore ripple mode from persistent ExtState
--
--   This script works in conjunction with "Save ripple mode to persistent ExtState". These two scripts are intended to be used as bookends for custom actions which change the ripple mode programatically. This allows a custom action to proceed as expected, leaving the user experience of the ripple mode unchanged.

function Restore_Ripple_State()
RippleState = reaper.GetExtState("Ripple","RippleState")
  if RippleState=="A"
    then
      reaper.Main_OnCommand(40311,0,1)
      -- reaper.ShowMessageBox("Ripple Mode Restored: All Tracks", "Ripple Mode", 0)
  end
  if RippleState=="P"
    then
      reaper.Main_OnCommand(40310,0,1)
      -- reaper.ShowMessageBox("Ripple Mode Restored: Per Track", "Ripple Mode", 0)
  end
  if RippleState=="N"
    then
      reaper.Main_OnCommand(40309,0,1)
      -- reaper.ShowMessageBox("Ripple Mode Restored: Off", "Ripple Mode", 0)
  end
end

Restore_Ripple_State()

Last edited by mendel; 04-10-2021 at 10:42 AM.
mendel is offline   Reply With Quote
Old 10-28-2020, 12:34 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Could you wrap the codes in [code]-brackets(or select it and hit the #-button in this editor)?

Otherwise it's too unreadable And might get mislayouted by the forum'ssoftware.

Welcome to the forum
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-10-2021, 10:42 AM   #3
mendel
Human being with feelings
 
mendel's Avatar
 
Join Date: Oct 2020
Posts: 6
Default

Sorry! I didn't even know to subscribe to replies! Finally edited
mendel is offline   Reply With Quote
Old 10-16-2021, 04:08 PM   #4
RothMedia
Human being with feelings
 
Join Date: Jun 2021
Posts: 15
Default

I'm new to scripting for Reaper so forgive the n00b question.

What are 41991 and 41990 ids for?
RothMedia is offline   Reply With Quote
Old 10-16-2021, 04:26 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

You can see it in the Action list:


(maybe you have to rightclick in action list > Show action IDs, to make the Command ID column visible).
nofish is offline   Reply With Quote
Old 10-17-2021, 06:45 AM   #6
RothMedia
Human being with feelings
 
Join Date: Jun 2021
Posts: 15
Default

Quote:
Originally Posted by nofish View Post
You can see it in the Action list:


(maybe you have to rightclick in action list > Show action IDs, to make the Command ID column visible).
Nice! I was looking at all the other ripple-related actions and missed those. Thanks so much!

Also, didn't even know that column existed until now.
RothMedia 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:33 AM.


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