void Gear_Slider::runAudio() { bool accept_midi = _settings.get(Gear_Slider::SETTING_ACCEPTMIDI)->valueBool(); if(accept_midi) { MidiMessage* msg; std::vector<MidiMessage*> messages = MidiEngine::getInstance().getMessages(); if(messages.size()) { int channel = _settings.get(Gear_Slider::SETTING_MIDICHANNEL)->valueInt(); int controller = _settings.get(Gear_Slider::SETTING_MIDICONTROLLER)->valueInt(); // we only consider the LAST controller value float low = _settings.get(Gear_Slider::SETTING_LOWERBOUND)->valueFloat(); float hi = _settings.get(Gear_Slider::SETTING_HIGHERBOUND)->valueFloat(); float lastValue = -1,lastStamp; for(unsigned int i=0;i<messages.size();i++) { msg = messages[i]; if(msg->isControllerChange() && msg->getChannel()==channel && msg->getController()==controller) { lastValue = (float)msg->getControllerValue() / 127; lastStamp = msg->getStamp(); } } if(lastValue!=-1) { //std::cout<<"set Value !! :"<<lastValue<<" "<<lastStamp<<std::endl; setValue(low + (hi-low)*lastValue); // can't call this from here since we're in a different thread than the GUI //getGearGui()->reDraw(); } } } }