COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 03-04-2016, 01:09 PM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default locking a parameter when changing presets ?

Is there a way to lock a parameter when changing 'baked in' presets, meaning this parameter retains the value it had before switching to another preset.

Example, I want the output volume knob of my synth to always stay the same once the user has changed it when switching presets.

Other than possibly using chunks (which I haven't looked into yet).
nofish is offline   Reply With Quote
Old 03-04-2016, 04:46 PM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Some of the params from Combo Model F are global rather than per preset, which I guess is similar to what you want. But yeah, I use chunks for that...
Tale is offline   Reply With Quote
Old 03-04-2016, 05:18 PM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Thanks Tale.
Guess I'll have to look into chunks then.
nofish is offline   Reply With Quote
Old 03-08-2016, 05:26 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

Another thought (as I rather not want to get into chunks stuff currently)...

Do we have a way to detect when the user selected another (baked in) preset ?

Then it would be rather easy setting the output volume to the value it was before I'd think.
nofish is offline   Reply With Quote
Old 03-08-2016, 05:55 AM   #5
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

If you aren't using chunks, you should be able to us IPlugBase::MakePresetFromNamedParams() in the plugin constructor to create baked-in presets. You need to give the preset a name, number of parameters to set, and a list of paramEnum/paramVal.

If you don't want the output volume to change, don't put it in the argument list and it will stay at the default value.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 03-08-2016, 08:39 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

Thanks, I've gotten this far already.

However,

Quote:
Originally Posted by random_id View Post
If you don't want the output volume to change, don't put it in the argument list and it will stay at the default value.
is the thing I want to get around here.
I don't want it to stay at default value, but stay at the 'last touched' value (i.e. lock it from preset change).

(Scenario: I load a Synth, play some notes, adjust output volume to taste. Now I start flipping through presets, output volume should stay where it is, so I don't have to dial it back everytime to my prefered level when I change a preset.)

Any way to do this (without using chunks if avoidable) ?

Last edited by nofish; 03-08-2016 at 08:51 AM.
nofish is offline   Reply With Quote
Old 03-08-2016, 12:56 PM   #7
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

What if you override UnserializeState() in your plugin. You could first get the output gain value, then call UnserializeParams(), and then set the output gain to the saved value.

The only think that might be an issue is with recalling saved states. I am not sure if there is a way to differentiate between a preset and a user-defined saved state.

I guess if you wanted to, you could have an extra bool parameter for the plugin that determines if the output gain is saved or not. Then in your overridden UnserializeState you could see if the parameter is on/off to determine if the gain is changed.

I am probably making this more complicated and less elegant.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 03-29-2016, 05:13 AM   #8
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 random_id View Post
What if you override UnserializeState() in your plugin. You could first get the output gain value, then call UnserializeParams(), and then set the output gain to the saved value.

The only think that might be an issue is with recalling saved states. I am not sure if there is a way to differentiate between a preset and a user-defined saved state.

I guess if you wanted to, you could have an extra bool parameter for the plugin that determines if the output gain is saved or not. Then in your overridden UnserializeState you could see if the parameter is on/off to determine if the gain is changed.

I am probably making this more complicated and less elegant.

Thanks and sorry for the late reply (sidetracked with other stuff...).

I've found another thread which also mentiones overwriting UnserializeState() for exactly this purpose (ignoring a param on preset recall) so this seems indeed a way to go.

http://forum.cockos.com/showthread.php?t=127661

So I tried a simple overwrite test with

Code:
// MyPlugin.h
int UnserializeState(ByteChunk * pChunk, int startPos);

// MyPlugin.cpp
int MyPlugin::UnserializeState(ByteChunk* pChunk, int startPos)
{
  TRACE;
  IMutexLock lock(this);
  return IPlugBase::UnserializeParams(pChunk, startPos);
}
and notice this gets called when I change presets in the plugin.
Looks good so far I'd say.

But uhm, now what ?
I'm not (yet) familiar with dealing with this ByteChunk. How would I use it to ignore a certain parameter on preset recall (or set to a previously saved value as you suggest) ?

(note that I currently don't use chunks in my plugin, but this shouldn't be a problem I'd think because according to here

http://forum.cockos.com/showpost.php...78&postcount=8

Unserialize() should get called anyway and that's what I observe also).

Thanks.

Last edited by nofish; 03-29-2016 at 05:26 AM.
nofish is offline   Reply With Quote
Old 04-03-2016, 02:05 AM   #9
antto
Human being with feelings
 
Join Date: Nov 2008
Posts: 108
Default

i've proposed some changes to IPlug which enable certain very desirable (i think) features for parameters (when using chunks) including hidden parameters, and setting a parameter to ignore being changed by presets
more info here: http://forum.cockos.com/showthread.p...39#post1401339 (and an example on the following post)

..just sayin'
antto is offline   Reply With Quote
Old 04-03-2016, 02:11 AM   #10
antto
Human being with feelings
 
Join Date: Nov 2008
Posts: 108
Default

i don't know what's the reason why those functionalities didn't get added to IPlug, i didn't get any explanation
so i guess maybe it's because i didn't implement it properly, and/or didn't submit it properly to git, and/or didn't explain what it does and why it's good
or maybe those who have the powers to accept the changes just develop plugins in a different way, a way where they don't end up needing to have these features

in any case, i hope the problem is in my lousy coding, and that someone who can code more properly sees the "parameter uniqueID" idea and pushes it forward so that it can get added to wdl-ol one day
antto is offline   Reply With Quote
Old 04-03-2016, 06:21 AM   #11
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

I was thinking about something simple like
Code:
// MyPlugin.cpp
int MyPlugin::UnserializeState(ByteChunk* pChunk, int startPos)
{
  TRACE;
  IMutexLock lock(this);
  double paramV = GetParam(kMyParam)->Value(); //gets the current value
  return IPlugBase::UnserializeParams(pChunk, startPos); //loads the settings
  GetParam(kMyParam)->Set(paramV); //sets the param back to the current value

  OnParamChange(kMyParam); //might need some things like this to ensure the internal 
     //variables are set to the correct values, and maybe 
     //to make sure the control is drawn with the correct settings
}
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 04-03-2016, 10:48 AM   #12
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Thanks random_id.

That's basically what I also came up with, seems to work for me so far for e.g. ignoring output volume on preset recall (not thouroughly tested yet though).

Code:
int myPlugin::UnserializeState(ByteChunk * pChunk, int startPos)
{
	TRACE;
	IMutexLock lock(this);
	
	int rtnval;
	double currentVal = pGainControl->GetValue(); // get current value
	rtnval = IPlugBase::UnserializeParams(pChunk, startPos); // first recall preset / default vals. ....
	if (savedStateLoaded == true) { // ...then set back vol to previous val.
		pGainControl->SetValueFromPlug(currentVal);
		pGainControl->SetDirty();
	}
	savedStateLoaded = true; // a flag initialised to false to ensure properly loading saved project state
	return rtnval;
}
nofish 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:56 PM.


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