Exemplo n.º 1
0
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();
      }
    }
  }
}
Exemplo n.º 2
0
void Gear_PushButton::runVideo()
{

 bool accept_midi = _settings.get(Gear_PushButton::SETTING_ACCEPTMIDI)->valueBool();
 if(accept_midi)
 {
   bool noteOff;
   MidiMessage* msg;
   std::vector<MidiMessage*> messages = MidiEngine::getInstance().getMessages();

   if(messages.size())
   {
     int channel = _settings.get(Gear_PushButton::SETTING_MIDICHANNEL)->valueInt();
     int Note = _settings.get(Gear_PushButton::SETTING_MIDINOTE)->valueInt();

     // we only consider the LAST Note value
     float on =_settings.get(Gear_PushButton::SETTING_ONVALUE)->valueFloat();
     float off =_settings.get(Gear_PushButton::SETTING_OFFVALUE)->valueFloat();
     
     float highValue = -1,lastStamp;
     noteOff=false;
     for(int i=0;i<messages.size();i++)
     {
       msg = messages[i];
       if(msg->isNoteEvent() && msg->getChannel()==channel  && msg->getNote()==Note)
       {
         std::cerr<<"have event!!!!!!!"<<std::endl;
         if(msg->getNoteValue()==0)
           noteOff=true;
         else
         {
           noteOff=false;
           highValue = (float)msg->getNoteValue() / 127;
         }
         lastStamp = msg->getStamp();
       }
     }

     if(highValue!=-1)
     {
       //std::cout<<"set Value !! :"<<lastValue<<" "<<lastStamp<<std::endl;
       setState(ON);

       // can't call this from here since we're in a different thread than the GUI
       //getGearGui()->reDraw();
     }
   }
   if (noteOff)
   {
     _havePendingRelease=true;
   }
 }




// keyboard part




  if(_settings.get(Gear_PushButton::SETTING_ONESHOT)->valueBool() && _lastWasOn)
    setState(OFF);
  if(_VALUE_OUT->type()->value()==_settings.get(Gear_PushButton::SETTING_ONVALUE)->valueFloat())
    _lastWasOn=true;
  else
    _lastWasOn=false;  
  _haveUnconsumedClick=false;
  if(_havePendingRelease)
    setState(OFF);
}