Beispiel #1
0
void StringFlip::onCallBack(UsineMessage *Message) 
{
	
	if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE)) // && (Message->result == 1)) //received 1 on "enable" input
	{
		if (sdkGetEvtData(m_enable) == 1)
		{
			m_textNew = sdkGetEvtPChar(m_textInput); //
			str.append(m_textNew);
			sdkSetEvtPChar(m_textOutput, (AnsiCharPtr)(str.c_str()));
			//sdkSetEvtPChar(m_textOutput, m_textNew);
		}
	}

	else if ((Message->wParam == 2) && (Message->lParam == MSG_CHANGE) ) //&& (Message->result == 1)) //received 1 on "reset" input
	{
		if (sdkGetEvtData(m_reset) == 1)
		{
			str.clear();
			sdkSetEvtPChar(m_textOutput, (AnsiCharPtr)(str.c_str()));
		}
	}
	else{}
	
}
Beispiel #2
0
//-----------------------------------------------------------------------------
// Parameters callback
void AudioVolumeExample::onCallBack (UsineMessage *Message) 
{
    // filter only message specific to this user module
    if (Message->message == NOTIFY_MSG_USINE_CALLBACK)
    {
        // Message->wParam is equal to ParamIndex
		if ((Message->wParam >= (numOfAudiotInsOuts*2)) && (Message->lParam == MSG_CHANGE))
		{
			coeffGain = (sdkGetEvtData (fdrGain)) * (1.0f - sdkGetEvtData (switchMute));
		}
    }
}
Beispiel #3
0
void AntiOPe20::onCallBack(UsineMessage *Message)
{
	
	if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (sdkGetEvtData(m_receivedSendOrder) == 1)) // && (Message->result == 1)) //received 1 on "enable" input
	{
			m_textNew = sdkGetEvtPChar(m_textInput); //
			std::string str(m_textNew);
			int firstChar(0);
			for (unsigned i = 0; i < str.length(); ++i)
			{
				char m_simplechar = str.at(i);
				if (m_simplechar == ',') {
					std::string strToSend = str.substr(firstChar, i - (1 + firstChar)); // a string between 2 commas
					firstChar = i+1; // the index of the string to start the next subtring
					sdkSetEvtPChar(m_textOutput, (AnsiCharPtr) (strToSend.c_str()));
					sdkSetEvtData(m_SendOrderToOSCModule, 1);
					//wait one cycle here
					sdkTraceChar("sending to MINITEL");
					_sleep(160);
					sdkSetEvtData(m_SendOrderToOSCModule, 0);
					}
				else{}
			}

	}

	else{}
	
}
void SimplePendulum::onCallBack(UsineMessage *Message) {
	//algo ici
	if (Message->message == NOTIFY_MSG_USINE_CALLBACK && Message->lParam == MSG_CHANGE)
	{
		switch (Message->wParam)
		{
		case 3: //reset position
			gravityAngle = sdkGetEvtData(m_resetValue) * 2 * PI;
			prev_gravityCorrection = gravityCorrection;
			gravityCorrection = gravityAngle;
			token1 = 2;
			break;

		case 4: //received clock trigger
				//evaluate the state functions
			
			float gravity = sdkGetEvtData(m_gravity);
			float friction = sdkGetEvtData(m_friction) * (1+gravity);
			
			dx[0] = (-gravity / (sdkGetEvtData(m_L1) * 1000)) * sin(dx[2]);	//acceleration
			dx[1] += dx[0];											//vitesse
			dx[1] *= (1 - friction);
			if (token1 == 2) {
				token1 = 0;
				dx[2] = dx[2] - gravityCorrection + prev_gravityCorrection;	   //angle
			}
			else {
				dx[2] += dx[1];	   //angle
			}


			float newAngle1 = dx[2] + gravityCorrection;
				sdkSetEvtData(m_M1posx, centerx + sdkGetEvtData(m_L1)*sin(newAngle1));
				sdkSetEvtData(m_M1posy, centery + sdkGetEvtData(m_L1)*cos(newAngle1));
				sdkSetEvtData(m_OffSetM1posx, centerx + 0.5f*sin(newAngle1));
				sdkSetEvtData(m_OffSetM1posy, centery + 0.5f*cos(newAngle1));

			//}
			break;
		}
	}
}
void Incrementor::onCallBack (UsineMessage *Message) 
{
	if ((Message->wParam == 0) && (Message->lParam == MSG_CHANGE))
    {
        sdkAddEvt3       (internalOutput, positiveInput, internalOutput);
		
		if (sdkGetEvtData(internalOutput) > sdkGetEvtData(resolutionInput)) 
		{
			sdkSetEvtData(internalOutput, 0);
		}
		else if (sdkGetEvtData(internalOutput) < 0)
		{
			sdkSetEvtData(internalOutput, sdkGetEvtData(resolutionInput));
		}
		sdkDivEvt3       (internalOutput, resolutionInput, output);
    }

    if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE))
    {
        sdkSubEvt3       (internalOutput, minusInput, internalOutput);

		if (sdkGetEvtData(internalOutput) > sdkGetEvtData(resolutionInput)) 
		{
			sdkSetEvtData(internalOutput, sdkGetEvtData(resolutionInput));
		}
		else if (sdkGetEvtData(internalOutput) < 0) 
		{
			sdkSetEvtData(internalOutput, 0);
		}
		sdkDivEvt3       (internalOutput, resolutionInput, output);
    }

    if (((Message->wParam == 2) || (Message->wParam == 3)) && (Message->lParam == MSG_CHANGE))
    {
		if (sdkGetEvtData(resetValueInput) > sdkGetEvtData(resolutionInput)) 
		{
            sdkSetEvtData(resetValueInput, sdkGetEvtData(resolutionInput));
		}
	}
	if ((Message->wParam == 4) && (Message->lParam == MSG_CHANGE))
    {
		if (sdkGetEvtData(resetValueInput) > sdkGetEvtData(resolutionInput)) 
		{
            sdkSetEvtData(resetValueInput, sdkGetEvtData(resolutionInput));
		}
		sdkSetEvtData(internalOutput, sdkGetEvtData(resetValueInput));
		sdkDivEvt3       (internalOutput, resolutionInput, output);
    }

}
void TemplateModule::onProcess () {

	if(sdkGetEvtData(params[eRate]) == eControl){
		float data;
		if(sdkGetEvtData(params[eMax]) > sdkGetEvtData(params[eMin])){
		    data = distribution.value(sdkGetEvtData(params[eMin]), sdkGetEvtData(params[eMax]), 128);
		    if(data == 0.0f){
			    data = sdkGetEvtData(params[eMin]);
		    }
		}else{
		    data = 0.f;
		}
	    sdkSetEvtSize(params[eOut], 1);
		sdkSetEvtData(params[eOut], data);
	}else if (sdkGetEvtData(params[eRate]) == eAudio){
		int sampleFrames = sdkGetBlocSize();
		sdkSetEvtSize(params[eOut], sampleFrames);
		for (int i = 0; i < sampleFrames; i++){
			float data;
		    if(sdkGetEvtData(params[eMax]) > sdkGetEvtData(params[eMin])){
		        data = distribution.value(sdkGetEvtData(params[eMin]), sdkGetEvtData(params[eMax]), 128);
		        if(data == 0.0f){
			        data = sdkGetEvtData(params[eMin]);
		        }
		    }else{
		        data = 0.f;
		    }
			sdkSetEvtArrayData(params[eOut], i, data);
		}
	}
}
void TemplateModule::onCallBack (UsineMessage *Message) {

	switch (Message->wParam) 
	{
	case eRate:
		rate = (int)sdkGetEvtData(params[eRate]);
		break;
	case eTrigger:
		if(Message->lParam == MSG_CHANGE && sdkGetEvtData(params[eRate]) == eButton){
			float data;
		    if(sdkGetEvtData(params[eMax]) > sdkGetEvtData(params[eMin])){
		        data = distribution.value(sdkGetEvtData(params[eMin]), sdkGetEvtData(params[eMax]), 128);
		        if(data == 0.0f){
			        data = sdkGetEvtData(params[eMin]);
		        }
		    }else{
		        data = 0.f;
		    }
			sdkSetEvtSize(params[eOut], 1);
			sdkSetEvtData(params[eOut], data);
		} 
		break;
	case eOut:
		//params[eOut] = pEvent;
		break;
	case eParamA:
		distribution.doBilateral(sdkGetEvtData(params[eParamA]));
		distribution.doExponential(sdkGetEvtData(params[eParamA]) * 5.f);
		distribution.doCauchy(sdkGetEvtData(params[eParamA]), sdkGetEvtData(params[eParamB]));
		distribution.doGaussian(sdkGetEvtData(params[eParamA]), sdkGetEvtData(params[eParamB]));
		distribution.doWeibull((sdkGetEvtData(params[eParamA]) * 0.99f) + 0.01, sdkGetEvtData(params[eParamB]));
		switch((int)sdkGetEvtData(params[eType])){
		    case 0: distribution.setType(UNIFORM);break;
			case 1: distribution.setType(LINEAR);break;
			case 2: distribution.setType(TRIANGULAR);break;
			case 3: distribution.setType(EXPONENTIAL);break;
			case 4: distribution.setType(BILATERAL);break;
			case 5: distribution.setType(GAUSSIAN);break;
			case 6: distribution.setType(CAUCHY);break;
			case 7: distribution.setType(WEIBULL);break;
			default: distribution.setType(UNIFORM);break;
		}
		break;
	case eParamB:
		distribution.doCauchy(sdkGetEvtData(params[eParamA]), sdkGetEvtData(params[eParamB]));
		distribution.doGaussian(sdkGetEvtData(params[eParamA]), sdkGetEvtData(params[eParamB]));
		distribution.doWeibull((sdkGetEvtData(params[eParamA]) * 0.99f) + 0.01, sdkGetEvtData(params[eParamB]));
		switch((int)sdkGetEvtData(params[eType])){
		    case 0: distribution.setType(UNIFORM);break;
			case 1: distribution.setType(LINEAR);break;
			case 2: distribution.setType(TRIANGULAR);break;
			case 3: distribution.setType(EXPONENTIAL);break;
			case 4: distribution.setType(BILATERAL);break;
			case 5: distribution.setType(GAUSSIAN);break;
			case 6: distribution.setType(CAUCHY);break;
			case 7: distribution.setType(WEIBULL);break;
			default: distribution.setType(UNIFORM);break;
		}
		break;
	case eType:
		switch((int)sdkGetEvtData(params[eType])){
		    case 0: distribution.setType(UNIFORM);break;
			case 1: distribution.setType(LINEAR);break;
			case 2: distribution.setType(TRIANGULAR);break;
			case 3: distribution.setType(EXPONENTIAL);break;
			case 4: distribution.setType(BILATERAL);break;
			case 5: distribution.setType(GAUSSIAN);break;
			case 6: distribution.setType(CAUCHY);break;
			case 7: distribution.setType(WEIBULL);break;
			default: distribution.setType(UNIFORM);break;
		}
		break;
	case eMin:
		if(sdkGetEvtData(params[eMax]) > sdkGetEvtData(params[eMin])){
			float temp = sdkGetEvtData(params[eMin]) + ((sdkGetEvtData(params[eMax]) - sdkGetEvtData(params[eMin])) * 0.5f);
			distribution.doTriangular(sdkGetEvtData(params[eMin]), temp, sdkGetEvtData(params[eMax]));
			distribution.doUniform(sdkGetEvtData(params[eMin]), sdkGetEvtData(params[eMax]));
		}
		switch((int)sdkGetEvtData(params[eType])){
		    case 0: distribution.setType(UNIFORM);break;
			case 1: distribution.setType(LINEAR);break;
			case 2: distribution.setType(TRIANGULAR);break;
			case 3: distribution.setType(EXPONENTIAL);break;
			case 4: distribution.setType(BILATERAL);break;
			case 5: distribution.setType(GAUSSIAN);break;
			case 6: distribution.setType(CAUCHY);break;
			case 7: distribution.setType(WEIBULL);break;
			default: distribution.setType(UNIFORM);break;
		}
		break;
	case eMax:
		if(sdkGetEvtData(params[eMax]) > sdkGetEvtData(params[eMin])){
			float temp = sdkGetEvtData(params[eMin]) + ((sdkGetEvtData(params[eMax]) - sdkGetEvtData(params[eMin])) * 0.5f);
			distribution.doTriangular(sdkGetEvtData(params[eMin]), temp, sdkGetEvtData(params[eMax]));
			distribution.doUniform(sdkGetEvtData(params[eMin]), sdkGetEvtData(params[eMax]));
		}
		switch((int)sdkGetEvtData(params[eType])){
		    case 0: distribution.setType(UNIFORM);break;
			case 1: distribution.setType(LINEAR);break;
			case 2: distribution.setType(TRIANGULAR);break;
			case 3: distribution.setType(EXPONENTIAL);break;
			case 4: distribution.setType(BILATERAL);break;
			case 5: distribution.setType(GAUSSIAN);break;
			case 6: distribution.setType(CAUCHY);break;
			case 7: distribution.setType(WEIBULL);break;
			default: distribution.setType(UNIFORM);break;
		}
		break;

		// default case
	default:
		break;
	}
}