Beispiel #1
0
static int ifd_process(CSOUND * csound, IFD * p)
{
  int     i;
  MYFLT  *sigin = p->in;
  MYFLT  *sigframe = (MYFLT *) p->sigframe.auxp;
  int     fftsize = p->fftsize;
  int    *counter = (int *) p->counter.auxp;
  uint32_t offset = p->h.insdshead->ksmps_offset;
  uint32_t early  = p->h.insdshead->ksmps_no_end;
  uint32_t n, nsmps = CS_KSMPS;
  int     frames = p->frames;
  //int     cnt = p->cnt;

  if (UNLIKELY(early)) nsmps -= early;
  for (n = offset; n < nsmps; n++) {
    for (i = 0; i < frames; i++) {
      sigframe[i * fftsize + counter[i]] = sigin[n];
      counter[i]++;
      if (counter[i] == fftsize) {
        //if (cnt < frames)
        // cnt++;
        //else
        IFAnalysis(csound, p, &sigframe[i * fftsize]);
        counter[i] = 0;
      }
    }
  }
  //p->cnt = cnt;

  return OK;
}
Beispiel #2
0
short
IFGram::DoProcess(){

  if(!m_error){
    if(m_input){
      if(m_enable){
	int i; float sig = 0.f;
	for(m_vecpos = 0; m_vecpos < m_hopsize; m_vecpos++) {
	  // signal input
	  sig = m_input->Output(m_vecpos);		
	  // distribute to the signal input frames
	  // according to a time pointer (kept by counter[n])
	  for(i=0;i < m_frames; i++){
	    m_sigframe[i][m_counter[i]]= (float) sig; 
	    m_counter[i]++;		   
	  } 
	}
	// every vecsize samples
	// set the current fftframe to be transformed
	m_cur--; if(m_cur<0) m_cur = m_frames-1;  
 
	// instant frequency analysis
	IFAnalysis(m_sigframe[m_cur]);
	// zero the current fftframe time pointer


	m_counter[m_cur] = 0;
	return 1;

      } else { // if disabled, reset the fftframes
	for(m_vecpos =0; m_vecpos < m_hopsize; m_vecpos++)
	  m_output[m_vecpos] = 0.f;
	return 1;
      }

    } else {
      m_error = 3;
      return 0;
    }
  }
  else 
    return 0;
}
Beispiel #3
0
static int tifd_process(CSOUND * csound, IFD * p)
{
  int     hopsize = p->hopsize;
  uint32_t nsmps = CS_KSMPS;

  if(p->cnt >= hopsize){
    MYFLT  pos = *p->in*csound->GetSr(csound);
    MYFLT  *sigframe = (MYFLT *) p->sigframe.auxp;
    MYFLT  pit = *p->p3;
    int     fftsize = p->fftsize;
    int post;
    MYFLT frac;
    FUNC *ft = csound->FTnp2Find(csound,p->p7);
    if (ft == NULL){
      csound->PerfError(csound, p->h.insdshead,
                        "could not find table number %d\n", (int) *p->p7);
      return NOTOK;
    }
    MYFLT *tab = ft->ftable;
    int i,size = ft->flen;
    for(i=0; i < fftsize; i++){
      MYFLT in;
      post = (int) pos;
      frac = pos  - post;
      while (post >= size) post -= size;
      while (post < 0) post += size;
      in = tab[post] + frac*(tab[post+1] - tab[post]);
      sigframe[i] = in;
      pos += pit;
    }
    p->g = *p->p2;
    IFAnalysis(csound, p, sigframe);
    p->cnt -= hopsize;
  }
  p->cnt += nsmps;
  return OK;
}