Beispiel #1
0
int C2F(genmcopy)(int *typ, int *a, int *na, int *b, int *nb, int *m, int *n)
{
    static int i, j, ia, ib, mn;
    switch (*typ)
    {
        case 1:
            MCOPY(integer1);
            break;
        case 2:
            MCOPY(integer2);
            break;
        case 4:
            MCOPY(int) ;
            break;
        case 11:
            MCOPY(unsigned char);
            break;
        case 12:
            MCOPY(unsigned short);
            break;
        case 14:
            MCOPY(unsigned int);
            break;
    }
    return 0;
}
Beispiel #2
0
AFILE *
AFwrWVhead (FILE *fp, struct AF_write *AFw)

{
  AFILE *AFp;
  int Lw;
  long int size, Ldata;
  struct WV_CKRIFF CKRIFF;

/* Set the long jump environment; on error return a NULL */
  if (setjmp (AFW_JMPENV))
    return NULL;	/* Return from a header write error */

/* Set up the encoding parameters */
  Lw = AF_DL[AFw->DFormat.Format];
  if (AFw->Nframe != AF_NFRAME_UNDEF)
    Ldata = AFw->Nframe * AFw->Nchan * Lw;
  else if (FLseekable (fp))
    Ldata = 0L;
  else {
    UTwarn ("AFwrWVhead - %s", AFM_WV_WRAccess);
    return NULL;
  }

  /* RIFF chunk */
  MCOPY ("RIFF", CKRIFF.ckID);
  /* defer filling in the chunk size */ 
  MCOPY ("WAVE", CKRIFF.WAVEID);

  /* fmt chunk */
  AF_setFMT (&CKRIFF.CKfmt, AFw);

  /* fact chunk */
  if (CKRIFF.CKfmt.wFormatTag != WAVE_FORMAT_PCM) {
    MCOPY ("fact", CKRIFF.CKfact.ckID);
    CKRIFF.CKfact.ckSize = (UT_uint4_t) sizeof (CKRIFF.CKfact.dwSampleLength);
    CKRIFF.CKfact.dwSampleLength = (UT_uint4_t) 0;
  }

  /* data chunk */
  MCOPY ("data", CKRIFF.CKdata.ckID);
  CKRIFF.CKdata.ckSize = (UT_uint4_t) Ldata;

  /* Fill in the RIFF chunk size */
  size = 4 + 8 + RNDUPV(CKRIFF.CKfmt.ckSize, ALIGN) +
             8 + RNDUPV(CKRIFF.CKdata.ckSize, ALIGN);
  if (CKRIFF.CKfmt.wFormatTag != WAVE_FORMAT_PCM)
    size += 8 + RNDUPV(CKRIFF.CKfact.ckSize, ALIGN);
  CKRIFF.ckSize = (UT_uint4_t) size;

/* Write out the header (error return via longjmp) */
  AFw->DFormat.Swapb = DS_EL;
  AF_wrRIFF (fp, &CKRIFF);

/* Set the parameters for file access */
  AFp = AFsetWrite (fp, FT_WAVE, AFw);

  return AFp;
}
Beispiel #3
0
void mpolsub(MPOL *p, MPOL *q, MPOL *r)
{

  register ip=0,iq=0,is=0;
  MPOL s;

  POL_ALLOC(&s,p->nterms + q->nterms);
  while ((ip<p->nterms)&&(iq<q->nterms)) {
#if (! INTR)
    (*PollPtr)();
#endif
    switch ((*cmp_exp)(MEXPO(p,ip),MEXPO(q,iq))) {
    case 1 : expocopy(MEXPO(p,ip),MEXPO(&s,is));
      MCOPY(&(p->coefs[ip]),&(s.coefs[is]));
      ip++;is++;break;
    case -1 : expocopy(MEXPO(q,iq),MEXPO(&s,is));
      MCOPY(&(q->coefs[iq]),&(s.coefs[is]));
      mnegate(&(s.coefs[is]));
      iq++;is++;break;
    case 0 : MCOPY(&(q->coefs[iq]),&(s.coefs[is]));
      mnegate(&(s.coefs[is]));
      madd(&(p->coefs[ip]),&(s.coefs[is]),&(s.coefs[is]));		
      if (mtest(&(s.coefs[is]))) {
	expocopy(MEXPO(p,ip),MEXPO(&s,is));
	is++;
      };
      ip++;iq++;
    };
  };
  while (ip<p->nterms) {
#if (! INTR)
    (*PollPtr)();
#endif
    expocopy(MEXPO(p,ip),MEXPO(&s,is));
    MCOPY(&(p->coefs[ip]),&(s.coefs[is]));
    ip++; is++;
  };
  while (iq<q->nterms) {
#if (! INTR)
    (*PollPtr)();
#endif
    expocopy(MEXPO(q,iq),MEXPO(&s,is));
    MCOPY(&(q->coefs[iq]),&(s.coefs[is]));
    mnegate(&(s.coefs[is]));
    iq++; is++;
  };
  s.nterms = is;
  if (is==0){
    xfree((char *)s.coefs);
    xfree((char *)s.expos);
  };

  mpolfree(r);	
  MPOLMOVEFREE(&s,r);
};
Beispiel #4
0
void mpolunit(MPOL *p, MINT *coef, MPOL *q)
{ 
  register i;
  MINT *resco,rem;
  MPOL res;


  if (p->nterms==0) {
	mpolfree(q);
	mset(0,coef);
	return;
  };
  
  MINIT(&rem);
  MFREE(coef);
  MCOPY(&(p->coefs[0]),coef);
  for (i=1;i<p->nterms;i++)
	mgcd(coef,&(p->coefs[i]),coef);

  MPOLINIT(&res);

  res.nterms = p->nterms;
  POL_ALLOC(&res,p->nterms); 
  resco = res.coefs;
  for (i=0;i<p->nterms;i++){
	MINIT(resco);
	mdiv(&(p->coefs[i]),coef,(resco++),&rem);
	expocopy(MEXPO(p,i),MEXPO(&res,i));
  }
  mpolfree(q);
  MPOLMOVEFREE(&res,q);
  MFREE(&rem);
}
//_____________________________________________
uint32_t AUDMAudioFilterMixer::fill(uint32_t max,float *output,AUD_Status *status)
{

    uint32_t rd = 0;
    uint8_t *in,*out;
    int nbSampleMax=max/_wavHeader.channels;
    uint8_t input_channels = _previous->getInfo()->channels;

// Fill incoming buffer
    shrink();
    fillIncomingBuffer(status);
    // Block not filled ?
    if((_tail-_head)<input_channels)
    {
      if(*status==AUD_END_OF_STREAM && _head)
      {
        memset(&_incomingBuffer[_head],0,sizeof(float) * input_channels);
        _tail=_head+input_channels;
        printf("[Mixer] Warning asked %u symbols\n",max);
      }
      else
      {
        return 0;
      }
    }
    // How many ?

    // Let's go
    int processed=0;
    int available=0;
    if(!nbSampleMax)
    {
      printf("[Mixer] Warning max %u, channels %u\n",max,input_channels);
    }
    available=(_tail-_head)/input_channels; // nb Sample
    ADM_assert(available);
    if(available > nbSampleMax) available=nbSampleMax;
    
    ADM_assert(available);
    

    // Now do the downsampling
	if (_output == CHANNEL_INVALID || true==ADM_audioCompareChannelMapping(&_wavHeader, _previous->getInfo(),
			_previous->getChannelMapping(),outputChannelMapping))
	{
		
		rd= (uint32_t)MCOPY(&_incomingBuffer[_head],output,available,input_channels);
	} else 
	{
		MIXER *call=matrixCall[_output];
		rd= (uint32_t)call(&_incomingBuffer[_head],output,available,input_channels,_previous->getChannelMapping());
	}

    _head+=available*input_channels;
    return rd;
    
}
Beispiel #6
0
Datei: Mgcd.c Projekt: 8l/csolve
void mgcd(MINT *a, MINT *b, MINT *c)
{	MINT x,y,z,w;

	MCOPY(a,&x);
	MCOPY(b,&y);
	MINIT(&z);
	MINIT(&w);

	while( mtest(&y) != 0)
	{	mdiv(&x,&y,&w,&z);
		mmove(&y,&x);
		mmove(&z,&y);
#if (! INTR)
		(*PollPtr)();
#endif
	}
	mmove(&x,c);
	MFREE(&y);
	MFREE(&z);
	MFREE(&w);
	return;
}
Beispiel #7
0
static void
AF_setFMT (struct WV_CKfmt *CKfmt, const struct AF_write *AFw)

{
  int Lw, Ext, Res, NbS;
  UT_uint2_t FormatTag;

  Lw = AF_DL[AFw->DFormat.Format];
  Res = 8 * Lw;
  NbS = AFw->DFormat.NbS;

  /* Determine whether to use an extensible header */
  Ext = 0;
  if (AFw->Ftype == FTW_WAVE)
    Ext = (AFw->Nchan > 2 || NbS != Res ||
	   AFw->DFormat.Format == FD_INT24 ||
	   AFw->DFormat.Format == FD_INT32 ||
	   (AFw->SpkrConfig[0] != AF_X_SPKR && AFw->SpkrConfig[0] != '\0'));

  switch (AFw->DFormat.Format) {
  case FD_UINT8:
  case FD_INT16:
  case FD_INT24:
  case FD_INT32:
    FormatTag = WAVE_FORMAT_PCM;
    break;
  case FD_MULAW8:
    FormatTag = WAVE_FORMAT_MULAW;
    break;
  case FD_ALAW8:
    FormatTag = WAVE_FORMAT_ALAW;
    break;
  case FD_FLOAT32:
  case FD_FLOAT64:
    FormatTag = WAVE_FORMAT_IEEE_FLOAT;
    break;
  default:
    FormatTag = WAVE_FORMAT_UNKNOWN;
    assert (0);
  }

  /* Set the chunk size (minimum size for now) */
  MCOPY ("fmt ", CKfmt->ckID);
  CKfmt->ckSize = sizeof (CKfmt->wFormatTag) + sizeof (CKfmt->nChannels)
    + sizeof (CKfmt->nSamplesPerSec) + sizeof (CKfmt->nAvgBytesPerSec)
    + sizeof (CKfmt->nBlockAlign) + sizeof (CKfmt->wBitsPerSample);

  CKfmt->nChannels = (UT_uint2_t) AFw->Nchan;
  CKfmt->nSamplesPerSec = (UT_uint4_t) (AFw->Sfreq + 0.5);	/* Rounding */
  CKfmt->nAvgBytesPerSec = (UT_uint4_t) (CKfmt->nSamplesPerSec * AFw->Nchan * Lw);
  CKfmt->nBlockAlign = (UT_uint2_t) (Lw * AFw->Nchan);

  if (Ext) {
    CKfmt->wBitsPerSample = (UT_uint2_t) Res;
    CKfmt->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
    CKfmt->cbSize = 22;
    if (FormatTag == WAVE_FORMAT_PCM || FormatTag == WAVE_FORMAT_IEEE_FLOAT)
      CKfmt->wValidBitsPerSample = (UT_uint2_t) NbS;
    else
      CKfmt->wValidBitsPerSample = (UT_uint2_t) Res;
    CKfmt->dwChannelMask = AF_encChannelConfig (AFw->SpkrConfig);
    CKfmt->SubFormat.wFormatTag = FormatTag;
    MCOPY (WAVEFORMATEX_TEMPLATE.guidx, CKfmt->SubFormat.guidx);
  }
  else {
    /* Use wBitsPerSample to specify the "valid bits per sample" */
    if (RNDUPV(NbS, 8) != Res) {
      UTwarn (AFMF_WV_InvNbS, "AFwrWVhead -", NbS, Res);
      NbS = Res;
    }
    CKfmt->wBitsPerSample = (UT_uint2_t) NbS;
    CKfmt->wFormatTag = FormatTag;
    CKfmt->cbSize = 0;
  }

  /* Update the chunk size with the size of the chunk extension */
  if (CKfmt->wFormatTag != WAVE_FORMAT_PCM)
    CKfmt->ckSize += (sizeof (CKfmt->cbSize) + CKfmt->cbSize);

  return;
}