Skip to main content
Inspiring
December 28, 2021
Answered

How to read out time slider position from c++ plugin. Take 2

  • December 28, 2021
  • 1 reply
  • 1766 views

Dear AE fellows,

most of us know that method

in_data ->current_time

 nicely reads out the position of a time slider.

Now the issue. My plugin has  its own win32 window (on top of AE main window) as part of its UI.

A lot of  the functionality of the plugin takes place inside this win32 window.

This win32 window needs the position of the time slider at each moment of the plugin usage. The question is: how can I pass this value to it.

The point is, if I don't change the parameters of my plugin (and I don't), no messages in the EffectMain (like PF_Cmd_RENDER, PF_Cmd_USER_CHANGED_PARAM and so on) are triggered. 

So in_data->current_time never gets updated(!)

Is it at all possible?

 

 

 

 

 

This topic has been closed for replies.
Correct answer shachar carmi

Thanks, for an advice Sachar!

Actually, what I'm trying to implement is the synchronous play of animation in my win32 window and in AE (or Ppro) window. That is needed for the designer preview function.

I sometimes think of  creating a .txt file with the time and update it every 10th of a second and then my win32 window will read the data from the file every 10th of a second and that's it.

Do you think it could be a viable solution? (Here we need to keep in mind that such a synchonization will be switched on by the user just from time to time)


i'd probably go with some shared memory with a mutex instead of a file.

but anyways, idle hook on the plug-in side and a timer on the window side would be the way to go. (imho)

1 reply

Community Expert
December 29, 2021

AEGP_GetItemCurrentTime

Inspiring
December 29, 2021

Thank you, Shachar,

I wrote a simple function:

A_long time_ae(PF_InData * in_data)
{
	AEGP_SuiteHandler suites(in_data->pica_basicP);
	A_Time time;
	AEGP_ItemH myitem;
	suites.ItemSuite8()->AEGP_GetActiveItem(&myitem);
	suites.ItemSuite8()->AEGP_GetItemCurrentTime(myitem, &time);
	return time.value;
}

 However it produces access violation error when hitting  suites.ItemSuite8()->AEGP_GetActiveItem(&myitem); line. Do you know what could be the reason for that?

Community Expert
January 1, 2022

Thanks, Shachar!

Since I never implemented idle hooks may I ask for some short hint?

 

1. is there some available somple code where I could find the sample implementation of an idle hook?

(I tried to google, but it always refers me to "idle task hook".  Does it feel as the correct ref?).

 

Do I undertsand the logic of implementation correctly?

  1. Since I need AEGP_GetActiveItem in any case I suppose I'll insert the code for the hook right into my EffectMain function.

2. Somehow I need my AEGP_GetActiveItem to work constantly for some time duration and to get updated 25 -30 times a second. That means I should somehow make it work continously.  That entails that I need to read out and update  my  in_data->pica_basicP 25-30 times a second (or simply in_data). 

 

3. to achieve  this in_data->pica_basicP constant update I need to create this magical hook. 

Is it a correct logic?

Is a hook a separate function which intercepts the memory address (or something like this) of in_data->pica_basicP and make it recompute 25-30 times per second?

 

 


the plan is to call AEGP_GetActiveItem and act on it during idle hook.

here's how to set it up.

 

create some static data strcuture to pass onto the idle hook function.

struct MyIdleHookData {

    SPBasicSuite *pica_basicP;//you'll probably want this...

    //add any other bit of info you'd like to use like, say, your global data pointer.

}

 

during global setup, call:

static MyIdleHookData idleData;

idleData.pica_basicP = in_data->pica_basicP;//fill the rest for the transfered goodies as well.

AEGP_PluginID aegpID;
suites.UtilitySuite6()->AEGP_RegisterWithAEGP(NULL, "some name", &aegpID);
suites.RegisterSuite5()->AEGP_RegisterIdleHook(aegpID, IdleHookFunction, (AEGP_IdleRefcon)&idleData);

 

that's if for the setup. the idle hook function will now be regularly called.

now for the implementation of the idle hook function:

 

PF_Err IdleHookFunction(AEGP_GlobalRefcon plugin_refconP, AEGP_IdleRefcon refconP, A_long *max_sleepPL) {
    *max_sleepPL = 500;//the max time you'd like before the next idle call, in ms.
    MyIdleHookData *idleData = (MyIdleHookData*)refconP;

 

    AEGP_SuiteHandler suites(idleData ->pica_basicP);

    //that's it. go nuts with whatever process you'd like to do. call AEGP_GetActiveItem and process it here.

 

    return PF_Err_NONE;
}