コード例 #1
0
ファイル: v3d.c プロジェクト: 2BReality/xbmc
void v3d_to_v2d(v3d *v3, int nbvertex, int width, int height, float distance, v2d *v2) {
	int i;
	for (i=0;i<nbvertex;++i) {
		if (v3[i].z > 2) {
			int Xp, Yp;
			F2I((distance * v3[i].x / v3[i].z),Xp);
			F2I((distance * v3[i].y / v3[i].z),Yp);
			v2[i].x = Xp + (width>>1);
			v2[i].y = -Yp + (height>>1);
		}
		else v2[i].x=v2[i].y=-666;
コード例 #2
0
ファイル: organ.c プロジェクト: BackupTheBerlios/holap
float
NFsin (horgand_synth_t * s, int i, float x)
{


  long int k = F2I (x * 1000.0f);


  if (i == 1)
    return (s->lsin[k]);
  if (i == 2)
    return (s->nsin[k]);
  if (i == 3)
    return (s->msin[k]);
  if (i == 4)
    return (s->psin[k]);
  if (i == 5)
    return (s->qsin[k]);
  if (i == 6)
    return (s->rsin[k]);
  if (i == 7)
    return (s->tsin[k]);
  if (i == 8)
    return (s->ssin[k]);
  if (i == 9)
    return (s->usin[k]);



  return 0.0;
};
コード例 #3
0
ClientWidget::ClientWidget(QGLWidget *parent)
    : QGLWidget(parent)
{
    qDebug()<<ENCAPS(tr("widget init"));
    frames=0;ftmp=0;
    hud.load("hud.png");
    teapot.size=F2I(0.1f);
    qsrand(0);
}
コード例 #4
0
void FormantFilter::setpos(REALTYPE input){
    int p1,p2;

    if (firsttime!=0) slowinput=input;
	else slowinput=slowinput*(1.0-formantslowness)+input*formantslowness;

    if ((fabs(oldinput-input)<0.001)&&(fabs(slowinput-input)<0.001)&&
	(fabs(Qfactor-oldQfactor)<0.001)) {
//	oldinput=input; daca setez asta, o sa faca probleme la schimbari foarte lente
	firsttime=0;
	return;
    } else oldinput=input;


    REALTYPE pos=fmod(input*sequencestretch,1.0);if (pos<0.0) pos+=1.0;

    F2I(pos*sequencesize,p2);
    p1=p2-1;if (p1<0) p1+=sequencesize;

    pos=fmod(pos*sequencesize,1.0);
    if (pos<0.0) pos=0.0; else if (pos>1.0) pos=1.0;
    pos=(atan((pos*2.0-1.0)*vowelclearness)/atan(vowelclearness)+1.0)*0.5;

    p1=sequence[p1].nvowel;
    p2=sequence[p2].nvowel;

    if (firsttime!=0) {
       for (int i=0;i<numformants;i++){
	    currentformants[i].freq=formantpar[p1][i].freq*(1.0-pos)+formantpar[p2][i].freq*pos;
	    currentformants[i].amp=formantpar[p1][i].amp*(1.0-pos)+formantpar[p2][i].amp*pos;
	    currentformants[i].q=formantpar[p1][i].q*(1.0-pos)+formantpar[p2][i].q*pos;
	    formant[i]->setfreq_and_q(currentformants[i].freq,currentformants[i].q*Qfactor);
	    oldformantamp[i]=currentformants[i].amp;
	};
	firsttime=0;
    } else {
	for (int i=0;i<numformants;i++){
	    currentformants[i].freq=currentformants[i].freq*(1.0-formantslowness)
		+(formantpar[p1][i].freq*(1.0-pos)+formantpar[p2][i].freq*pos)*formantslowness;

	    currentformants[i].amp=currentformants[i].amp*(1.0-formantslowness)
		+(formantpar[p1][i].amp*(1.0-pos)+formantpar[p2][i].amp*pos)*formantslowness;

	    currentformants[i].q=currentformants[i].q*(1.0-formantslowness)
		+(formantpar[p1][i].q*(1.0-pos)+formantpar[p2][i].q*pos)*formantslowness;

	    formant[i]->setfreq_and_q(currentformants[i].freq,currentformants[i].q*Qfactor);
	};
    };

    oldQfactor=Qfactor;
};
コード例 #5
0
ファイル: PADnote.cpp プロジェクト: ishkabbible/ZASF
inline void PADnote::fadein(REALTYPE *smps)
{
    int zerocrossings=0;
    for (int i=1;i<SOUND_BUFFER_SIZE;i++)
        if ((smps[i-1]<0.0) && (smps[i]>0.0)) zerocrossings++;//this is only the possitive crossings

    REALTYPE tmp=(SOUND_BUFFER_SIZE-1.0)/(zerocrossings+1)/3.0;
    if (tmp<8.0) tmp=8.0;

    int n;
    F2I(tmp,n);//how many samples is the fade-in
    if (n>SOUND_BUFFER_SIZE) n=SOUND_BUFFER_SIZE;
    for (int i=0;i<n;i++) {//fade-in
        REALTYPE tmp=0.5-cos((REALTYPE)i/(REALTYPE) n*PI)*0.5;
        smps[i]*=tmp;
    };
};
コード例 #6
0
ファイル: Unison.cpp プロジェクト: beatwise/ZynWise
void Unison::process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf) {
    if(!uv)
        return;
    if(!outbuf)
        outbuf = inbuf;

    REALTYPE volume    = 1.0 / SQRT(unison_size);
    REALTYPE xpos_step = 1.0 / (REALTYPE) update_period_samples;
    REALTYPE xpos      = (REALTYPE) update_period_sample_k * xpos_step;
    for(int i = 0; i < bufsize; i++) {
        if((update_period_sample_k++) >= update_period_samples) {
            update_unison_data();
            update_period_sample_k = 0;
            xpos = 0.0;
        }
        xpos += xpos_step;
        REALTYPE in   = inbuf[i], out = 0.0;

        REALTYPE sign = 1.0;
        for(int k = 0; k < unison_size; k++) {
            REALTYPE vpos = uv[k].realpos1
                            * (1.0 - xpos) + uv[k].realpos2 * xpos;     //optimize
            REALTYPE pos  = delay_k + max_delay - vpos - 1.0; //optimize
            int      posi;
            REALTYPE posf;
            F2I(pos, posi); //optimize!
            if(posi >= max_delay)
                posi -= max_delay;
            posf = pos - floor(pos);
            out +=
                ((1.0
                  - posf) * delay_buffer[posi] + posf
                 * delay_buffer[posi + 1]) * sign;
            sign = -sign;
        }
        outbuf[i] = out * volume;
//		printf("%d %g\n",i,outbuf[i]);
        delay_buffer[delay_k] = in;
        if((++delay_k) >= max_delay)
            delay_k = 0;
    }
}
コード例 #7
0
ファイル: PADnote.cpp プロジェクト: BaraMGB/lmms
inline void PADnote::fadein(float *smps)
{
    int zerocrossings = 0;
    for(int i = 1; i < synth->buffersize; ++i)
        if((smps[i - 1] < 0.0f) && (smps[i] > 0.0f))
            zerocrossings++;                                  //this is only the possitive crossings

    float tmp = (synth->buffersize_f - 1.0f) / (zerocrossings + 1) / 3.0f;
    if(tmp < 8.0f)
        tmp = 8.0f;

    int n;
    F2I(tmp, n); //how many samples is the fade-in
    if(n > synth->buffersize)
        n = synth->buffersize;
    for(int i = 0; i < n; ++i) { //fade-in
        float tmp = 0.5f - cosf((float)i / (float) n * PI) * 0.5f;
        smps[i] *= tmp;
    }
}
コード例 #8
0
ファイル: Unison.cpp プロジェクト: CallisteHanriat/lmms
void Unison::process(int bufsize, float *inbuf, float *outbuf)
{
    if(!uv)
        return;
    if(!outbuf)
        outbuf = inbuf;

    float volume    = 1.0f / sqrtf(unison_size);
    float xpos_step = 1.0f / (float) update_period_samples;
    float xpos      = (float) update_period_sample_k * xpos_step;
    for(int i = 0; i < bufsize; ++i) {
        if(update_period_sample_k++ >= update_period_samples) {
            updateUnisonData();
            update_period_sample_k = 0;
            xpos = 0.0f;
        }
        xpos += xpos_step;
        float in   = inbuf[i], out = 0.0f;
        float sign = 1.0f;
        for(int k = 0; k < unison_size; ++k) {
            float vpos = uv[k].realpos1 * (1.0f - xpos) + uv[k].realpos2 * xpos;        //optimize
            float pos  = (float)(delay_k + max_delay) - vpos - 1.0f;
            int   posi;
            F2I(pos, posi); //optimize!
            int posi_next = posi + 1;
            if(posi >= max_delay)
                posi -= max_delay;
            if(posi_next >= max_delay)
                posi_next -= max_delay;
            float posf = pos - floorf(pos);
            out += ((1.0f - posf) * delay_buffer[posi] + posf
                 * delay_buffer[posi_next]) * sign;
            sign = -sign;
        }
        outbuf[i] = out * volume;
//		printf("%d %g\n",i,outbuf[i]);
        delay_buffer[delay_k] = in;
        delay_k = (++delay_k < max_delay) ? delay_k : 0;
    }
}
コード例 #9
0
ファイル: alloc_cell.c プロジェクト: rashadkm/grass_cmake
size_t Rast_cell_size(RASTER_MAP_TYPE data_type)
{
    return (type_size[F2I(data_type)]);
}
コード例 #10
0
ファイル: virt_timer.cpp プロジェクト: iver6/BA
void bx_virt_timer_c::timer_handler(void)
{
  if(!virtual_timers_realtime) {
    Bit64u temp_final_time = bx_pc_system.time_usec();
    temp_final_time -= current_virtual_time;
    while (temp_final_time) {
      if((temp_final_time)>(virtual_next_event_time)) {
        temp_final_time -= virtual_next_event_time;
        advance_virtual_time(virtual_next_event_time);
      } else {
        advance_virtual_time(temp_final_time);
        temp_final_time -= temp_final_time;
      }
    }
    bx_pc_system.activate_timer(system_timer_id,
                                (Bit32u)BX_MIN(0x7FFFFFFF,(virtual_next_event_time>2)?(virtual_next_event_time-2):1),
                                0);
    return;
  }

  Bit64u usec_delta = bx_pc_system.time_usec()-last_usec;

  if (usec_delta) {
#if BX_HAVE_REALTIME_USEC
    Bit64u ticks_delta = 0;
    Bit64u real_time_delta = GET_VIRT_REALTIME64_USEC() - last_real_time - real_time_delay;
    Bit64u real_time_total = real_time_delta + total_real_usec;
    Bit64u system_time_delta = (Bit64u)usec_delta + (Bit64u)stored_delta;
    if(real_time_delta) {
      last_realtime_delta = real_time_delta;
      last_realtime_ticks = total_ticks;
    }
    ticks_per_second = USEC_PER_SECOND;

    //Start out with the number of ticks we would like
    // to have to line up with real time.
    ticks_delta = real_time_total - total_ticks;
    if(real_time_total < total_ticks) {
      //This slows us down if we're already ahead.
      //  probably only an issue on startup, but it solves some problems.
      ticks_delta = 0;
    }
    if(ticks_delta + total_ticks - last_realtime_ticks > (F2I(MAX_MULT * I2F(last_realtime_delta)))) {
      //This keeps us from going too fast in relation to real time.
#if 0
      ticks_delta = (F2I(MAX_MULT * I2F(last_realtime_delta))) + last_realtime_ticks - total_ticks;
#endif
      ticks_per_second = F2I(MAX_MULT * I2F(USEC_PER_SECOND));
    }
    if(ticks_delta > system_time_delta * USEC_PER_SECOND / MIN_USEC_PER_SECOND) {
      //This keeps us from having too few instructions between ticks.
      ticks_delta = system_time_delta * USEC_PER_SECOND / MIN_USEC_PER_SECOND;
    }
    if(ticks_delta > virtual_next_event_time) {
      //This keeps us from missing ticks.
      ticks_delta = virtual_next_event_time;
    }

    if(ticks_delta) {

#  if DEBUG_REALTIME_WITH_PRINTF
      //Every second print some info.
      if(((last_real_time + real_time_delta) / USEC_PER_SECOND) > (last_real_time / USEC_PER_SECOND)) {
        Bit64u temp1, temp2, temp3, temp4;
        temp1 = (Bit64u) total_real_usec;
        temp2 = (total_real_usec);
        temp3 = (Bit64u)total_ticks;
        temp4 = (Bit64u)((total_real_usec) - total_ticks);
        printf("useconds: " FMT_LL "u, ", temp1);
        printf("expect ticks: " FMT_LL "u, ", temp2);
        printf("ticks: " FMT_LL "u, ", temp3);
        printf("diff: "FMT_LL "u\n", temp4);
      }
#  endif

      last_real_time += real_time_delta;
      total_real_usec += real_time_delta;
      last_system_usec += system_time_delta;
      stored_delta = 0;
      total_ticks += ticks_delta;
    } else {
      stored_delta = system_time_delta;
    }

    Bit64u a = usec_per_second, b;
    if(real_time_delta) {
      //FIXME
      Bit64u em_realtime_delta = last_system_usec + stored_delta - em_last_realtime;
      b=((Bit64u)USEC_PER_SECOND * em_realtime_delta / real_time_delta);
      em_last_realtime = last_system_usec + stored_delta;
    } else {
      b=a;
    }
    usec_per_second = ALPHA_LOWER(a,b);
#else
    BX_ASSERT(0);
#endif
#if BX_HAVE_REALTIME_USEC
    advance_virtual_time(ticks_delta);
#endif
  }

  last_usec=last_usec + usec_delta;
  bx_pc_system.deactivate_timer(system_timer_id);
  BX_ASSERT(virtual_next_event_time);
  bx_pc_system.activate_timer(system_timer_id,
                              (Bit32u)BX_MIN(0x7FFFFFFF,BX_MAX(1,TICKS_TO_USEC(virtual_next_event_time))),
                              0);
}
コード例 #11
0
ファイル: formant_filter.cpp プロジェクト: XelaRellum/zyn
void FormantFilter::setpos(float input)
{
  int p1;
  int p2;
  float pos;
  int i;

  if (m_firsttime != 0)
  {
    m_slowinput = input;
  }
  else
  {
    m_slowinput = m_slowinput * (1.0 - m_formantslowness) + input * m_formantslowness;
  }

  if ((fabs(m_oldinput - input) < 0.001) &&
      (fabs(m_slowinput - input) < 0.001) &&
      (fabs(m_Qfactor - m_oldQfactor) < 0.001))
  {
//  m_oldinput = input; // daca setez asta, o sa faca probleme la schimbari foarte lente
    m_firsttime=0;
    return;
  }
  else
  {
    m_oldinput = input;
  }

  pos = fmod(input * m_sequencestretch, 1.0);
  if (pos < 0.0)
  {
    pos += 1.0;
  }

  F2I(pos * m_sequencesize, p2);
  p1 = p2 - 1;
  if (p1 < 0)
  {
    p1 += m_sequencesize;
  }

  pos = fmod(pos * m_sequencesize, 1.0);
  if (pos < 0.0)
  {
    pos = 0.0;
  }
  else if (pos > 1.0)
  {
    pos = 1.0;
  }
  pos = (atan((pos * 2.0 - 1.0) * m_vowelclearness) / atan(m_vowelclearness) + 1.0) * 0.5;

  p1 = m_sequence[p1].nvowel;
  p2 = m_sequence[p2].nvowel;

  if (m_firsttime != 0)
  {
    for (i = 0 ; i < m_numformants ; i++)
    {
      m_currentformants[i].frequency = m_formantpar[p1][i].frequency * (1.0 - pos) + m_formantpar[p2][i].frequency*pos;
      m_currentformants[i].amplitude = m_formantpar[p1][i].amplitude * (1.0 - pos) + m_formantpar[p2][i].amplitude*pos;
      m_currentformants[i].q_factor = m_formantpar[p1][i].q_factor*(1.0 - pos) + m_formantpar[p2][i].q_factor * pos;  
      m_formants[i].setfreq_and_q(m_currentformants[i].frequency, m_currentformants[i].q_factor * m_Qfactor);
      m_oldformantamp[i] = m_currentformants[i].amplitude;
    }

    m_firsttime = 0;
  }
  else
  {
    for (i = 0 ; i < m_numformants ; i++)
    {
      m_currentformants[i].frequency = m_currentformants[i].frequency * (1.0 - m_formantslowness)
        + (m_formantpar[p1][i].frequency * (1.0 - pos) + m_formantpar[p2][i].frequency * pos) * m_formantslowness;

      m_currentformants[i].amplitude = m_currentformants[i].amplitude * (1.0 - m_formantslowness)
        + (m_formantpar[p1][i].amplitude * (1.0 - pos) + m_formantpar[p2][i].amplitude * pos) * m_formantslowness;

      m_currentformants[i].q_factor = m_currentformants[i].q_factor * (1.0 - m_formantslowness)
        + (m_formantpar[p1][i].q_factor * (1.0 - pos) + m_formantpar[p2][i].q_factor * pos) * m_formantslowness;

      m_formants[i].setfreq_and_q(m_currentformants[i].frequency, m_currentformants[i].q_factor * m_Qfactor);
    }
  }

  m_oldQfactor = m_Qfactor;
}
コード例 #12
0
ファイル: Arc.cpp プロジェクト: george-kuo/GoSysWare
void CArc::Format(long left, long top, long right, long bottom, long flag)
{
	long ldx,ldy;
	switch(flag){
	case FM_A2L:
		ldx=left-Left();
		m_lx1+=ldx;
		m_lx2+=ldx;
		m_lx3+=ldx;
		m_lx4+=ldx;
		break;
	case FM_A2C:
		ldx=(left+right-Left()-Right())/2;
		m_lx1+=ldx;
		m_lx2+=ldx;
		m_lx3+=ldx;
		m_lx4+=ldx;
		break;
	case FM_A2R:
		ldx=right-Right();
		m_lx1+=ldx;
		m_lx2+=ldx;
		m_lx3+=ldx;
		m_lx4+=ldx;
		break;
	case FM_A2T:
		ldy=top-Top();
		m_ly1+=ldy;
		m_ly2+=ldy;
		m_ly3+=ldy;
		m_ly4+=ldy;
		break;
	case FM_A2M:
		ldy=(top+bottom-Top()-Bottom())/2;
		m_ly1+=ldy;
		m_ly2+=ldy;
		m_ly3+=ldy;
		m_ly4+=ldy;
		break;
	case FM_A2B:
		ldy=bottom-Bottom();
		m_ly1+=ldy;
		m_ly2+=ldy;
		m_ly3+=ldy;
		m_ly4+=ldy;
		break;
	case FM_A2CM:
		ldx=(left+right-Left()-Right())/2;
		m_lx1+=ldx;
		m_lx2+=ldx;
		m_lx3+=ldx;
		m_lx4+=ldx;
		ldy=(top+bottom-Top()-Bottom())/2;
		m_ly1+=ldy;
		m_ly2+=ldy;
		m_ly3+=ldy;
		m_ly4+=ldy;
		break;
	case FM_R2W:
		ldx=(left+right)/2;
		ldy=(top+bottom)/2;
		R2W(ldx,ldy,&m_lx1,&m_ly1);
		R2W(ldx,ldy,&m_lx2,&m_ly2);
		R2W(ldx,ldy,&m_lx3,&m_ly3);
		R2W(ldx,ldy,&m_lx4,&m_ly4);
		break;
	case FM_R2U:
		ldx=(left+right)/2;
		ldy=(top+bottom)/2;
		R2U(ldx,ldy,&m_lx1,&m_ly1);
		R2U(ldx,ldy,&m_lx2,&m_ly2);
		R2U(ldx,ldy,&m_lx3,&m_ly3);
		R2U(ldx,ldy,&m_lx4,&m_ly4);
		break;
	case FM_F2Z:
		ldx=(left+right)/2;
		F2Z(ldx,&m_lx1);
		F2Z(ldx,&m_lx2);
		F2Z(ldx,&m_lx3);
		F2Z(ldx,&m_lx4);
		ldx=m_lx3;
		ldy=m_ly3;
		m_lx3=m_lx4;
		m_ly3=m_ly4;
		m_lx4=ldx;
		m_ly4=ldy;
		break;
	case FM_F2I:
		ldy=(top+bottom)/2;
		F2I(ldy,&m_ly1);
		F2I(ldy,&m_ly2);
		F2I(ldy,&m_ly3);
		F2I(ldy,&m_ly4);
		ldx=m_lx3;
		ldy=m_ly3;
		m_lx3=m_lx4;
		m_ly3=m_ly4;
		m_lx4=ldx;
		m_ly4=ldy;
		break;
	case FM_S2G:
		m_lx1=(m_lx1+right/2)-(m_lx1+right/2)%right;
		m_lx2=(m_lx2+right/2)-(m_lx2+right/2)%right;
		m_lx3=(m_lx3+right/2)-(m_lx3+right/2)%right;
		m_lx4=(m_lx4+right/2)-(m_lx4+right/2)%right;
		m_ly1=(m_ly1+bottom/2)-(m_ly1+bottom/2)%bottom;
		m_ly2=(m_ly2+bottom/2)-(m_ly2+bottom/2)%bottom;
		m_ly3=(m_ly3+bottom/2)-(m_ly3+bottom/2)%bottom;
		m_ly4=(m_ly4+bottom/2)-(m_ly4+bottom/2)%bottom;
		break;
	}
}
コード例 #13
0
ファイル: pd7752.cpp プロジェクト: eighttails/PC6001VX
////////////////////////////////////////////////////////////////
// 1フレーム分の音声を合成します。
// 引数:	frame	合成した波形データの格納先。1フレーム分の個数
// 返値:	int		エラーコード
////////////////////////////////////////////////////////////////
int	cD7752::Synth(	BYTE *param, D7752_SAMPLE *frame )
{
	int	vu;
	int	qmag;
	D7752Coef *curr;
	D7752Coef incr,	next;
	
	if(	!param || !frame ) return D7752_ERR_PARAM;
	
	curr = &Coef;
	
	// まず、パラメータを係数に展開する
	qmag = (param[0] & 4) != 0 ? 1 : 0;
	
	for( int i=0; i<5; i++ ){
		int	f =	(param[i+1]	>> 3) &	31;
		if(	f &	16 ) f -= 32;
		next.f[i] =	curr->f[i] + I2F( f	<< qmag	);
		
		int	b =	param[i+1] & 7;
		if(	b &	4 )	b -= 8;
		next.b[i] =	curr->b[i] + I2F( b	<< qmag	);
	}
	
	next.amp = I2F(	( param[6] >> 4	) &	15 );
	
	int	p =	param[6] & 7;
	if(	p &	4 )	p -= 8;
	next.pitch = curr->pitch + I2F(p);
	
	// 線形補完用の増分値の計算
	incr.amp   = ( next.amp	  -	curr->amp )	  /	FrameSize;
	incr.pitch = ( next.pitch -	curr->pitch	) /	FrameSize;
	for( int i=0; i<5; i++ ){
		incr.b[i] =	( next.b[i]	- curr->b[i] ) / FrameSize;
		incr.f[i] =	( next.f[i]	- curr->f[i] ) / FrameSize;
	}
	
	// インパルス・ノイズの発生有無をチェック
	vu	= param[0] & 1 ? 1 : 2;
	vu |= param[6] & 4 ? 3 : 0;
	
	// 合成する
	for( int i=0; i<FrameSize; i++ ){
		int	y =	0;
		
		// インパルス発生
		int	c =	F2I( curr->pitch );
		if(	PitchCount > (c	> 0	? c	: 128) ){
			if(	vu & 1 ) y = amp_table[F2I(curr->amp)] * 16	- 1;
			PitchCount = 0;
		}
		PitchCount++;
		
		// ノイズ発生
		if(	vu & 2 )
			if(	rand() & 1 ) y += amp_table[F2I(curr->amp)]	* 4	- 1;	 //	XXX	ノイズ詳細不明
		
		// 謎のディジタルフィルタ
		for( int j=0; j<5; j++ ){
			int	t;
			t  = Y[j][0] * iir1[ F2I( curr->f[j] ) & 0x7f		  ]	/ 8192;
			y += t		 * iir1[(F2I( curr->b[j] ) * 2 + 1)	& 0x7f]	/ 8192;
			y -= Y[j][1] * iir2[ F2I( curr->b[j] ) & 0x3f		  ]	/ 8192;
			
			y =	y >	8191 ? 8191	: y	< -8192	? -8192	: y;
			
			Y[j][1]	= Y[j][0];
			Y[j][0]	= y;
		}
		
		// データを保存
		*frame++ = y;
		
		// パラメータを増分
		curr->amp	+= incr.amp;
		curr->pitch	+= incr.pitch;
		for( int j=0; j<5; j++ ){
			curr->b[j] += incr.b[j];
			curr->f[j] += incr.f[j];
		}
	}
	
	// パラメータをシフトする
	memcpy(	curr, &next, sizeof(D7752Coef) );
	
	return D7752_ERR_SUCCESS;
}
コード例 #14
0
ファイル: Chorus.C プロジェクト: yroffin/Rakkarack
/*
 * Apply the effect
 */
void
Chorus::out (float * smpsl, float * smpsr)
{
  int i;
  dl1 = dl2;
  dr1 = dr2;
  lfo.effectlfoout (&lfol, &lfor);

  dl2 = getdelay (lfol);
  dr2 = getdelay (lfor);

  for (i = 0; i < PERIOD; i++)
    {
      float inl = smpsl[i];
      float inr = smpsr[i];
      //LRcross
      float l = inl;
      float r = inr;
      inl = l * (1.0f - lrcross) + r * lrcross;
      inr = r * (1.0f - lrcross) + l * lrcross;

      //Left channel

      //compute the delay in samples using linear interpolation between the lfo delays
      mdel = (dl1 * (float)(PERIOD - i) + dl2 * (float)i) / fPERIOD;
      if (++dlk >= maxdelay)
	dlk = 0;
      float tmp = (float) dlk - mdel + (float)maxdelay * 2.0f;	//where should I get the sample from

      F2I (tmp, dlhi);
      dlhi %= maxdelay;

      dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
      dllo = 1.0f - fmodf (tmp, 1.0f);
      efxoutl[i] = delayl[dlhi2] * dllo + delayl[dlhi] * (1.0f - dllo);
      delayl[dlk] = inl + efxoutl[i] * fb;

      //Right channel

      //compute the delay in samples using linear interpolation between the lfo delays
      mdel = (dr1 * (float)(PERIOD - i) + dr2 * (float)i) / fPERIOD;
      if (++drk >= maxdelay)
	drk = 0;
      tmp = (float)drk - mdel + (float)maxdelay * 2.0f;	//where should I get the sample from

      F2I (tmp, dlhi);
      dlhi %= maxdelay;

      dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
      dllo = 1.0f - fmodf (tmp, 1.0f);
      efxoutr[i] = delayr[dlhi2] * dllo + delayr[dlhi] * (1.0f - dllo);
      delayr[dlk] = inr + efxoutr[i] * fb;

    };

  if (Poutsub != 0)
    for (i = 0; i < PERIOD; i++)
      {
	efxoutl[i] *= -1.0f;
	efxoutr[i] *= -1.0f;
      };


  for (int i = 0; i < PERIOD; i++)
    {
      efxoutl[i] *= panning;
      efxoutr[i] *= (1.0f - panning);
    };
};
コード例 #15
0
ファイル: Text.cpp プロジェクト: george-kuo/GoSysWare
void CText::Format(long left, long top, long right, long bottom, long flag)
{
    long ldx,ldy;
    switch(flag) {
    case FM_A2L:
        ldx=left-Left();
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2C:
        ldx=(left+right-Left()-Right())/2;
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2R:
        ldx=right-Right();
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2T:
        ldy=top-Top();
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2M:
        ldy=(top+bottom-Top()-Bottom())/2;
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2B:
        ldy=bottom-Bottom();
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2CM:
        ldx=(left+right-Left()-Right())/2;
        m_lx1+=ldx;
        m_lx2+=ldx;
        ldy=(top+bottom-Top()-Bottom())/2;
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_R2W:
        ldx=(left+right)/2;
        ldy=(top+bottom)/2;
        R2W(ldx,ldy,&m_lx1,&m_ly1);
        R2W(ldx,ldy,&m_lx2,&m_ly2);
        m_font.lfEscapement+=2700;
        m_font.lfEscapement%=3600;
        break;
    case FM_R2U:
        ldx=(left+right)/2;
        ldy=(top+bottom)/2;
        R2U(ldx,ldy,&m_lx1,&m_ly1);
        R2U(ldx,ldy,&m_lx2,&m_ly2);
        m_font.lfEscapement+=900;
        m_font.lfEscapement%=3600;
        break;
    case FM_F2Z:
        ldx=(left+right)/2;
        F2Z(ldx,&m_lx1);
        F2Z(ldx,&m_lx2);
        if(m_lx1>m_lx2) {
            ldx=m_lx1;
            m_lx1=m_lx2;
            m_lx2=m_lx1;
        }
        break;
    case FM_F2I:
        ldy=(top+bottom)/2;
        F2I(ldy,&m_ly1);
        F2I(ldy,&m_ly2);
        if(m_ly1>m_ly2) {
            ldy=m_ly1;
            m_ly1=m_ly2;
            m_ly2=ldy;
        }
        break;
    case FM_S2G:
        break;
    }
}
コード例 #16
0
ファイル: FormantFilter.cpp プロジェクト: peter1000/Carla
void FormantFilter::setpos(float frequency)
{
    int p1, p2;

    //Convert form real freq[Hz]
    const float input = log_2(frequency) - 9.96578428f; //log2(1000)=9.95748f.

    if(firsttime != 0)
        slowinput = input;
    else
        slowinput = slowinput
                    * (1.0f - formantslowness) + input * formantslowness;

    if((fabsf(oldinput - input) < 0.001f) && (fabsf(slowinput - input) < 0.001f)
       && (fabsf(Qfactor - oldQfactor) < 0.001f)) {
        //	oldinput=input; daca setez asta, o sa faca probleme la schimbari foarte lente
        firsttime = 0;
        return;
    }
    else
        oldinput = input;

    float pos = input * sequencestretch;
    pos -= floorf(pos);

    F2I(pos * sequencesize, p2);
    p1 = p2 - 1;
    if(p1 < 0)
        p1 += sequencesize;

    pos = pos * sequencesize;
    pos -= floorf(pos);
    pos =
        (atanf((pos * 2.0f
                - 1.0f)
               * vowelclearness) / atanf(vowelclearness) + 1.0f) * 0.5f;

    p1 = sequence[p1].nvowel;
    p2 = sequence[p2].nvowel;

    if(firsttime != 0) {
        for(int i = 0; i < numformants; ++i) {
            currentformants[i].freq =
                formantpar[p1][i].freq
                * (1.0f - pos) + formantpar[p2][i].freq * pos;
            currentformants[i].amp =
                formantpar[p1][i].amp
                * (1.0f - pos) + formantpar[p2][i].amp * pos;
            currentformants[i].q =
                formantpar[p1][i].q * (1.0f - pos) + formantpar[p2][i].q * pos;
            formant[i]->setfreq_and_q(currentformants[i].freq,
                                      currentformants[i].q * Qfactor);
            oldformantamp[i] = currentformants[i].amp;
        }
        firsttime = 0;
    }
    else
        for(int i = 0; i < numformants; ++i) {
            currentformants[i].freq =
                currentformants[i].freq * (1.0f - formantslowness)
                + (formantpar[p1][i].freq
                   * (1.0f - pos) + formantpar[p2][i].freq * pos)
                * formantslowness;

            currentformants[i].amp =
                currentformants[i].amp * (1.0f - formantslowness)
                + (formantpar[p1][i].amp * (1.0f - pos)
                   + formantpar[p2][i].amp * pos) * formantslowness;

            currentformants[i].q = currentformants[i].q
                                   * (1.0f - formantslowness)
                                   + (formantpar[p1][i].q * (1.0f - pos)
                                      + formantpar[p2][i].q
                                      * pos) * formantslowness;


            formant[i]->setfreq_and_q(currentformants[i].freq,
                                      currentformants[i].q * Qfactor);
        }

    oldQfactor = Qfactor;
}
コード例 #17
0
ファイル: Chorus.C プロジェクト: dtimms/rakarrack
/*
 * Apply the effect
 */
void
Chorus::out (float * smpsl, float * smpsr)
{
    int i;
    float tmp;
    dl1 = dl2;
    dr1 = dr2;
    lfo.effectlfoout (&lfol, &lfor);

    if(awesome_mode) { //use interpolated delay line for better sound
        float tmpsub;

        dl2 = delay + lfol * depth;
        dr2 = delay + lfor * depth;
        if (Poutsub != 0) tmpsub = -1.0f;
        else tmpsub = 1.0f;

        for (i = 0; i < PERIOD; i++) {
            //Left
            mdel = (dl1 * (float)(PERIOD - i) + dl2 * (float)i) / fPERIOD;
            tmp = smpsl[i] + oldl*fb;
            efxoutl[i] = tmpsub*ldelay->delay(tmp, mdel, 0, 1, 0);
            oldl = efxoutl[i];

            //Right
            mdel = (dr1 * (float)(PERIOD - i) + dr2 * (float)i) / fPERIOD;
            tmp = smpsr[i] + oldr*fb;
            efxoutr[i] = tmpsub*rdelay->delay(tmp, mdel, 0, 1, 0);
            oldr =  efxoutr[i];
        }

    } else {

        dl2 = getdelay (lfol);
        dr2 = getdelay (lfor);
        for (i = 0; i < PERIOD; i++) {
            float inl = smpsl[i];
            float inr = smpsr[i];
            //LRcross
            float l = inl;
            float r = inr;
            inl = l * (1.0f - lrcross) + r * lrcross;
            inr = r * (1.0f - lrcross) + l * lrcross;

            //Left channel

            //compute the delay in samples using linear interpolation between the lfo delays
            mdel = (dl1 * (float)(PERIOD - i) + dl2 * (float)i) / fPERIOD;
            if (++dlk >= maxdelay)
                dlk = 0;
            float tmp = (float) dlk - mdel + (float)maxdelay * 2.0f;	//where should I get the sample from

            F2I (tmp, dlhi);
            dlhi %= maxdelay;

            dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
            dllo = 1.0f - fmodf (tmp, 1.0f);
            efxoutl[i] = delayl[dlhi2] * dllo + delayl[dlhi] * (1.0f - dllo);
            delayl[dlk] = inl + efxoutl[i] * fb;

            //Right channel

            //compute the delay in samples using linear interpolation between the lfo delays
            mdel = (dr1 * (float)(PERIOD - i) + dr2 * (float)i) / fPERIOD;
            if (++drk >= maxdelay)
                drk = 0;
            tmp = (float)drk - mdel + (float)maxdelay * 2.0f;	//where should I get the sample from

            F2I (tmp, dlhi);
            dlhi %= maxdelay;

            dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
            dllo = 1.0f - fmodf (tmp, 1.0f);
            efxoutr[i] = delayr[dlhi2] * dllo + delayr[dlhi] * (1.0f - dllo);
            delayr[dlk] = inr + efxoutr[i] * fb;

        };


        if (Poutsub != 0)
            for (i = 0; i < PERIOD; i++) {
                efxoutl[i] *= -1.0f;
                efxoutr[i] *= -1.0f;
            };


        for (int i = 0; i < PERIOD; i++) {
            efxoutl[i] *= panning;
            efxoutr[i] *= (1.0f - panning);
        };

    } //end awesome_mode test
};
コード例 #18
0
ファイル: Line.cpp プロジェクト: eseawind/CNCS_PMC-Conductor
void CLine::Format(long left, long top, long right, long bottom, long flag)
{
    long ldx,ldy;
    switch(flag) {
    case FM_A2L:
        ldx=left-Left();
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2C:
        ldx=(left+right-Left()-Right())/2;
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2R:
        ldx=right-Right();
        m_lx1+=ldx;
        m_lx2+=ldx;
        break;
    case FM_A2T:
        ldy=top-Top();
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2M:
        ldy=(top+bottom-Top()-Bottom())/2;
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2B:
        ldy=bottom-Bottom();
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_A2CM:
        ldx=(left+right-Left()-Right())/2;
        m_lx1+=ldx;
        m_lx2+=ldx;
        ldy=(top+bottom-Top()-Bottom())/2;
        m_ly1+=ldy;
        m_ly2+=ldy;
        break;
    case FM_R2W:
        ldx=(left+right)/2;
        ldy=(top+bottom)/2;
        R2W(ldx,ldy,&m_lx1,&m_ly1);
        R2W(ldx,ldy,&m_lx2,&m_ly2);
        break;
    case FM_R2U:
        ldx=(left+right)/2;
        ldy=(top+bottom)/2;
        R2U(ldx,ldy,&m_lx1,&m_ly1);
        R2U(ldx,ldy,&m_lx2,&m_ly2);
        break;
    case FM_F2Z:
        ldx=(left+right)/2;
        F2Z(ldx,&m_lx1);
        F2Z(ldx,&m_lx2);
        break;
    case FM_F2I:
        ldy=(top+bottom)/2;
        F2I(ldy,&m_ly1);
        F2I(ldy,&m_ly2);
        break;
    case FM_S2G:
        break;
    }
}