Old 08-01-2018, 05:46 AM   #1
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default Store custom extension data in .RPP project

hello,

Is there a way to store something in the .RPP from a custom reaper extension?

thanks!

oli
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 08-01-2018, 06:01 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Code:
int SetProjExtState(ReaProject* proj, const char* extname, const char* key, const char* value)

Save a key/value pair for a specific extension, to be restored the next time this specific project is loaded. 

int GetProjExtState(ReaProject* proj, const char* extname, const char* key, char* valOutNeedBig, int valOutNeedBig_sz)

Get the value previously associated with this extname and key, the last time the project was saved.
There was also some more involved way but I don't remember the specifics at the moment. (A system that can be used handle custom undo states as well as custom project data.)
__________________
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 08-01-2018, 06:37 AM   #3
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

thanks!
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 08-01-2018, 06:47 AM   #4
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

and is there a way to know when a new project is loaded? I'm doing this in C++
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 08-01-2018, 07:26 AM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by olilarkin View Post
and is there a way to know when a new project is loaded? I'm doing this in C++
edit : wrong answer removed.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.

Last edited by Xenakios; 08-01-2018 at 12:31 PM.
Xenakios is offline   Reply With Quote
Old 08-01-2018, 08:32 AM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

There is project_config_extension_t for this purpose.
Code:
#include <reaper_plugin.h>
#include <reaper_plugin_functions.h>
#include <WDL/lineparse.h>

static void BeginLoadProjectState(bool isUndo, struct project_config_extension_t *reg)
{
  // called on project load/undo before any (possible) ProcessExtensionLine
}

static bool ProcessExtensionLine(const char *line, ProjectStateContext *ctx, bool isUndo, struct project_config_extension_t *reg)
{
  LineParser lp(false);
  if(lp.parse(line) || lp.getnumtokens() < 1)
    return false;

  if(!strcmp(lp.gettoken_str(0), "YOURPLUGIN_SETTING")) {
    const char *value = lp.gettoken_str(1);
    return true;
  }

  return false; // if nobody returns true for this setting, REAPER will show a popup
}

static void SaveExtensionConfig(ProjectStateContext *ctx, bool isUndo, struct project_config_extension_t *reg)
{
  ctx->AddLine("YOURPLUGIN_SETTING %s", "value");
}

static project_config_extension_t s_projectconfig{
  ProcessExtensionLine, SaveExtensionConfig, BeginLoadProjectState
};

YourPlugin::YourPlugin()
{
  plugin_register("projectconfig", &s_projectconfig);
}

YourPlugin::~YourPlugin()
{
  plugin_register("-projectconfig", &s_projectconfig);
}

Last edited by cfillion; 08-01-2018 at 08:38 AM.
cfillion is offline   Reply With Quote
Old 08-01-2018, 09:15 AM   #7
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

perfect thanks!
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin 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 05:26 AM.


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