COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 07-10-2016, 04:26 AM   #1
Staiff
Human being with feelings
 
Join Date: May 2016
Posts: 34
Default presets creation & management

hello !

in my synth i use both Iplugchunk & iplug multitarget preset managers.



as U could see i have the preset (from "create preset" in .cpp) at the top and the drop down menu to load/save .fxp/.fxb just under.

that works !



But my problems are:

1 - i didn't really create preset at this time. "init synth" is just a name (no params). to create presets with "create preset" i must enter all enum params number in the exact order as it is in the "enum param" section ? right ?
if i want 128 preset i'll have to write all params for each 128 presets.... (SIG ! )


2 - i created some presets (for testing) and saved them in .fxp.
Loading .fxp presets work, but of course the preset name is not shown in the top window because it's not written in the "create preset" section; It's still "init synth". So:

3 - is there a way to show the .fxp preset name in the the "create preset" window ?

4 - is there a way to put the .fxp presets by default in the synth (instead of creating/writing it in the "create preset" section) ?

in the iplugchunk code ther is:

Code:
class ITempPresetSaveButtonControl : public IPanelControl
{
public:
	ITempPresetSaveButtonControl(IPlugBase *pPlug, IRECT pR)
		: IPanelControl(pPlug, pR, &COLOR_RED) {}

	void OnMouseDown(int x, int y, IMouseMod* pMod)
	{
		WDL_String presetFilePath;
		mPlug->GetGUI()->DesktopPath(&presetFilePath);
#ifdef OS_WIN
		presetFilePath.Append("\\IPlugChunksPreset.txt");
#else //OSX
		presetFilePath.Append("IPlugChunksPreset.txt");
#endif
		mPlug->DumpPresetBlob(presetFilePath.Get());
	}
"IPlugChunksPreset.txt""?

thanks for answers
Staiff is offline   Reply With Quote
Old 07-10-2016, 05:59 AM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Staiff View Post

1 - i didn't really create preset at this time. "init synth" is just a name (no params). to create presets with "create preset" i must enter all enum params number in the exact order as it is in the "enum param" section ? right ?
You can also use 'CreatePresetFromNamedParams' then they needn't be in the exact order as in 'enum param' section, I find this a little easier.

Like this:

Code:
void myPlugin::CreatePresets() {
  MakePresetFromNamedParams("Preset 1", kNumParams,
  param, val
  ...
  );
}

Last edited by nofish; 07-10-2016 at 06:07 AM.
nofish is offline   Reply With Quote
Old 07-10-2016, 06:15 AM   #3
Staiff
Human being with feelings
 
Join Date: May 2016
Posts: 34
Default

Quote:
Originally Posted by nofish View Post
You can also use 'CreatePresetFromNamedParams' then they needn't be in the exact order as in 'enum param' section, I find this a little easier.
i tried this but compiling crashed

but maybe because i didn't implement params, just name and preset order/number ?

Code:
void myPlugin::CreatePresets() {
  MakePresetFromNamedParams("Preset 1", kNumParams,
  param, val
  ...
  );
}
preset name= ok, kunmparam = ok, value = ok. but param ? what's this ?

for example:
MakePresetFromNamedParams("test preset", kGain,
"?", 0.7
Staiff is offline   Reply With Quote
Old 07-10-2016, 06:37 AM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Staiff View Post
for example:
MakePresetFromNamedParams("test preset", kGain,
"?", 0.7
That's not quite correct.

'kNumParams' is the last variable in 'EParams' enumeration, to give the number of parameters, so it must stay this way.

'param' is the name of the parameter given in 'EParams'

'val' is the value you want to assign to this parameter.


Here's a snippet of actual code I use in my plugin:

Code:
void myPlugin::CreatePresets()
{
	MakePresetFromNamedParams("init", 0); // sets to default values
		
	MakePresetFromNamedParams("Preset 1", kNumParams,
		kOscFrequency, 684.02, 
		kGain, 20.33,
		kOscWaveform, 2,
		kOnOff, 0,

		mLFOpitchWaveform, 0,
		mLFOpitchFrequency, 4.22,
		mLFOpitchAmount, 54.37,

		mLFOLFO1Waveform, 0,
		mLFOLFO1Frequency, 0.,
		mLFOLFO1Amount, 0.,

		mLFOLFO2Waveform, 0,
		mLFOLFO2Frequency, 0.,
		mLFOLFO2Amount, 0.,

		kChopSwitch, 0,
		mLFOChopFrequency, 0.7,
		mLFOChopAmount, 0.,

		kLFOLFO1Switch, 0,
		kLFOLFO2Switch, 0,

		mVolumeEnvAttack, .01,
		mVolumeEnvRelease, .01,

		kWet, .7,
		kDelay, .3,
		kFeedback, .7,
		kLFOdepth, .0,
		kLFOspeed, .5,

		kDelayHP, .264,
		kDelayLP, 0.656
		);

	MakePresetFromNamedParams("Preset 2", kNumParams,
		kOscFrequency, 895.,
		kGain, 20.33,
		kOscWaveform, 1,
		kOnOff, 0,

		mLFOpitchWaveform, 0,
		mLFOpitchFrequency, 0.387,
		mLFOpitchAmount, 73.,

		mLFOLFO1Waveform, 0,
		mLFOLFO1Frequency, 0.,
		mLFOLFO1Amount, 0.,

		mLFOLFO2Waveform, 0,
		mLFOLFO2Frequency, 0.,
		mLFOLFO2Amount, 0.,

		kChopSwitch, 0,
		mLFOChopFrequency, 0.7,
		mLFOChopAmount, 0.,

		kLFOLFO1Switch, 0,
		kLFOLFO2Switch, 0,

		mVolumeEnvAttack, 3.44, 
		mVolumeEnvRelease, 12.678,

		kWet, .7,
		kDelay, .3,
		kFeedback, .7,
		kLFOdepth, .0,
		kLFOspeed, .5,
		
		kDelayHP, .264,
		kDelayLP, 0.656
		);
}
Is it more clear now ?
nofish is offline   Reply With Quote
Old 07-10-2016, 08:45 AM   #5
Staiff
Human being with feelings
 
Join Date: May 2016
Posts: 34
Default

okay i understand now.

i just tested with 2 params (i have 65)
Code:
MakePresetFromNamedParams("Preset 1", kNumParams,
		kGain, 0.3,
		kPan, 0.5);
and the compiling result:

Code:
Unhandled exception at 0x00007FF74E1B64BE in Synth.exe: 0xC0000005: Access violation writing location 0x000001B2CAE11468.
maybe because i didn't use all params ...

Anyway, the "classic" style (just "makePreset" and the values) work.

Code:
MakePreset("Synth Strings 1", 0.7, 0.5, 500, MODE_SAW, 0, 0, 2, 1.003, 0, 0.5, 0.5, 0.5, MODE_SAW, 0, 0.004, 2, 1.006, 0, 0.5, 0.5, 0.5, MODE_SAW, 0, 0.006, 2, 1.013, 0, 0.5, 0.5, 0.5, MODE_SAW, 0, 0, 0, 1.0, 0, 0.5, 0.5, 0.0, ENVELOPE_MODE_LOG, 0.00, 3.90, 0.56, 2.57, MODE_LOWPASS, 0.990, 0.042, ENVELOPE_MODE_LOG, 0.001, 0.87, 0.75, 2.501, 1.00, 0.0, false, 0.0, false, 0.500, 0.40, 2.0, OFF, 0.001, MODE_SINE, 0.53, FilterCutoff);

//it works !
So i will continue with this kind of setting if i have error again with MakePresetFromNamedParams. I already have my 1rst preset

there is no way to read .fxp in .txt style (readable of course) to just cap the settings in it ?
Staiff is offline   Reply With Quote
Old 07-10-2016, 09:07 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Staiff View Post
okay i understand now.

i just tested with 2 params (i have 65)
Code:
MakePresetFromNamedParams("Preset 1", kNumParams,
		kGain, 0.3,
		kPan, 0.5);
and the compiling result:

Code:
Unhandled exception at 0x00007FF74E1B64BE in Synth.exe: 0xC0000005: Access violation writing location 0x000001B2CAE11468.
maybe because i didn't use all params ...
Yes, use kNumParams if you want to assign all parameters. Sorry, should have written that. With above example you should do:

Code:
MakePresetFromNamedParams("Preset 1", 2,
		kGain, 0.3,
		kPan, 0.5);
Quote:
there is no way to read .fxp in .txt style (readable of course) to just cap the settings in it ?
I'd like to know this too. Would make things quicker.
nofish is offline   Reply With Quote
Old 07-10-2016, 09:37 AM   #7
Staiff
Human being with feelings
 
Join Date: May 2016
Posts: 34
Default

Quote:
Originally Posted by nofish View Post
Sorry, should have written that.
Don't be sorry. I am stupid. that's all.I should have guessed myself

Quote:
Originally Posted by nofish View Post
I'd like to know this too. Would make things quicker.
yes because i prefer creating preset with my ears, no with numbers/params. So i'm playing with all the params/knobs/sliders, save it in .fxp

after that I have to retrieve all the parameters to write them in the .cpp

It's long ... very long...
Staiff is offline   Reply With Quote
Old 07-10-2016, 12:35 PM   #8
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

Take a look at DumpPresetSrcCode() in IPlugBase.h/cpp. You pass a char* filename and a char* array of parameter names. The function will save a text file that matches the MakePresetFromNamedParams() function. If you add a way of triggering this (like through your drop-down menu), it should make life a lot easier for saving presets.

You can also modify things further to save to the clipboard. This makes it easy to cut and paste. I use this, and pass the std::string of the "MakePresetFromNameParams(......". I do this instead of saving to a file.
Code:
bool  DumpToClipBoard(std::string* txt) {
    bool r = true;
#ifdef OS_WIN
    const char* output = txt->c_str();
    const size_t len = strlen(output) + 1;
    HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
    memcpy(GlobalLock(hMem), output, len);
    GlobalUnlock(hMem);
    r &= OpenClipboard(0);
    r &= EmptyClipboard();
    SetClipboardData(CF_TEXT, hMem);
    r &= CloseClipboard();
#else
    AddEscapeQuotes(txt);
    std::string cmd = "echo \"";
    cmd.append(*txt);
    cmd.append("\" | pbcopy");
    FILE* pipe = popen(cmd.c_str(), "r");
    pclose(pipe);
#endif
    return r;
}

void  AddEscapeQuotes(std::string* s, std::size_t start) { // all \" needs replaced with \\\"    ->  http://stackoverflow.com/questions/13689738/keeping-double-quotes-when-passing-string-to-popen-in-c
    std::size_t find = s->find("\"", start);
    if (find != s->npos) {
        s->insert(find, "\\");
        AddEscapeQuotes(s, find + 3u);
    }
}
[check my code, this was a quick copy/paste that I had to strip some things out. I hope I got it right]
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 07-11-2016, 01:19 AM   #9
Staiff
Human being with feelings
 
Join Date: May 2016
Posts: 34
Default

not a bad idea, cause a lot of preset in main .cpp make a huge file (a lot of text).
but I would have preferred the opposite. export/save your preset/gui change directly from the synth (standalone, vst, etc. ...) with a "save" button (or menu) that write directly the params in "make preset"

If you prefer the basic "save/save as" on every software

But if you do that every user could totally change your presets. Spending time to create presets and let user saving/replacing/erasing them ...

the actual way of creation is long, but i prefer.

in the Iplugmultitargets_controls.h there is:

Code:
class IPresetMenu : public IControl
{
private:
  WDL_String mDisp;
public:
  IPresetMenu(IPlugBase *pPlug, IRECT pR)
    : IControl(pPlug, pR, -1)
  {
    mTextEntryLength = MAX_PRESET_NAME_LEN - 3;
    mText = IText(14, &COLOR_RED, "Arial", IText::kStyleNormal, IText::kAlignNear);
  }
If i change the arial font with another (LCD, Liquid crystal, etc...), every users sould have the same font installed or is it baked in the file (.dll, vst3, AU, etc. ...) ?

because arial on a synth screen is awful
Staiff 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 04:34 AM.


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