• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Output param and call of standard effects from API

Explorer ,
Jul 17, 2008 Jul 17, 2008

Copy link to clipboard

Copied

I have two questions.

1) how can i output parameters? The supervise option is usefull to make a change in parameters each time a parameter is changed... but if i want to change a value of parameter according to my image, how can i do?
I want to compute some point or color, and make them available in the parameter windows so that it can be connected afterwards with expression to other effects parameters...
Using arbitrary type + event callback would solve the problem?

2)My second question is: can I apply from the API an effect other than the one I am working on?
for example, I would like to apply a color key effect on the input layer before I apply my effect. Is it possible? or am i oblige to either program again colorkey, or apply it before outside the API?
TOPICS
SDK

Views

4.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2008 Jul 18, 2008

Copy link to clipboard

Copied

about outputting parameters:
you can apply a value to any standard parameter in any effect using StreamSuite2()->AEGP_SetStreamValue() for constant values, or KeyframeSuite3()->AEGP_SetKeyframeValue() for time varying streams.
(no problem with point, and color. but I'm not sure about arbitrary)
and also set PF_OutFlag_REFRESH_UI, so the user can see the change.

as for applying a different effect:
that a tricky one.
EffectSuite3()->AEGP_ApplyEffect(), will apply any effect you want as long as you have it's AEGP_InstalledEffectKey.
the illusive install key may change between computers, installations and even re launches of AE.
so each time your plug-in launches you must ensure you have the correct install key.
to do that you need to go through every effect installed and check it's MatchName using EffectSuite3()->AEGP_GetEffectMatchName(), AEGP_GetNumInstalledEffects() and AEGP_GetNextInstalledEffect().
the match name for the color key is something like "ADBE ColorKey".
this may also change, if adobe would decide to rename their plug-in internally. (unlikely, as it would invalidate this plug-in for old projects, but don't bet your life on it)

you're not out of the woods yet.
the worst is still to come.
you can only apply effects at a higher position in the effects stack.
i.e. if your effect is 3rd in the stack, you can only apply and effect at position 4 and up.

it gets worse now.
CS3 will crash if your effect isn't the last in the stack while applying a new effect.
and that's not the worst news.
any attempt to reorder the newly applied effect using EffectSuite3()->AEGP_ReorderEffect(), to a position prior to your effect, will launch an error message.
it woun't make AE crash, but it will send a nasty message + error sound each and every time.
and even that wasn't the worst news.

the reason for all these problems is that these functions were intended to be used by AEGPs and not effects.
changing an effect stack from an effect within that stack, wrecks havoc on AE's internal checks.
that was the worst bit.

the only solution i found was using a separate AEGP, that lurks in the shadows and identifies (either by itself or by sending it a message from your effect) an event in which effects need be applied and re ordered, and does that ONLY during AEGP_IdleHook.
that means these changes don't happen while this effect stack is in use.
it's the long way around, but it's the only way that worked for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 18, 2008 Jul 18, 2008

Copy link to clipboard

Copied

Thank you for your prompt reply.
I will try the 1), but I think I will abandon the 2).
I m not familiar with AEGP function, can we call it from Effects plugins? the setStreamValue function takes AEGP_PLUGINID,AEGP_STREAMREFH,AEGP_STREAMVALUE as parameters.... how can I find it?
I will try to find by myself too.
Have a nice week end.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 18, 2008 Jul 18, 2008

Copy link to clipboard

Copied

in general, most AEGP functions can be used in effects.
the documentation says little about which functions shouldn't be used from within effect plug-ins.
the most simple way to know weather a function is safe or not, is to use it.
if your plug-in doesn't crash miserably, then i guess it's ok...

regarding the setStreamValues function,
I didn't find an sdk sample project that uses it.
how ever, the opposite function, getNewStreamValue(), is used quite often.
it uses all the param types you need for SetStreamValues().
look in the "projector" and "project dump" samples, and you'll see how this function is put into use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 25, 2008 Jul 25, 2008

Copy link to clipboard

Copied

Thanks again for your answer. I tried to make it real...
but...
i need to provide the AEGP_PluginID, AEGP_StreamRefH and AEGP_StreamValue

I developped an effect, so my entry point is not the AEGP function:
A_Err
My_AEGP_Main(
struct SPBasicSuite*pica_basicP,
A_long major_versionL,
A_longminor_versionL,
const A_char*file_pathZ,
const A_char*res_pathZ,
AEGP_PluginIDaegp_plugin_id,
AEGP_GlobalRefcon*global_refconPV)

But the
PF_Err
main (
PF_Cmd cmd,
PF_InData *in_data,
PF_OutData *out_data,
PF_ParamDef *params[],
PF_LayerDef *output,
void *extra)

I m really wondering how I could use this setStreamValue to output a parameter in an effect each time my effect is computed...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2008 Jul 25, 2008

Copy link to clipboard

Copied

[DISCLAIMER: this following is pseudo-code: it uses unintialized variables, ignores errors and doesn't release resources. Read the SDK Guide for more info.]

To get an effect's AEGP_PluginID:

AEGP_GlobalRefcon g = 0xF00; // whatever you want
const A_char * s = "my effect"; // whatever you want
AEGP_PluginID gpid;
AEGP_RegisterWithAEGP( g, s, &gpid );

To set a value for a non-time-variant 1D float param:

AEGP_EffectRefH gper;
AEGP_GetNewEffectForEffect( gpid, in_data->effect_ref, &gper );
AEGP_StreamValue2 strmv;
AEGP_GetNewEffectStreamByIndex( gpid, gper, idx, &val.streamH );
PF_ParamIndex idx = 123; // whatever you want
val.val.one_d = 45.6; // whatever you want
AEGP_SetStreamValue( gpid, val.streamH, &value );

Use a similar methods for other param types. There's an additional API layer for adding keyframes for time-variant streams.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 28, 2008 Jul 28, 2008

Copy link to clipboard

Copied

Thank you for your prompt answer.
I succeeded to output my parameter... but ... I have a magic error.

A_Time compTime = {0,1};
AEGP_EffectRefH gper = NULL;
suites.PFInterfaceSuite()->AEGP_GetNewEffectForEffect( gpid, in_data->effect_ref, &gper );//get effect reference
AEGP_StreamRefH streamRef = NULL;
suites.StreamSuite()->AEGP_GetNewEffectStreamByIndex(gpid, gper, AlphaFollow_OUTPUT_POINT, &streamRef);
AEGP_StreamValue value;
AEFX_CLR_STRUCT(value);

suites.StreamSuite()->AEGP_GetNewStreamValue(gpid,streamRef,
AEGP_LTimeMode_CompTime,&compTime,TRUE,&value);
value.val.two_d.x = 15;
value.val.two_d.y = 15;
suites.StreamSuite()->AEGP_SetStreamValue(gpid, streamRef, &value );
suites.StreamSuite()->AEGP_DisposeStream(streamRef);
suites.StreamSuite()->AEGP_DisposeStreamValue(&value);

The parameter value is changed, but each time the value is recomputed, i have the error...
This piece of code is in the render function, and I think this is the problem.
If i put it in the PF_Cmd_USER_CHANGED_PARAM call back it would be called only when user changes parameters right?

I someone has any idea to make my computation automatic, each time the effect is computed...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 02, 2008 Oct 02, 2008

Copy link to clipboard

Copied

During what command selectors are you trying to change your own parameters? If it's not during param supervision, don't expect it to work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2008 Oct 02, 2008

Copy link to clipboard

Copied

LATEST
I succeded to change my parameter value during the render command selector. My only problem is that as the effect parameter change, it cancels the cache each time it s computed.

A_Time currentCompTime;
AEGP_EffectRefH gper = NULL;
AEGP_StreamValue value;
AEFX_CLR_STRUCT(value);
AEGP_StreamValue currentvalue;
//layer info
AEGP_LayerH currentLayer;
A_Time layerInpoint;
A_Time layerDuration;
suites.PFInterfaceSuite1()->AEGP_ConvertEffectToCompTime(in_data->effect_ref,
in_data->current_time,
in_data->time_scale,
&currentCompTime);
suites.PFInterfaceSuite1()->AEGP_GetEffectLayer(in_data->effect_ref, &currentLayer);
suites.LayerSuite5()->AEGP_GetLayerInPoint(currentLayer, AEGP_LTimeMode_CompTime, &layerInpoint);
suites.LayerSuite5()->AEGP_GetLayerDuration(currentLayer, AEGP_LTimeMode_CompTime, &layerDuration);

suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(gpid, in_data->effect_ref, &gper );//get effect reference
suites.StreamSuite1()->AEGP_GetNewEffectStreamByIndex(gpid, gper, AlphaFollow_OUTPUT_POINT, &value.streamH);
suites.StreamSuite2()->AEGP_GetNewStreamValue(gpid, value.streamH, AEGP_LTimeMode_CompTime, &currentCompTime, false, &currentvalue);
...
suites.StreamSuite1()->AEGP_SetStreamValue(gpid, value.streamH, &value );
suites.StreamSuite1()->AEGP_DisposeStreamValue(&currentvalue);
suites.EffectSuite3()->AEGP_DisposeEffect(gper);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines