Copy link to clipboard
Copied
hi,all:
i've written a keyframer plugin.the AE often prompt a dialog(which shows "After Effects error: Time argument is out of range.") when the plugin deletes some keyframes and inserts lots of keyframe.i checked out the time argument and found the time is valid.on what condition the AE will promt the dialog?
thanks advance
Copy link to clipboard
Copied
the dialog wo'nt show if i just insert keyframes(do'nt delete keyframes before insert lots of keyframes).who can help me?
Copy link to clipboard
Copied
try deleting the keyframes in reverse order.
not only is it much faster, it could also prevent an issue where the key
index is out of range because the list shortens as you delete. meaning, key
10 will become key 7 after deleting 3 keys.
i know it's not directly related to the message that you're seeing, but
perhaps it's messes something up that later manifests as what problem
you're getting.
Copy link to clipboard
Copied
i tried to delete the keyframes in reverse order and the dialog also shows.i read the sdk and didn't find the way to delete keyframes in batch mode.whereas can insert keyframes in batch mode.
and i find that if i insert keyframes not in batch mode,the dialog shows more frequently.
Copy link to clipboard
Copied
here's a thread about keyframe deletion.
https://forums.adobe.com/message/7694328#7694328
françois leroy has suggested a couple of methods for removing all keyframes
from a layer instead of deleting each one individually.
perhaps that will solve the issue you're seeing. (though it doesn't explain
why the problem is occurring.
say, if you only delete the keyframes but don't create new ones, does the
error message still show?
Copy link to clipboard
Copied
to shachar: thank you for your reply very much.
if i just delete lots of keyframes and just insert lots of keyframes the dialog wo'nt show,it works fine.
Copy link to clipboard
Copied
to shachar:in my plugin i can't delete all keyframes,i need to delete the keyframes in the specified time range and insert new frames in the time range.
Copy link to clipboard
Copied
just guessing here, but perhaps you need to end the batch operation after
the deletion and then start a new one for the adding.
if that doesn't help then you should probably if you posted the relevant
code here.
Copy link to clipboard
Copied
to shachar:here is my code:
static A_Err CopyStream(A_char * pEffectName,A_long streamIndexDes,A_long streamIndexSrc,A_long startFrameIndex,A_long EndFrameIndex)
{
A_Err err = A_Err_NONE;
AEGP_SuiteHandler suites(sP);
AEGP_LayerH layerH = NULL;
A_long com_index =0;
A_long num_effectsL =0;
A_long num_paramsL = 0;
A_char item_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char type_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char layer_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char effect_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char stream_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char indent_stringAC[128] = {'\0'};
AEGP_EffectRefH effectH = NULL;
AEGP_StreamRefH streamSrcH = NULL;
AEGP_StreamRefH streamDesH = NULL;
AEGP_ProjectH proj;
ERR(suites.ProjSuite6()->AEGP_GetProjectByIndex(0,&proj));
AEGP_ItemH itemH;
AEGP_ItemType itemType;
ERR(suites.ItemSuite8()->AEGP_GetFirstProjItem(proj,&itemH));
while(err == PF_Err_NONE && itemH != NULL)
{
ERR(suites.ItemSuite6()->AEGP_GetItemName(itemH,type_nameAC));
ERR(suites.ItemSuite6()->AEGP_GetItemType(itemH,&itemType));
if(itemType == AEGP_ItemType_COMP)
{
//composition
std::string strCompName = "QSC";
std::string strTemp = type_nameAC;
if(strCompName.compare(strTemp.c_str()) != 0)
continue;
A_long numLayers;
AEGP_CompH compH;
AEGP_LayerH layerH;
A_Boolean bFindQscEffect = FALSE;
suites.CompSuite8()->AEGP_GetCompFromItem(itemH,&compH);
suites.LayerSuite7()->AEGP_GetCompNumLayers(compH,&numLayers);
for(A_long index = 0;index < numLayers;index++)
{
suites.LayerSuite7()->AEGP_GetCompLayerByIndex(compH,index,&layerH);
if(layerH != NULL)
{
ERR(suites.EffectSuite2()->AEGP_GetLayerNumEffects(layerH, &num_effectsL));
for (A_long jL = 0; !err && jL < num_effectsL; jL++)
{
ERR(suites.EffectSuite2()->AEGP_GetLayerEffectByIndex(S_my_id, layerH, jL, &effectH));
if (!err && effectH)
{
AEGP_InstalledEffectKey key;
ERR(suites.EffectSuite2()->AEGP_GetInstalledKeyFromLayerEffect(effectH, &key));
ERR(suites.EffectSuite2()->AEGP_GetEffectName(key, effect_nameAC));
std::string strEffectName = pEffectName;
std::string strTemp = effect_nameAC;
if(strEffectName.compare(strTemp.c_str()) != 0)
{
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effectH));
continue;
}
bFindQscEffect = TRUE;
ERR(suites.StreamSuite2()->AEGP_GetEffectNumParamStreams(effectH, &num_paramsL));
if (num_paramsL<streamIndexDes || num_paramsL < streamIndexSrc)
{
return A_Err_PARAMETER;
}else
{
A_Err err2 = A_Err_NONE;
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,streamIndexSrc, &streamSrcH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,streamIndexDes, &streamDesH));
if(streamSrcH != NULL && streamDesH != NULL)
{
A_long srcKFs = 0;
ERR(suites.KeyframeSuite4()->AEGP_GetStreamNumKFs(streamSrcH,&srcKFs));
if(startFrameIndex > srcKFs)
{
err = A_Err_PARAMETER;
}
else
{
if(startFrameIndex < 0)
{
startFrameIndex = 0;
}
if(EndFrameIndex == -1 || EndFrameIndex > srcKFs)
{
EndFrameIndex = srcKFs - 1;
}
AEGP_LTimeMode timeMode = AEGP_LTimeMode_LayerTime;
A_Time timeKf;
A_long preIndex = -1;
A_long indexPL = 0;
A_short t_dimPSSrc = 0;
A_short t_dimPSDes = 0;
AEGP_StreamValue2 valueP;
A_Boolean needReleaseTan = false;
AEGP_StreamValue2 in_tanP0;
AEGP_StreamValue2 out_tanP0;
AEGP_KeyframeEase prein_easeP0;
AEGP_KeyframeEase preout_easeP0;
AEGP_KeyframeEase in_easeP0;
AEGP_KeyframeEase out_easeP0;
AEGP_KeyframeFlags flagsP;
AEGP_KeyframeInterpolationType inP0;
AEGP_KeyframeInterpolationType outP0;
{
A_FpLong timeStartFP;
A_FpLong timeEndFP;
A_long delStartIndex = -1,delEndIndex = -1;
GetTimeFromKFIndex(pEffectName,streamIndexSrc,startFrameIndex,EndFrameIndex,timeStartFP,timeEndFP);
GetIndexFromKFTime(pEffectName,streamIndexDes,timeStartFP,FALSE,timeEndFP,FALSE,delStartIndex,delEndIndex);
if(delStartIndex != -1 && delEndIndex != -1)
{
A_long delCount = delEndIndex - delStartIndex + 1;
A_long delIndex = delEndIndex;
// AEGP_AddKeyframesInfoH tempH;
// ERR(suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamDesH,&tempH));
// if(tempH != NULL)
// {
// while(delIndex >= delStartIndex)
// {
// ERR(suites.KeyframeSuite4()->AEGP_DeleteKeyframe(streamDesH,delIndex));
// delIndex--;
// }
// ERR(suites.KeyframeSuite4()->AEGP_EndAddKeyframes(FALSE,tempH));
// }
while(delIndex >= delStartIndex)
{
ERR(suites.KeyframeSuite4()->AEGP_DeleteKeyframe(streamDesH,delIndex));
delIndex--;
}
while(delCount > 0)
{
ERR(suites.KeyframeSuite4()->AEGP_DeleteKeyframe(streamDesH,delStartIndex));
delCount--;
}
}
}
AEGP_AddKeyframesInfoH addKFSH;
std::vector<CopyKeyframeInfo> vecCopyKeyframes;
ERR(suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamDesH,&addKFSH));
if(addKFSH != NULL)
{
for(A_long index = startFrameIndex;index <= EndFrameIndex;index++)
{
needReleaseTan = false;
ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeTime(streamSrcH,index,timeMode,&timeKf));
ERR(suites.KeyframeSuite4()->AEGP_GetNewKeyframeValue(S_my_id,streamSrcH,index,&valueP));
ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeFlags(streamSrcH,index,&flagsP));
ERR(suites.KeyframeSuite4()->AEGP_GetStreamTemporalDimensionality(streamSrcH,&t_dimPSSrc));
ERR(suites.KeyframeSuite4()->AEGP_GetStreamTemporalDimensionality(streamDesH,&t_dimPSDes));
if(t_dimPSSrc != t_dimPSDes)
{
err = A_Err_PARAMETER;
ERR(suites.StreamSuite3()->AEGP_DisposeStreamValue(&valueP));
break;
}
AEFX_CLR_STRUCT(in_easeP0);
AEFX_CLR_STRUCT(out_easeP0);
ERR(suites.KeyframeSuite3()->AEGP_GetKeyframeTemporalEase(streamSrcH,index,0,&in_easeP0,&out_easeP0));
if( (flagsP & AEGP_KeyframeFlag_SPATIAL_CONTINUOUS) || (flagsP &AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER) )
{
needReleaseTan = true;
ERR(suites.KeyframeSuite4()->AEGP_GetNewKeyframeSpatialTangents(S_my_id,streamSrcH,index,&in_tanP0,&out_tanP0));
}
ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeInterpolation(streamSrcH,index,&inP0,&outP0));
ERR(suites.KeyframeSuite4()->AEGP_AddKeyframes(addKFSH,timeMode,&timeKf,&indexPL));
ERR(suites.KeyframeSuite4()->AEGP_SetAddKeyframe(addKFSH,indexPL,&valueP));
ERR(suites.StreamSuite3()->AEGP_DisposeStreamValue(&valueP));
CopyKeyframeInfo info;
info.Init();
info.index = indexPL;
info.preIndex = preIndex;
info.flagsP = flagsP;
info.bStreamValue2Valid = needReleaseTan;
info.in_tanP0 = in_tanP0;
info.out_tanP0 = out_tanP0;
info.in_easeP0 = in_easeP0;
info.out_easeP0 = out_easeP0;
info.inP0 = inP0;
info.outP0 = outP0;
info.prein_easeP0 = prein_easeP0;
info.preout_easeP0 = preout_easeP0;
vecCopyKeyframes.push_back(info);
preIndex = indexPL;
prein_easeP0 = in_easeP0;
preout_easeP0 = out_easeP0;
}
ERR(suites.KeyframeSuite4()->AEGP_EndAddKeyframes(TRUE,addKFSH));
}
for(std::vector<CopyKeyframeInfo>::iterator it = vecCopyKeyframes.begin();it != vecCopyKeyframes.end();it++)
{
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesH,it->index,AEGP_KeyframeFlag_TEMPORAL_AUTOBEZIER,it->flagsP & AEGP_KeyframeFlag_TEMPORAL_AUTOBEZIER));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesH,it->index,AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER,it->flagsP & AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesH,it->index,AEGP_KeyframeFlag_TEMPORAL_CONTINUOUS,it->flagsP & AEGP_KeyframeFlag_TEMPORAL_CONTINUOUS));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesH,it->index,AEGP_KeyframeFlag_SPATIAL_CONTINUOUS,it->flagsP & AEGP_KeyframeFlag_SPATIAL_CONTINUOUS));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesH,it->index,AEGP_KeyframeFlag_ROVING,it->flagsP & AEGP_KeyframeFlag_ROVING));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeInterpolation(streamDesH,it->index,it->inP0,it->outP0));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeTemporalEase(streamDesH,it->index,0,&it->in_easeP0,&it->out_easeP0));
if( (it->flagsP & AEGP_KeyframeFlag_SPATIAL_CONTINUOUS) || (it->flagsP &AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER) )
{
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeSpatialTangents(streamDesH,it->index,&it->in_tanP0,&it->out_tanP0));
}
if(it->preIndex != -1)
{
ERR(suites.KeyframeSuite3()->AEGP_SetKeyframeTemporalEase(streamDesH,it->preIndex,0,&it->prein_easeP0,&it->preout_easeP0));
}
if(it->bStreamValue2Valid)
{
ERR(suites.StreamSuite3()->AEGP_DisposeStreamValue(&it->in_tanP0));
ERR(suites.StreamSuite3()->AEGP_DisposeStreamValue(&it->out_tanP0));
}
}
vecCopyKeyframes.clear();
}
ERR(suites.StreamSuite2()->AEGP_DisposeStream(streamSrcH));
ERR(suites.StreamSuite2()->AEGP_DisposeStream(streamDesH));
}
else
{
err = A_Err_PARAMETER;
}
}
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effectH));
break;
}
}
}
if(bFindQscEffect)
break;
}
break;
}
err = suites.ItemSuite8()->AEGP_GetNextProjItem(proj,itemH,&itemH);
}
return err;
}
Copy link to clipboard
Copied
static A_Err GenerateVibration(A_char * pEffectName,A_long startFrameIndex,A_long EndFrameIndex)
{
A_Err err = A_Err_NONE;
if(-1 == startFrameIndex || -1 == EndFrameIndex || startFrameIndex == EndFrameIndex)
{
return A_Err_PARAMETER;
}
AEGP_SuiteHandler suites(sP);
AEGP_ErrReportState errorState;
ERR(suites.UtilitySuite5()->AEGP_StartQuietErrors(&errorState));
AEGP_LayerH layerH = NULL;
A_long num_effectsL =0;
A_long num_paramsL = 0;
A_char type_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
A_char effect_nameAC[AEGP_MAX_ITEM_NAME_SIZE] = {'\0'};
AEGP_EffectRefH effectH = NULL;
AEGP_StreamRefH streamSrcBackLeftH = NULL;
AEGP_StreamRefH streamSrcBackRightH = NULL;
AEGP_StreamRefH streamSrcFrontCenterH = NULL;
AEGP_StreamRefH streamAmpH = NULL;
AEGP_StreamRefH streamFreqH = NULL;
AEGP_StreamRefH streamVibrateModeH = NULL;
AEGP_StreamRefH streamDesBackLeftH = NULL;
AEGP_StreamRefH streamDesBackRightH = NULL;
AEGP_StreamRefH streamDesFrontCenterH = NULL;
AEGP_ProjectH proj;
ERR(suites.ProjSuite6()->AEGP_GetProjectByIndex(0,&proj));
AEGP_ItemH itemH;
AEGP_ItemType itemType;
ERR(suites.ItemSuite8()->AEGP_GetFirstProjItem(proj,&itemH));
while(err == PF_Err_NONE && itemH != NULL)
{
ERR(suites.ItemSuite6()->AEGP_GetItemName(itemH,type_nameAC));
ERR(suites.ItemSuite6()->AEGP_GetItemType(itemH,&itemType));
if(itemType == AEGP_ItemType_COMP)
{
//composition
std::string strCompName = "QSC";
std::string strTemp = type_nameAC;
if(strCompName.compare(strTemp.c_str()) != 0)
continue;
A_long numLayers;
AEGP_CompH compH;
AEGP_LayerH layerH;
A_Boolean bFindQscEffect = FALSE;
suites.CompSuite8()->AEGP_GetCompFromItem(itemH,&compH);
suites.LayerSuite7()->AEGP_GetCompNumLayers(compH,&numLayers);
for(A_long index = 0;index < numLayers;index++)
{
suites.LayerSuite7()->AEGP_GetCompLayerByIndex(compH,index,&layerH);
if(layerH != NULL)
{
ERR(suites.EffectSuite2()->AEGP_GetLayerNumEffects(layerH, &num_effectsL));//得到效果插件个数
for (A_long jL = 0; !err && jL < num_effectsL; jL++)
{
ERR(suites.EffectSuite2()->AEGP_GetLayerEffectByIndex(S_my_id, layerH, jL, &effectH));
if (!err && effectH)
{
AEGP_InstalledEffectKey key;
ERR(suites.EffectSuite2()->AEGP_GetInstalledKeyFromLayerEffect(effectH, &key));
ERR(suites.EffectSuite2()->AEGP_GetEffectName(key, effect_nameAC));
std::string strEffectName = pEffectName;
std::string strTemp = effect_nameAC;
if(strEffectName.compare(strTemp.c_str()) != 0)
{
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effectH));
continue;
}
bFindQscEffect = TRUE;
ERR(suites.StreamSuite2()->AEGP_GetEffectNumParamStreams(effectH, &num_paramsL));
if (num_paramsL != FEATHER_Count)
{
ERR(suites.UtilitySuite5()->AEGP_EndQuietErrors(TRUE,&errorState));
return A_Err_NONE;
}else
{
A_Err err2 = A_Err_NONE;
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_ID1, &streamSrcBackLeftH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_ID2, &streamSrcFrontCenterH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_ID3, &streamSrcBackRightH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_Amp, &streamAmpH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_Freq, &streamFreqH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_DISK_VibrateMode, &streamVibrateModeH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_BackLeft, &streamDesBackLeftH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_FrontCenter, &streamDesFrontCenterH));
ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(S_my_id, effectH,FEATHER_BackRight, &streamDesBackRightH));
if(streamSrcBackLeftH != NULL && streamSrcFrontCenterH != NULL && streamSrcBackRightH != NULL && streamAmpH != NULL &&
streamFreqH != NULL && streamVibrateModeH != NULL && streamDesBackLeftH != NULL && streamDesBackRightH != NULL && streamDesFrontCenterH != NULL)
{
A_long freqKFs = 0;
ERR(suites.KeyframeSuite4()->AEGP_GetStreamNumKFs(streamFreqH,&freqKFs));
if(startFrameIndex > freqKFs)
{
err = A_Err_PARAMETER;
}
else
{
if(startFrameIndex < 0)
{
startFrameIndex = 0;
}
if(EndFrameIndex == -1 || EndFrameIndex > freqKFs)
{
EndFrameIndex = freqKFs;
}
AEGP_LTimeMode timeMode = AEGP_LTimeMode_LayerTime;
A_Time timeKf;
A_Time timeKfNext;
// A_Time timeKfFirst;
// A_Time timeKfLast;
A_long preInterpIndexBackleft = -1;
A_long preInterpIndexBackRight = -1;
A_long preInterpIndexFrontCenter = -1;
A_long indexPLBackLeft = 0;
A_long indexPLBackRight = 0;
A_long indexPLFrontCenter = 0;
AEGP_StreamType stream_type;
AEGP_StreamValue2 valueFreq;
AEGP_KeyframeEase in_easeP0BackLeft;
AEGP_KeyframeEase out_easeP0BackLeft;
AEGP_KeyframeEase in_easeP0BackRight;
AEGP_KeyframeEase out_easeP0BackRight;
AEGP_KeyframeEase in_easeP0FrontCenter;
AEGP_KeyframeEase out_easeP0FrontCenter;
AEGP_KeyframeInterpolationType inPNone = AEGP_KeyInterp_NONE;
AEGP_KeyframeInterpolationType inPLine = AEGP_KeyInterp_LINEAR;
AEGP_KeyframeInterpolationType inPBezier = AEGP_KeyInterp_BEZIER;
AEGP_KeyframeInterpolationType inPTemp = AEGP_KeyInterp_BEZIER;
AEGP_KeyframeInterpolationType outPTemp = AEGP_KeyInterp_BEZIER;
AEGP_StreamValue2 valueAmpBackLeft;
AEGP_StreamValue2 valueAmpBackRight;
AEGP_StreamValue2 valueAmpFrontCenter;
AEGP_StreamValue2 valueDesBackLeft;
AEGP_StreamValue2 valueDesBackRight;
AEGP_StreamValue2 valueDesFrontCenter;
A_Boolean pre_expressionB = TRUE;
A_FpLong dpBackLeft = 0.0;
A_FpLong dpBackRight = 0.0;
A_FpLong dpFrontCenter = 0.0;
A_long vibrateMode = 0;
A_FpLong InsertKeyFrameMinGap = 0.0;
bool positive = true;
// ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeTime(streamFreqH,startFrameIndex,timeMode,&timeKfFirst));
// ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeTime(streamFreqH,EndFrameIndex,timeMode,&timeKfLast));
for(A_long index = startFrameIndex;index < EndFrameIndex;index++)
{
ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeTime(streamFreqH,index,timeMode,&timeKf));
ERR(suites.KeyframeSuite4()->AEGP_GetKeyframeTime(streamFreqH,index+1,timeMode,&timeKfNext));
if( (timeKf.scale != timeKfNext.scale) && (timeKf.scale != 0) )
{
A_FpLong temp = (A_FpLong)timeKf.value/timeKf.scale;
timeKf.scale = timeKfNext.scale;
timeKf.value = temp*timeKfNext.scale;
}
AEGP_StreamValue val;
AEGP_StreamValue *sample_valP = &val;
AEGP_StreamType stream_typeVibMode;
ERR(suites.StreamSuite2()->AEGP_GetStreamType(streamVibrateModeH, &stream_typeVibMode));
if (AEGP_StreamType_NO_DATA != stream_typeVibMode)
{
ERR(suites.StreamSuite2()->AEGP_GetNewStreamValue(S_my_id,
streamVibrateModeH,
AEGP_LTimeMode_LayerTime,
&timeKf,
pre_expressionB,
sample_valP));
if(AEGP_StreamType_OneD == stream_typeVibMode)
{
vibrateMode = sample_valP->val.one_d;
if(vibrateMode > ViarateMode_RotateAntiClockWise || vibrateMode < ViarateMode_UpDown)
{
vibrateMode = ViarateMode_UpDown;
}
}
ERR(suites.StreamSuite2()->AEGP_DisposeStreamValue(sample_valP));
}
A_long tempIndex = 0;
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesBackLeftH,timeMode,&timeKf,&tempIndex));
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesBackRightH,timeMode,&timeKf,&tempIndex));
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesFrontCenterH,timeMode,&timeKf,&tempIndex));
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesBackLeftH,timeMode,&timeKfNext,&tempIndex));
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesBackRightH,timeMode,&timeKfNext,&tempIndex));
ERR(suites.KeyframeSuite4()->AEGP_InsertKeyframe(streamDesFrontCenterH,timeMode,&timeKfNext,&tempIndex));
std::vector<InsertedKeyframeInfo> vecBackLeftKeyframes;
std::vector<InsertedKeyframeInfo> vecBackRightKeyframes;
std::vector<InsertedKeyframeInfo> vecFrontCenterKeyframes;
AEGP_AddKeyframesInfoH addBackLeftKeyframesInfoH = NULL;
AEGP_AddKeyframesInfoH addBackRightKeyframesInfoH = NULL;
AEGP_AddKeyframesInfoH addFrontCenterKeyframesInfoH = NULL;
suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamDesBackLeftH, &addBackLeftKeyframesInfoH);
suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamDesBackRightH, &addBackRightKeyframesInfoH);
suites.KeyframeSuite4()->AEGP_StartAddKeyframes(streamDesFrontCenterH, &addFrontCenterKeyframesInfoH);
ERR(suites.KeyframeSuite4()->AEGP_GetNewKeyframeValue(S_my_id,streamFreqH,index,&valueFreq));
ERR(suites.StreamSuite2()->AEGP_GetStreamType(streamFreqH, &stream_type));
InsertKeyFrameMinGap = (A_FpLong)timeKf.scale/100;
timeKf.value += InsertKeyFrameMinGap;
timeKfNext.value -= InsertKeyFrameMinGap;
A_FpLong timeSeconds = (A_FpLong)timeKfNext.value/timeKfNext.scale - (A_FpLong)timeKf.value/timeKf.scale;
A_long needKeyFramePerSecond = 0;
A_long needKeyFrameTotal = 0;
A_FpLong timeSampGap = 0.0;
A_FpLong timeDPBackLeftOffset = 0.0;
A_FpLong timeDPBackRightOffset = 0.0;
A_FpLong timeDPFrontCenterOffset = 0.0;
A_Time timeInsertKFBackLeft;
A_Time timeInsertKFBackLeftPre;
A_Time timeInsertKFBackRight;
A_Time timeInsertKFBackRightPre;
A_Time timeInsertKFFrontCenter;
timeInsertKFBackLeft = timeKf;
timeInsertKFBackLeftPre = timeKf;
timeInsertKFBackRight = timeKf;
timeInsertKFBackRightPre = timeKf;
timeInsertKFFrontCenter = timeKf;
needKeyFramePerSecond = (A_FpLong)valueFreq.val.one_d*2;
needKeyFrameTotal = needKeyFramePerSecond*timeSeconds;
timeSampGap = (A_FpLong)1/(A_FpLong)needKeyFramePerSecond*timeKf.scale;
dpBackLeft = dpModeArray[vibrateMode].dpBL;
dpBackRight = dpModeArray[vibrateMode].dpBR;
dpFrontCenter = dpModeArray[vibrateMode].dpFC;
timeDPBackLeftOffset = ((A_FpLong)1/needKeyFramePerSecond*timeKf.scale)*dpBackLeft*2;
timeDPBackRightOffset = ((A_FpLong)1/needKeyFramePerSecond*timeKf.scale)*dpBackRight*2;
timeDPFrontCenterOffset = ((A_FpLong)1/needKeyFramePerSecond*timeKf.scale)*dpFrontCenter*2;
if(valueFreq.val.one_d < 1.0)
{
ERR(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueFreq));
continue;
}
else
{
if(AEGP_StreamType_OneD == stream_type)
{
A_FpLong nextCheckVibModeTime = 0.0;
while( (timeInsertKFBackLeft.value <= timeKfNext.value) && (timeInsertKFBackRight.value <= timeKfNext.value) &&
(timeInsertKFFrontCenter.value <= timeKfNext.value) )
{
A_long maxTime = 0;
if(timeInsertKFBackLeft.value > timeInsertKFBackRight.value)
{
maxTime = timeInsertKFBackLeft.value;
}
else
{
maxTime = timeInsertKFBackRight.value;
}
if(maxTime < timeInsertKFFrontCenter.value)
{
maxTime = timeInsertKFFrontCenter.value;
}
maxTime += timeSampGap;
if(maxTime > timeKfNext.value)
break;
outPTemp = inPTemp = inPBezier;
if(timeInsertKFBackLeft.value == timeKf.value)
{
timeInsertKFBackLeft.value += timeDPBackLeftOffset;
timeInsertKFBackRight.value += timeDPBackRightOffset;
timeInsertKFFrontCenter.value += timeDPFrontCenterOffset;
}
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamSrcBackLeftH,timeMode,&timeInsertKFBackLeft,pre_expressionB,&valueDesBackLeft));
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamSrcBackRightH,timeMode,&timeInsertKFBackRight,pre_expressionB,&valueDesBackRight));
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamSrcFrontCenterH,timeMode,&timeInsertKFFrontCenter,pre_expressionB,&valueDesFrontCenter));
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamAmpH,timeMode,&timeInsertKFBackLeft,pre_expressionB,&valueAmpBackLeft));
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamAmpH,timeMode,&timeInsertKFBackRight,pre_expressionB,&valueAmpBackRight));
ERR(suites.StreamSuite3()->AEGP_GetNewStreamValue(S_my_id,streamAmpH,timeMode,&timeInsertKFFrontCenter,pre_expressionB,&valueAmpFrontCenter));
if(!positive)
{
valueDesBackLeft.val.one_d = valueDesBackLeft.val.one_d + valueAmpBackLeft.val.one_d;
valueDesBackRight.val.one_d = valueDesBackRight.val.one_d + valueAmpBackRight.val.one_d;
if(vibrateMode == ViarateMode_RotateAntiClockWise || vibrateMode == ViarateMode_RotateClockWise)
valueDesFrontCenter.val.one_d = valueDesFrontCenter.val.one_d + valueAmpFrontCenter.val.one_d/2;
else
valueDesFrontCenter.val.one_d = valueDesFrontCenter.val.one_d + valueAmpFrontCenter.val.one_d;
}
else
{
valueDesBackLeft.val.one_d = valueDesBackLeft.val.one_d - valueAmpBackLeft.val.one_d;
valueDesBackRight.val.one_d = valueDesBackRight.val.one_d - valueAmpBackRight.val.one_d;
if(vibrateMode == ViarateMode_RotateAntiClockWise || vibrateMode == ViarateMode_RotateClockWise)
valueDesFrontCenter.val.one_d = valueDesFrontCenter.val.one_d - valueAmpFrontCenter.val.one_d/2;
else
valueDesFrontCenter.val.one_d = valueDesFrontCenter.val.one_d - valueAmpFrontCenter.val.one_d;
}
positive = !positive;
if(dpBackLeft >= 0)
{
if((timeInsertKFBackLeft.value - timeKf.value) > InsertKeyFrameMinGap)
{
ERR(suites.KeyframeSuite4()->AEGP_AddKeyframes(addBackLeftKeyframesInfoH,timeMode,&timeInsertKFBackLeft,&indexPLBackLeft));
ERR(suites.KeyframeSuite4()->AEGP_SetAddKeyframe(addBackLeftKeyframesInfoH, indexPLBackLeft, &valueDesBackLeft));
InsertedKeyframeInfo info;
info.index = indexPLBackLeft;
info.value = valueDesBackLeft.val.one_d;
vecBackLeftKeyframes.push_back(info);
timeInsertKFBackLeftPre = timeInsertKFBackLeft;
preInterpIndexBackleft = indexPLBackLeft;
}
timeInsertKFBackLeft.value += timeSampGap;
}
if(dpBackRight >= 0)
{
if((timeInsertKFBackRight.value - timeKf.value) > InsertKeyFrameMinGap)
{
ERR(suites.KeyframeSuite4()->AEGP_AddKeyframes(addBackRightKeyframesInfoH,timeMode,&timeInsertKFBackRight,&indexPLBackRight));
ERR(suites.KeyframeSuite4()->AEGP_SetAddKeyframe(addBackRightKeyframesInfoH, indexPLBackRight, &valueDesBackRight));
InsertedKeyframeInfo info;
info.index = indexPLBackRight;
info.value = valueDesBackRight.val.one_d;
vecBackRightKeyframes.push_back(info);
timeInsertKFBackRightPre = timeInsertKFBackRight;
preInterpIndexBackRight = indexPLBackRight;
}
timeInsertKFBackRight.value += timeSampGap;
}
if(dpFrontCenter >= 0)
{
if((timeInsertKFFrontCenter.value - timeKf.value) > InsertKeyFrameMinGap)
{
ERR(suites.KeyframeSuite4()->AEGP_AddKeyframes(addFrontCenterKeyframesInfoH,timeMode,&timeInsertKFFrontCenter,&indexPLFrontCenter));
ERR(suites.KeyframeSuite4()->AEGP_SetAddKeyframe(addFrontCenterKeyframesInfoH, indexPLFrontCenter, &valueDesFrontCenter));
InsertedKeyframeInfo info;
info.index = indexPLFrontCenter;
info.value = valueDesFrontCenter.val.one_d;
vecFrontCenterKeyframes.push_back(info);
preInterpIndexFrontCenter = indexPLFrontCenter;
}
timeInsertKFFrontCenter.value += timeSampGap;
}
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueDesBackLeft));
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueDesBackRight));
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueDesFrontCenter));
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueAmpBackLeft));
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueAmpBackRight));
ERR2(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueAmpFrontCenter));
}
}
ERR(suites.StreamSuite4()->AEGP_DisposeStreamValue(&valueFreq));
}
suites.KeyframeSuite4()->AEGP_EndAddKeyframes(TRUE, addBackLeftKeyframesInfoH);
suites.KeyframeSuite4()->AEGP_EndAddKeyframes(TRUE, addBackRightKeyframesInfoH);
suites.KeyframeSuite4()->AEGP_EndAddKeyframes(TRUE, addFrontCenterKeyframesInfoH);
for(std::vector<InsertedKeyframeInfo>::iterator it = vecBackLeftKeyframes.begin();it != vecBackLeftKeyframes.end();it++)
{
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackLeftH,it->index,AEGP_KeyframeFlag_TEMPORAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackLeftH,it->index,AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackLeftH,it->index,AEGP_KeyframeFlag_TEMPORAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackLeftH,it->index,AEGP_KeyframeFlag_SPATIAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackLeftH,it->index,AEGP_KeyframeFlag_ROVING,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeInterpolation(streamDesBackLeftH,it->index,inPTemp,outPTemp));
in_easeP0BackLeft.speedF = 0.0;
in_easeP0BackLeft.influenceF = VibrateInfluenceF;
out_easeP0BackLeft.speedF = 0.0;
out_easeP0BackLeft.influenceF = VibrateInfluenceF;
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeTemporalEase(streamDesBackLeftH,it->index,0,&in_easeP0BackLeft,&out_easeP0BackLeft));
}
vecBackLeftKeyframes.clear();
for(std::vector<InsertedKeyframeInfo>::iterator it = vecBackRightKeyframes.begin();it != vecBackRightKeyframes.end();it++)
{
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackRightH,it->index,AEGP_KeyframeFlag_TEMPORAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackRightH,it->index,AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackRightH,it->index,AEGP_KeyframeFlag_TEMPORAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackRightH,it->index,AEGP_KeyframeFlag_SPATIAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesBackRightH,it->index,AEGP_KeyframeFlag_ROVING,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeInterpolation(streamDesBackRightH,it->index,inPTemp,outPTemp));
in_easeP0BackRight.speedF = 0.0;
in_easeP0BackRight.influenceF = VibrateInfluenceF;
out_easeP0BackRight.speedF = 0.0;
out_easeP0BackRight.influenceF = VibrateInfluenceF;
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeTemporalEase(streamDesBackRightH,it->index,0,&in_easeP0BackRight,&out_easeP0BackRight));
}
vecBackRightKeyframes.clear();
for(std::vector<InsertedKeyframeInfo>::iterator it = vecFrontCenterKeyframes.begin();it != vecFrontCenterKeyframes.end();it++)
{
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesFrontCenterH,it->index,AEGP_KeyframeFlag_TEMPORAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesFrontCenterH,it->index,AEGP_KeyframeFlag_SPATIAL_AUTOBEZIER,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesFrontCenterH,it->index,AEGP_KeyframeFlag_TEMPORAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesFrontCenterH,it->index,AEGP_KeyframeFlag_SPATIAL_CONTINUOUS,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeFlag(streamDesFrontCenterH,it->index,AEGP_KeyframeFlag_ROVING,FALSE));
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeInterpolation(streamDesFrontCenterH,it->index,inPTemp,outPTemp));
in_easeP0FrontCenter.speedF = 0.0;
in_easeP0FrontCenter.influenceF = VibrateInfluenceF;
out_easeP0FrontCenter.speedF = 0.0;
out_easeP0FrontCenter.influenceF = VibrateInfluenceF;
ERR(suites.KeyframeSuite4()->AEGP_SetKeyframeTemporalEase(streamDesFrontCenterH,it->index,0,&in_easeP0FrontCenter,&out_easeP0FrontCenter));
}
vecFrontCenterKeyframes.clear();
}
}
}
else
{
err = A_Err_PARAMETER;
}
if(streamSrcBackLeftH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamSrcBackLeftH));
if(streamSrcFrontCenterH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamSrcFrontCenterH));
if(streamSrcBackRightH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamSrcBackRightH));
if(streamAmpH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamAmpH));
if(streamFreqH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamFreqH));
if(streamVibrateModeH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamVibrateModeH));
if(streamDesBackLeftH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamDesBackLeftH));
if(streamDesFrontCenterH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamDesFrontCenterH));
if(streamDesBackRightH != NULL)
ERR2(suites.StreamSuite2()->AEGP_DisposeStream(streamDesBackRightH));
}
ERR(suites.EffectSuite2()->AEGP_DisposeEffect(effectH));
break;
}
}
}
if(bFindQscEffect)
break;
}
break;
}
err = suites.ItemSuite8()->AEGP_GetNextProjItem(proj,itemH,&itemH);
}
ERR(suites.UtilitySuite5()->AEGP_EndQuietErrors(TRUE,&errorState));
return err;
}
Copy link to clipboard
Copied
in PF_Cmd_USER_CHANGED_PARAM:
CopyStream(EffectName,FEATHER_FrontCenter,FEATHER_DISK_ID2,startIndex3,endIndex3);
GenerateVibration(EffectName,startIndex,endIndex);
Copy link to clipboard
Copied
see After Effects error: Time argument is out of range. What causes this? thank shachar carmi for your help