#include "guimodule.h" #include "it_enum_list.h" #define PN_IN 0 #define PN_IN2 1 #define PN_OUT 2 #define PN_OUT2 3 GuiModule::GuiModule(seGuiCallback seaudioMaster, void *p_resvd1) : SEGUI_base(seaudioMaster, p_resvd1) { lastpin = 1; imChanged = false; // pay attention to pins now } void GuiModule::OnGuiPinValueChange(SeGuiPin *p_pin) { if(imChanged) return; // i'm already changing pins; leave me alone imChanged = true; // okay, now i'm gonna change stuff, please don't interrupt me. hehe // first, check any 'parameters' that will affect our formula switch(p_pin->getIndex()) { case PN_IN: inputA = getPin(PN_IN)->getValueFloat(); lastpin = 1; break; case PN_IN2: outputA = getPin(PN_IN2)->getValueFloat(); lastpin = 2; break; case PN_OUT: inputB = getPin(PN_OUT)->getValueFloat(); lastpin = 3; break; case PN_OUT2: outputB = getPin(PN_OUT2)->getValueFloat(); lastpin = 4; break; } switch(lastpin) { case 1: // inputA was last changed outputA = inputA; getPin(PN_IN2)->setValueFloat( outputA ); break; case 2: // outputA was last pin to change inputA = outputA; getPin(PN_IN)->setValueFloat( inputA ); break; case 3: // inputB was last changed outputB = inputB; getPin(PN_OUT2)->setValueFloat( outputB ); break; case 4: // outputB was last pin to change inputB = outputB; getPin(PN_OUT)->setValueFloat( inputB ); break; } imChanged = false; // now we're done, start paying attention to the pins again }