Ejemplo n.º 1
0
short
Lookupi::DoProcess(){
  if(!m_error){
    if(m_ptable && m_input){ 
      float i; int ps;
      for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++){
	if(m_enable){ 
	  i = m_input->Output(m_vecpos);
	  if(m_normal) i *= m_size; // if normalised 
	  // modulus
	  if(m_mode){
	    while(i >= m_size)
	      i -= m_size;        
	    while (i < 0)
	      i += m_size;
	  }
	  else if(i >= m_size || i > 0) 
	    i = (i >= m_size) ? m_size - 1.f : 0.f;
	  // interpolating lookup :
	  ps = Ftoi(i);
	  m_output[m_vecpos] = m_ptable->GetTable()[ps] +      
	    ((m_ptable->GetTable()[ps] - 
	      m_ptable->GetTable()[ps+1])*(ps - i)); 
	}
	else m_output[m_vecpos] =  0.f;
      }
      return 1;
    } else {
      m_error = 3;
      return 0;
    }
  }
  else return 0;		  
}  
Ejemplo n.º 2
0
short
Lookup::DoProcess()
{ 
  if(!m_error){
    if(m_ptable && m_input){ 
      float i;
      for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++){
	if(m_enable){ 
	  i = m_input->Output(m_vecpos);
	  if(m_normal) i *= m_size; // if normalised 
	  // modulus
	  if(m_mode){
	    while(i >= m_size)
	      i -= m_size;        
	    while (i < 0)
	      i += m_size;
	  }
	  else if(i >= m_size || i > 0) 
	    i = (i >= m_size) ? m_size - 1.f : 0.f;
	  // truncating lookup :
	  m_output[m_vecpos] = m_ptable->GetTable()[Ftoi(i) + m_offset]; 
        
	}
	else m_output[m_vecpos] =  0.f;
      }
      return 1;
    } else {
      m_error = 3;
      return 0;
    }
  }
  else return 0;		  
}  
Ejemplo n.º 3
0
short
PhOscili :: DoProcess(){  

  if(!m_error) 
    {
      // wrapping loop
      float fr; 
      float amp; 
      if(!m_ptable)
	{ 
	  m_error = 1; // empty table object
	  return 0;
	} 
      float* tab = m_ptable->GetTable();
      float i;

      for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++)
	{
	  if(m_enable)
	    {
	      int ps;
	      fr      = m_fr + 
		(m_input == 0 ? 0 : m_input->Output(m_vecpos));
	      amp     = m_amp + 
		(m_inputamp == 0 ? 0 : m_inputamp->Output(m_vecpos));
			
	      i = (m_index + 
		   (m_inputphase == 0 ? 0 : m_size * m_inputphase->Output(m_vecpos)));
			
	      // modulo
	      while(i >= m_size)
		i -= m_size;        
	      while (i < 0)
		i += m_size;
	      ps = Ftoi(i);
	      m_output[m_vecpos] =  amp * 
		(  tab[ps] + 
		   ( (tab[ps] - tab[ps+1]) * 
		     (  ps - i  )
		     )
		   );

	      m_incr = fr * m_factor;                         
			
	      m_index += m_incr;             // increment m_index

	      while(m_index >= m_size)
		m_index -= m_size;        // modulus
	      while (m_index < 0)
		m_index += m_size;

	    } else {
	      m_output[m_vecpos] = 0.f;
	    }
	} // end wrapping loop
      return 1;
    }
  else return 0;
}
Ejemplo n.º 4
0
////////////////// OPERATIONS ///////////////////////////////
float  Pan::Panning(float pan, int chan){

  if(pan >= -1 && pan <= 1){
    if(!chan) return m_panpos[Ftoi(m_res*(1+pan))];
    else return m_panpos[Ftoi(m_res*(1-pan))];
  }
  else {
    if (pan < -1) { 
      if(!chan) return m_panpos[0]; 
      else  return 0.f;
    }
    else {
      if(!chan) return 0.f;
      else return m_panpos[0];

    } 
  }

}
Ejemplo n.º 5
0
short
PVTransp::DoProcess(){

  if(!m_error){
    if(m_input){
	  
      for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos+=2){
	m_output[m_vecpos] = 0.f;
	m_output[m_vecpos+1] = (m_vecpos/2)*m_base;
      }

      if(m_enable){	

	int chan, newchan;
	float pitch = m_pitch + (m_input2 ? m_input2->Output(0) :
				 0.f);
     
	m_output[0] = m_input->Output(0);
	m_output[1] = m_input->Output(1);

	for(m_vecpos=2,chan=1;m_vecpos < m_vecsize; m_vecpos+=2,chan++){

	  newchan = Ftoi(chan*pitch)*2; 
	  if(newchan < m_vecsize-1 && newchan > 0){
	    if(m_keepform) m_output[newchan] = m_input->Output(newchan);
	    else m_output[newchan] = m_input->Output(m_vecpos);
	    m_output[newchan+1] = m_input->Output(m_vecpos+1)*pitch;	  
	  }
	}
      }

      return 1;


    } else {
      m_error = 3;
      return 0;
    }
  }
  else return 0;



}
Ejemplo n.º 6
0
short
MidiMap::DoProcess(){
  if(!m_error) { 
    if(m_ioinput){   
      if(m_ioinput->NewMessage(m_channel+1) && 
	 (m_message == m_ioinput->GetMessage(m_channel+1))){
	for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++){   
	  if(m_enable){
	    if(!m_readvel  &&  !m_readaft){
	      if(m_maptable)
		m_output[m_vecpos] = m_maptable->GetTable()[Ftoi(m_ioinput->Output(m_channel))];
	      else
		m_output[m_vecpos] = m_map[Ftoi(m_ioinput->Output(m_channel))];
	    }
	    else {
	      if(m_readvel){
		if(m_maptable)
		  m_output[m_vecpos] = m_maptable->GetTable()[Ftoi((float)m_ioinput->LastNoteVelocity())];
		else	   
		  m_output[m_vecpos] = m_map[Ftoi((float)m_ioinput->LastNoteVelocity())];

	      }
	      if(m_readaft){
		if(m_maptable)
		  m_output[m_vecpos] = m_maptable->GetTable()[Ftoi((float)m_ioinput->LastNoteAftertouch())];
		else	   
		  m_output[m_vecpos] = m_map[Ftoi((float)m_ioinput->LastNoteAftertouch())];
	      }
	    }
	  } else m_output[m_vecpos] = 0.f;
	}
	return 1; 
      } else return 1;
    }  
    else{
      m_error = 11; 
      return 0;
    }
  }
  else return 0;
}
Ejemplo n.º 7
0
	static __int64 Ftoi(FloatConstant* a, const IntegerType* toKind) {
		return Ftoi(a->Value(), a->GetType()->GetSubtype(), toKind->GetSubtype());
	}
Ejemplo n.º 8
0
short
IFAdd::DoProcess() {
	
  if(m_input){
		
    float ampnext,amp,freq, freqnext, phase;
    float inc1, inc2, a, ph, cnt, frac;
    float a2, a3, phasediff, phasenext, cph, shf;
    bool lock;
    int i2, i, bins = m_maxtracks, ndx;
    float* tab = m_ptable->GetTable(); 
    memset(m_output, 0, sizeof(float)*m_vecsize);

    shf = m_tscal*m_pitch;
    if(shf  - Ftoi(shf)) lock = false;
    else lock = true;
		
    // for each bin from 1
    for(i=1; i < bins; i++){
			
      i2 = i<<1;

      ampnext =  m_input->Output(i2)*m_scale;
      freqnext = m_input->Output(i2+1)*TWOPI*m_pitch;
      phasenext = ((IFGram *)m_input)->Outphases(i)*shf;
      freq = m_freqs[i];
      phase = m_phases[i];
      amp = m_amps[i];
			 
      //phase difference
      phasediff = phasenext - phase;
      while(phasediff >= PI) phasediff -= TWOPI;
      while(phasediff < -PI) phasediff += TWOPI;
      // update phasediff to match the freq
      cph = ((freq+freqnext)*m_factor/2. - phasediff)/TWOPI;
      phasediff += TWOPI* (lock ? Ftoi(cph + 0.5) : cph);
       
      // interpolation coefs
      a2 = 3./m_facsqr * (phasediff - m_factor/3.*(2*freq+freqnext));
      a3 = 1./(3*m_facsqr)  * (freqnext - freq - 2*a2*m_factor);

      // interpolation resynthesis loop	
      a = amp;
      ph = phase;
      cnt = 0;
      inc1 = (ampnext - amp)/m_vecsize;
      inc2 = 1/m_sr;  
      for(m_vecpos=0; m_vecpos < m_vecsize; m_vecpos++){
		
	if(m_enable) {    
	  // table lookup oscillator
	  ph *= m_LoTWOPI;
	  while(ph < 0) ph += m_size;
	  while(ph >= m_size) ph -= m_size;
	  ndx = Ftoi(ph);
	  frac = ph - ndx;
	  m_output[m_vecpos] += a*(tab[ndx] + (tab[ndx+1] - tab[ndx])*frac); 
	  a += inc1;
	  cnt += inc2;
	  ph = phase + cnt*(freq + cnt*(a2 + a3*cnt));
					
	}
	else m_output[m_vecpos] = 0.f;		
      }

      // keep amp, freq, and update phase for next time
      m_amps[i] = ampnext;
      m_freqs[i] = freqnext;
      phasenext += (lock ? 0 : (cph - Ftoi(cph))*TWOPI); 
      while(phasenext < 0) phasenext += TWOPI;
      while(phasenext >= TWOPI) phasenext -= TWOPI;
      m_phases[i] = phasenext;  
    } 
    return 1;
  }
  else {
    m_error  = 1;
    return 0;
  }

}