Exemplo n.º 1
0
CKERROR MidiEventCallBack(const CKBehaviorContext& behcontext){
  CKBehavior *beh = behcontext.Behavior;
  MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );

  switch( behcontext.CallbackMessage ){
    
  case CKM_BEHAVIOREDITED:
    {
      int c_pin = beh->GetInputParameterCount();
      
      char name[20];

      CKParameterIn *pin;
      for( int a=2 ; a<c_pin ; a++){
        pin = beh->GetInputParameter(a);
        sprintf( name, "Note %d", a);
        pin->SetName( name );
        pin->SetGUID( CKPGUID_INT );
      }
    } break;
    
  case CKM_BEHAVIORATTACH:
  case CKM_BEHAVIORLOAD:
		{
			mm->AddMidiBBref();
		} break;
  case CKM_BEHAVIORDETACH:
		{
			mm->RemoveMidiBBref();
		} break;
  }
  
  return CKBR_OK; 
}
Exemplo n.º 2
0
/*
*******************************************************************
* Function: int GetCIValueCB( const CKBehaviorContext& behaviorContext )
*
* Description : The Behavior Callback function is called by Virtools when various events happen 
*               in the life of a BuildingBlock. Exactly which events trigger a call to the 
*               Behavior Callback function is defined in the Behavior Prototype, along with the 
*               declaration of the function pointer 
*
* Parameters :
*    behaviourContext    r   Behavior context reference, which gives 
*                            access to frequently used global objects 
*                            ( context, level, manager, etc... )
*
* Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values.
*
*******************************************************************
*/
CKERROR GetCIValueCB(const CKBehaviorContext& behcontext)
{
	/************************************************************************/
	/*  collecting data :													*/
	/*  																	*/
	CKBehavior *beh = behcontext.Behavior;
	CKContext* ctx = beh->GetCKContext();
	CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager());
	/************************************************************************/
	/*	process virtools callbacks		:																			*/
	/*  																														*/

	switch(behcontext.CallbackMessage)
	{
	
		
		case CKM_BEHAVIOREDITED:
		case CKM_BEHAVIORSETTINGSEDITED:
		{
	
			assert(beh && ctx);
			BOOL getByName,getAsString,outputAttriubtes,outputOnChange = false;
			beh->GetLocalParameterValue(BEH_SETTINGS_GET_BY_NAME,&getByName);
			beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString);
			beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes);
			beh->GetLocalParameterValue(BEH_SETTINGS_OUTPUT_ON_CHANGE,&outputOnChange);


			//////////////////////////////////////////////////////////////////////////
			//we add beh - in - trigger, if we are in event mode:
			if (outputOnChange)
			{
				beh->AddInput("Stop");

				//change to correct name :
			 	CKBehaviorIO * out_trigger = beh->GetOutput(0);
				out_trigger->SetName("Change detected");
			}else
			{
				//change to correct name :
				CKBehaviorIO * out_trigger = beh->GetOutput(0);
				out_trigger->SetName("Finish");
			}
              

			//remove unecessary beh - input triggers from even-mode :  
			int count = beh->GetInputCount();

			while(  (outputOnChange ? BEH_IN_TRIGGER_MAX_COUNT  : BEH_IN_TRIGGER_MIN_COUNT )  <= count ) 
						beh->DeleteInput( count-- );

			CKParameterIn *ciIn = beh->GetInputParameter(0);
			if( getByName )
			{
				ciIn->SetType(pm->ParameterGuidToType(CKPGUID_STRING));
				ciIn->SetName("unique name of the configurable information");
			}else
			{
				ciIn->SetType(pm->ParameterGuidToType(CIPARAMETERGUID));
				ciIn->SetName("Configurable Information");
			}
			
			if(outputAttriubtes)
			{
				beh->CreateOutputParameter("Default Value",CKPGUID_STRING);
                beh->CreateOutputParameter("Unique name",CKPGUID_STRING);                
				beh->CreateOutputParameter("Description",CKPGUID_STRING);
				beh->CreateOutputParameter("Runtime flags",CIPRTFLAGSGUID);
				beh->CreateOutputParameter("Type",CKPGUID_PARAMETERTYPE);

			}

			int p_count  =  beh->GetOutputParameterCount();
			while(   (outputAttriubtes ? BEH_OUT_MAX_COUNT : BEH_OUT_MIN_COUNT )   < p_count )
			{ 
				CKDestroyObject( beh->RemoveOutputParameter( --p_count) );
			}
		
			
			
		}
	}
	return CKBR_OK;
}