Example #1
0
void exprCos::generateCuts (expression *w, //const OsiSolverInterface &si, 
			    OsiCuts &cs, const CouenneCutGenerator *cg,
			    t_chg_bounds *chg, int wind, 
			    CouNumber lbw, CouNumber ubw) {

  //  int wi = w -> Index ();

  /*if (chg && !(cg -> isFirst ()) && 
      (chg [wi].lower() == t_chg_bounds::UNCHANGED) && 
      (chg [wi].upper() == t_chg_bounds::UNCHANGED))
      return;*/

#ifdef NEW_TRIG
  if (trigEnvelope (cg, cs, w, w -> Image () -> Argument (), COU_COSINE) == 0) 
#else
    if (addHexagon (cg, cs, COU_COSINE, w, w -> Image () -> Argument()) == 0)
#endif
    {

    }
}
Example #2
0
///////////////////////////////////////////////////////////////////////
// Called when a new note is triggered on the channel
void CLogicalChannel::trig(byte note, byte velocity, byte trigEnv) 
{    
  CLogicalVoice *voice = NULL;
  
  // Check if the channel LFO needs to be restarted 
  // on each note trigger
  switch(m_conf->eLFOMode)
  {
  case TONE_CONFIG::LFO_TRIG_FREE:
  case TONE_CONFIG::LFO_TRIG_GATE:
  case TONE_CONFIG::LFO_ONE_SHOT:
    // Yes - so restart the LFO cycle
    m_fLFOPhase = 0.0;
    m_flags |= SF_LFOSIGN;
    m_flags &= ~SF_LFOCOMPLETE;
    break;
  case TONE_CONFIG::LFO_UNGATE:
  case TONE_CONFIG::LFO_GATE:   
  case TONE_CONFIG::LFO_FREE:      
  default:
    break;
  }

  //////////////////////////////////////////////////////////////////
  // CHANNEL CONFIGURED IN UNISON OR MONO MODE
  if((m_conf->eUnisonMode != TONE_CONFIG::UNISON_OFF) || 
      ( m_conf->flags & TONE_CONFIG::MONO)) {
    // check if a nonzero portamento setting is defined
    if(m_conf->portaTime) {
      
      // store trigggered note as the target of the portamento engine
      m_portaTargetNote = note;
      
      // is there a previous note to use as start point?
      if(m_fPortamentoNote > 0 && note != m_fPortamentoNote) {  
        
        // calculate step rate based on distance between the old and new note
        // and the portamento time setting        
        m_fPortaStep = 2.0 * (note - m_fPortamentoNote) / (float)m_conf->portaTime;
      }
      else {
        // just remember the note for next time!
        m_fPortamentoNote = note;
        m_portaTargetNote = 0;
      }
    }
    else  {
      m_portaTargetNote = 0;
    }
    
    for(int i=m_voiceBegin; i<m_voiceEnd; ++i) {
      voice = &Voice[i];
      voice->m_midi_note = note;
      voice->m_midi_vel = velocity;
      if(trigEnv) {
        trigEnvelope(&m_conf->ampEnv, &voice->m_amp);
        trigEnvelope(&m_conf->modEnv, &voice->m_mod);
      }
      if(m_conf->flags & TONE_CONFIG::MONO) {
        break;
      }
    }
  }
  //////////////////////////////////////////////////////////////////
  // POLYPHONIC CHANNEL
  else
  {    
    // check if the note is already assigned to a channel...
    // if it is, then we will retrigger it
    for(int i=m_voiceBegin; i<m_voiceEnd; ++i) {
      if(Voice[i].m_midi_note == note) {
        voice = &Voice[i];
        break;
      }
    }
    if(!voice) {
      // Otherwise do we have a free channel?
      for(int i=m_voiceBegin; i<m_voiceEnd; ++i) {
        if(Voice[i].m_amp.ePhase == ENVELOPE_STATE::NONE) {
          voice = &Voice[i];
          break;
        }
      }
    }
    if(!voice) {
      // or failing that, one that is in release
      for(int i=m_voiceBegin; i<m_voiceEnd; ++i) {
        if(Voice[i].m_amp.ePhase == ENVELOPE_STATE::RELEASE) {
          voice = &Voice[i];
          break;
        }
      }
    }
    
    // Did we get a voice to assign the note to?
    if(voice) {
      
      // assign the note to the voice
      voice->m_midi_note = note;
      voice->m_midi_vel = velocity;
      
      // retrigger envelopes if needed
      if(trigEnv) {
        trigEnvelope(&m_conf->ampEnv, &voice->m_amp);
        trigEnvelope(&m_conf->modEnv, &voice->m_mod);
      }
    }
  }
}