示例#1
0
文件: dlm_xft.c 项目: thias42/dLabPro
/**
 * Computes the complex (inverse) fast Fourier transform.
 * 
 * @param RE
 *          Pointer to an array containing the real part of the input, will be
 *          overwritten with real part of output.
 * @param IM
 *          Pointer to an array containing the imaginary part of the input, will
 *          be overwritten with imaginary part of output.
 * @param nXL
 *          Length of signals, must be a power of 2 (otherwise the function will
 *          return an <code>ERR_MDIM</code> error)
 * @param bInv
 *          If non-zero the function computes the inverse complex Fourier
 *          transform
 * @return <code>O_K</code> if successfull, a (begative) error code otherwise
 * 
 * <h4>Remarks</h4>
 * <ul>
 *   <li>The function creates the tables by its own, stores them in static arrays and
 *   reuses them for all subsequent calls with the same value of <code>nXL</code>.</li>
 * </ul>
 */
INT16 dlm_fft
(
  FLOAT64*       RE,
  FLOAT64*       IM,
  INT32          nXL,
  INT16          bInv
)
{
  extern int ifft(FLOAT64*,FLOAT64*,const int);
  extern int fft(FLOAT64*,FLOAT64*,const int);
  INT16  order;

  /* Initialize */                                                               /* --------------------------------- */
  order = (INT16)dlm_log2_i(nXL);                                                /* Compute FFT order                 */
  if (order<=0) return ERR_MDIM;                                                 /* nXL is not power of 2 --> ://     */
#ifndef __NOXALLOC
  DLPASSERT(dlp_size(RE)>=nXL*sizeof(FLOAT64));                                  /* Assert RE has the right length    */
  DLPASSERT(dlp_size(IM)>=nXL*sizeof(FLOAT64));                                  /* Assert IM has the right length    */
#endif

  if(bInv) {
    if(ifft(RE,IM,nXL) != 0) return NOT_EXEC;
  } else {
    if(fft(RE,IM,nXL) != 0) return NOT_EXEC;
  }

  return O_K;                                                                    /* All done                          */
}
示例#2
0
文件: dlm_chf.c 项目: gitgun/dLabPro
INT16 dlm_cholfC(COMPLEX64* Z, const COMPLEX64* A, INT32 nXD) {
  integer info = 0;
  integer n = (integer) nXD;
  char uplo[1] = { 'U' };
#ifdef __MAX_TYPE_32BIT
  extern int clacpy_(char*,integer*,integer*,complex*,integer*,complex*,integer *ldb);
  extern int cpotrf_(char*,integer*,complex*,integer*,integer*);
#else
  extern int zlacpy_(char*,integer*,integer*,doublecomplex*,integer*,doublecomplex*,integer *ldb);
  extern int zpotrf_(char*,integer*,doublecomplex*,integer*,integer*);
#endif

  /* Declare variables */
  DLPASSERT(Z != A);                                                            /* Assert input is not output        */
  DLPASSERT(dlp_size(Z) >= nXD * nXD * sizeof(FLOAT64));                        /* Check size of output buffer       */
  DLPASSERT(dlp_size(A) >= nXD * nXD * sizeof(FLOAT64));                        /* Check size of input buffer        */

  /* ... computation ... *//* --------------------------------- */
#ifdef __MAX_TYPE_32BIT
  cpotrf_(uplo, &n, (complex*)A, &n, &info);
  clacpy_(uplo, &n, &n, (complex*)A, &n, (complex*)Z, &n);
#else
  zpotrf_(uplo, &n, (doublecomplex*)A, &n, &info);
  zlacpy_(uplo, &n, &n, (doublecomplex*)A, &n, (doublecomplex*)Z, &n);
#endif
  return (info == 0) ? O_K : NOT_EXEC; /* All done successfully             */
}
示例#3
0
/*
 * Synthesis using pitch marks.
 *
 * Derived instances of FBAproc should override method
 * SynthesizePM() to add the desired functionality
 *
 * @return O_K if successfull, NOT_EXEC otherwise
 */
INT16 CGEN_VPROTECTED CFBAproc::SynthesizeUsingPM(data *idFea, data *idPm, data *idSyn) {
  CData   *idExcite    = NULL;
  FLOAT64 *excitation  = NULL;
  FLOAT64 *synthesis   = NULL;
  INT32    nSamples    = 0;
  INT16    nPer        = 0;
  INT32    nCompVuv    = idFea->FindComp("v/uv");
  INT16    nCompFea    = idFea->GetNNumericComps() - (nCompVuv >= 0 ? 1 : 0);
  INT32    iRecFea     = 0;
  INT32    nRecFea     = 0;

  AlignFramesToPitch(idPm, idFea, idFea);

  nRecFea = idFea->GetNRecs();

  if(m_bSynEnhancement) {
    for(iRecFea = 0; iRecFea < nRecFea; iRecFea++) {
      FeaEnhancement((FLOAT64*)idFea->XAddr(iRecFea,0), nCompFea);
    }
  }

  Smooth(idFea, idPm, idFea);

  // Generate modulated excitation
  ICREATEEX(CData,idExcite,"~idExcite",NULL);
  DLPASSERT(O_K==ModEx(idPm,idExcite));
  DLPASSERT(!idExcite->IsEmpty());

  nSamples = idExcite->GetNRecs();

  idSyn->Reset();
  idSyn->AddComp("syn", T_DOUBLE);
  idSyn->Allocate(nSamples);

  excitation = (FLOAT64*)idExcite->XAddr(0, 0);
  synthesis = (FLOAT64*)idSyn->XAddr(0, 0);

  for(INT32 currSample = 0, currPer = 0; (currSample < nSamples) && (currPer < idFea->GetNRecs()); currSample += nPer, currPer++) {
    nPer = (INT16)idPm->Dfetch(currPer,0);

    if(SynthesizeFrame((FLOAT64*)idFea->XAddr(currPer,0), nCompFea, excitation+currSample, nPer, synthesis+currSample) != O_K) {
      IDESTROY(idExcite);
      return IERROR(this,FBA_SYNTHESISE, currPer, 0,0);
    }
  }

  IDESTROY(idExcite);

  if (m_nMinLog != 0.0) for (INT32 i=0; i<idSyn->GetNRecs(); i++) *((FLOAT64*)idSyn->XAddr(0, 0)+i) *= exp(m_nMinLog);

  return O_K;
}
示例#4
0
文件: data_prt.c 项目: gitgun/dLabPro
/**
 * Prints the instance in text mode (exactly one component of type 1).
 */
INT16 CGEN_PRIVATE CData_PrintText(CData* _this)
{
  INT32  nR   = 0;                                                               /* Current record                    */
  INT32  nXR  = 0;                                                               /* Number of records                 */
  char* tx   = NULL;                                                            /* Auxilary char pointer #1          */
  char* tx0  = NULL;                                                            /* Pointer to string                 */
  char* ty   = NULL;                                                            /* Auxilary char pointer #2          */
  char* ty0  = NULL;                                                            /* Pointer to last white space       */
  INT32  nCtr = 0;                                                               /* Line counter                      */
  char  sBuf[255];                                                              /* Printing buffer                   */

  /* Initialize */                                                              /* --------------------------------- */
  nXR = CData_GetNRecs(_this);                                                  /* Get number of records             */

  /* Print data contents as text */                                             /* --------------------------------- */
  DLPASSERT(FMSG("ALPHA: String mode not tested yet"));                         /* TODO: Remove after debugging      */
  printf("\n  String Mode"); dlp_inc_printlines(1);                             /* Protocol                          */
  tx0=tx=(char*)CData_XAddr(_this,0,0);                                         /* Initialize char pointers          */
  if (!*tx)                                                                     /* Empty string                      */
  {                                                                             /* >>                                */
    printf("\n  [empty]");                                                      /*   Protocol                        */
    dlp_inc_printlines(1);                                                      /*   Adjust no. of printed lines     */
  }                                                                             /* <<                                */
  else while (*tx)                                                              /* Loop over characters              */
  {                                                                             /* >>                                */
    /* Make line breaks */                                                      /*   - - - - - - - - - - - - - - - - */
    for (ty=tx,ty0=NULL; *ty && ty<tx0+nXR; )                                   /*   Do until end of string          */
    {                                                                           /*   >>                              */
      while (*ty && ty<tx0+nXR && !iswspace(*ty)) ty++;                         /*     Seek next white space         */
      while (*ty && ty<tx0+nXR &&  iswspace(*ty)) ty++;                         /*     Skip following white spaces   */
      ty0=ty;                                                                   /*     Remember previous white spc.  */
      if (ty>tx+dlp_maxprintcols()-16) break;                                   /*     Line full                     */
    }                                                                           /*   <<                              */
    if (ty0) ty=ty0;                                                            /*   Go back to last white space     */

    /* Print one line */                                                        /*   - - - - - - - - - - - - - - - - */
    dlp_memset(sBuf,0,255);                                                     /*   Clear printing buffer           */
    dlp_memmove(sBuf,tx,ty-tx);                                                 /*   Copy characters in              */
    printf("\n  %4d(%06d): %s",(int)nCtr,(int)(tx-tx0),sBuf);                   /*   Print 'em                       */
    dlp_inc_printlines(1);                                                      /*   Adjust no. of printed lines     */
    if (dlp_if_printstop()) break;                                              /*   Break listing                   */

    /* End-of-line actions */                                                   /*   - - - - - - - - - - - - - - - - */
    DLPASSERT(ty>tx);                                                           /*   Should have made some progress  */
    tx=ty;                                                                      /*   Move to end of printed line     */
    nCtr++;                                                                     /*   Increment line counter          */
  }                                                                             /* <<                                */
  if (nR>=nXR) printf("\n  No more data - Stop.");                              /* Protocol                          */
  else         printf("\n  Cancelled - Stop.");                                 /* Protocol                          */
  return O_K;                                                                   /* Ok                                */
}
示例#5
0
/*
 * Manual page at function.def
 */
INT16 CGEN_PUBLIC CFunction::OnGet()
{
  // Delegate to running function                                               // ------------------------------------
  FNC_DELEGATE OnGet();                                                         // Use a weird macro (see function.def)

  // Initialize                                                                 // ------------------------------------
  CDlpObject* iCont = GetActiveInstance();                                      // Determine field container
  const char* lpsId = GetNextToken(TRUE);                                       // Determine field name

  // Validate                                                                   // ------------------------------------
  DLPASSERT(iCont);                                                             // Check set target
  if (!dlp_strlen(lpsId))                                                       // If no field name committed
    return IERROR(this,FNC_EXPECT,"field identifier after -get",0,0);           //   Error
  SWord* lpWrd = iCont->FindWord(lpsId,WL_TYPE_FIELD);                          // Find field in container
  if (!lpWrd)                                                                   // If not found
  {                                                                             // >>
    iCont = this;                                                               //   Use this instance as container
    lpWrd = FindWord(lpsId,WL_TYPE_FIELD);                                      //   And seek again
  }                                                                             // <<
  if (!lpWrd) return IERROR(this,ERR_NOTFIELD,lpsId,0,0);                       // If still not found --> Error

  // Push field value                                                           // ------------------------------------
  switch (lpWrd->ex.fld.nType)                                                  // Branch for field variable type
  {                                                                             // >>
    case T_BOOL    : { PushLogic   (      *(     BOOL*)lpWrd->lpData);  break; }// - Boolean
    case T_UCHAR   : { PushNumber  (CMPLX(*(    UINT8*)lpWrd->lpData)); break; }// - Unsigned character
    case T_CHAR    : { PushNumber  (CMPLX(*(     INT8*)lpWrd->lpData)); break; }// - Signed character
    case T_USHORT  : { PushNumber  (CMPLX(*(   UINT16*)lpWrd->lpData)); break; }// - Unsigned short integer
    case T_SHORT   : { PushNumber  (CMPLX(*(    INT16*)lpWrd->lpData)); break; }// - Signed short integer
    case T_UINT    : { PushNumber  (CMPLX(*(   UINT32*)lpWrd->lpData)); break; }// - Unsigned integer
    case T_INT     : { PushNumber  (CMPLX(*(    INT32*)lpWrd->lpData)); break; }// - Signed integer
    case T_ULONG   : { PushNumber  (CMPLX(*(   UINT64*)lpWrd->lpData)); break; }// - Unsigned long integer
    case T_LONG    : { PushNumber  (CMPLX(*(    INT64*)lpWrd->lpData)); break; }// - Signed long integer
    case T_FLOAT   : { PushNumber  (CMPLX(*(  FLOAT32*)lpWrd->lpData)); break; }// - Single precision floating point
    case T_DOUBLE  : { PushNumber  (CMPLX(*(  FLOAT64*)lpWrd->lpData)); break; }// - Double precision floating point
    case T_COMPLEX : { PushNumber  (      *(COMPLEX64*)lpWrd->lpData);  break; }// - Double precision complex floating point
    case T_INSTANCE: { PushInstance(*(CDlpObject**) lpWrd->lpData);     break; }// - Instance
    case T_TEXT    : /* Fall through */                                         // - Text (deprecated type!)
    case T_CSTRING : /* Fall through */                                         // - Constant string
    case T_STRING  : { PushString(*(char**)         lpWrd->lpData); break;     }// - String
    default        : {                                                          // - Other types
      if (lpWrd->ex.fld.nType > 0 && lpWrd->ex.fld.nType <= 256)                //     Character array?
        PushString((char*)lpWrd->lpData);                                       //       Push value
      else                                                                      //     Type unknown!
        DLPASSERT(FMSG("Unknown field type"));                                  //       Error
    }                                                                           //   <<
  }                                                                             // <<

  return O_K;                                                                   // Done.
}
示例#6
0
文件: sta_upd.c 项目: thias42/dLabPro
/**
 * Updates the statistics with one vector. There are no checks performed!
 *
 * @param _this
 *          Pointer to this CStatistics instance
 * @param lpX
 *          Pointer to a buffer containing the vector to update the statistics
 *          with (is expected to contain <i>N</i> = <code>{@link dat}.dim</code>
 *          double values)
 * @param c
 *          Index of class this vector belongs to (0 &le; <code>k</code> &lt;
 *          <i>C</i> = <code>{@link dat}.nblock</code>)
 */
INT16 CGEN_PROTECTED CStatistics_UpdateVector
(
  CStatistics* _this,
  FLOAT64*      lpX,
  INT32         c,
  FLOAT64       w
)
{
  INT32    i     = 0;                                                            /* Mixed sum index                   */
  INT32    k     = 0;                                                            /* Order loop counter (for k>2)      */
  INT32    n     = 0;                                                            /* 1st dimension loop couner         */
  INT32    m     = 0;                                                            /* 2nd dimension loop couner         */
  INT32    K     = 0;                                                            /* Statistics order                  */
  INT32    N     = 0;                                                            /* Statistics dimensionality         */
  FLOAT64* lpSsz = NULL;                                                         /* Ptr. to class' c sample size      */
  FLOAT64* lpMin = NULL;                                                         /* Ptr. to class' c minimum vector   */
  FLOAT64* lpMax = NULL;                                                         /* Ptr. to class' c maximum vector   */
  FLOAT64* lpSum = NULL;                                                         /* Ptr. to class' c sum vector       */
  FLOAT64* lpMsm = NULL;                                                         /* Ptr. to class' c mixed sum matrix */
  FLOAT64* lpKsm = NULL;                                                         /* Ptr. to class' c k-th ord.sum vec.*/

  /* Validate */                                                                /* --- DEBUG ONLY ------------------ */
  DLPASSERT(_this);                                                             /* Check this pointer                */
  DLPASSERT(_this->m_idDat);                                                    /* Check statistics data table       */
  DLPASSERT((INT32)(dlp_size(lpX)/sizeof(FLOAT64)) == CStatistics_GetDim(_this)); /* Check update vector buffer        */
  DLPASSERT(c>=0 && c<CStatistics_GetNClasses(_this));                          /* Check class index                 */

  /* Initialize */                                                              /* --------------------------------- */
  K = CStatistics_GetOrder(_this);                                              /* Get statistics order              */
  N = CStatistics_GetDim(_this);                                                /* Get statistics dimensionality     */
  DLPASSERT((lpSsz = CStatistics_GetPtr(_this,c,STA_DAI_SSIZE)));               /* Get ptr. to class' c sample size  */
  DLPASSERT((lpMin = CStatistics_GetPtr(_this,c,STA_DAI_MIN  )));               /* Get ptr. to class' c min. vector  */
  DLPASSERT((lpMax = CStatistics_GetPtr(_this,c,STA_DAI_MAX  )));               /* Get ptr. to class' c max. vector  */
  DLPASSERT((lpSum = CStatistics_GetPtr(_this,c,STA_DAI_SUM  )));               /* Get ptr. to class' c sum vector   */
  DLPASSERT((lpMsm = CStatistics_GetPtr(_this,c,STA_DAI_MSUM )));               /* Get ptr. to class' c mix.sum.matr.*/
  DLPASSERT((lpKsm = CStatistics_GetPtr(_this,c,STA_DAI_KSUM )) || K<=2);       /* Get ptr. to class' c k-th ord.sum.*/

  /* Update */                                                                  /* --------------------------------- */
  (*lpSsz)+=w;                                                                  /* Increment sample size             */
  for (n=0,i=0; n<N; n++)                                                       /* Loop over dimensions              */
  {                                                                             /* >>                                */
    if (lpMin[n] > lpX[n]) lpMin[n] = lpX[n];                                   /*   Track minimum                   */
    if (lpMax[n] < lpX[n]) lpMax[n] = lpX[n];                                   /*   Track maximum                   */
    lpSum[n] += lpX[n]*w;                                                       /*   Update sum                      */
    for (m=0; m<N; m++,i++) lpMsm[i] += lpX[n]*lpX[m]*w;                        /*   Update mixed sum                */
    for (k=3; k<=K; k++) lpKsm[(k-3)*N+n] += dlm_pow(lpX[n],k)*w;               /*   Update k-th order sums          */
  }                                                                             /* <<                                */

  return O_K;                                                                   /* Done                              */
}
示例#7
0
/**
 *  Convert f0-contour with equal spaced sampling points to pitch markers.
 *
 * @param idSrc        source f0-contour
 * @param idDst        target pitch marker
 * @param n            target sum of pitch marker lengths
 * @param srate        sampling rate
 * @return O_K if sucessfull, not exec otherwise
 */
INT16 CGEN_PUBLIC CPMproc::F02pm(CData *idSrc, CData* idDst, INT32 n, INT32 srate) {

  INT16* p_pm = NULL;
  INT32    n_pm = 0;

  if(CData_IsEmpty(idSrc) == TRUE) return NOT_EXEC;
  if(n <= 0)                       return NOT_EXEC;

  DLPASSERT(CData_GetNComps(idSrc) == 1);

  CREATEVIRTUAL(CData,idSrc,idDst);

  CData_Reset(idDst, TRUE);

  dlm_f02pm((FLOAT64*)idSrc->XAddr(0,0), idSrc->GetNRecs(), &p_pm, &n_pm, n, srate);

  CData_AddComp(idDst, "pm",   T_SHORT);
  CData_AddComp(idDst, "v/uv", T_SHORT);
  CData_Allocate(idDst, n_pm);
  ISETFIELD_RVALUE(idDst, "fsr", 1000.0/srate);

  dlp_memmove(idDst->XAddr(0,0), p_pm, 2*n_pm*sizeof(INT16));

  /* clean up */
  DESTROYVIRTUAL(idSrc,idDst)

  dlp_free(p_pm);

  return(O_K);
}
示例#8
0
INT16 CGEN_PROTECTED CCgen::OnHfile()
{
  char lpName[L_INPUTLINE+1];
  GetNextDefToken(lpName);
  if (!dlp_strlen(lpName)) ERRORRET(ERR_EXPECTAFTER,"name","HFILE:",0,NOT_EXEC);

  switch(m_nCreating)
  {
  case CR_PROJECT:
    return IERROR(this,ERR_INVALSUBKEY,"PROJECT:","HFILE:",0);
  case CR_ERROR:
    return IERROR(this,ERR_INVALSUBKEY,"ERROR:","HFILE:",0);
  case CR_FIELD:
    return IERROR(this,ERR_INVALSUBKEY,"FIELD:","HFILE:",0);
  case CR_OPTION:
    return IERROR(this,ERR_INVALSUBKEY,"OPTION:","HFILE:",0);
  case CR_METHOD:
    return IERROR(this,ERR_INVALSUBKEY,"METHOD:","HFILE:",0);
  case CR_NOTE:
    return IERROR(this,ERR_INVALSUBKEY,"NOTE:","HFILE:",0);
  case CR_ICLS   : {
    SCGIcl* s = m_lpCreatingIcl; DLPASSERT(s);
    dlp_strcpy(s->lpHFile,lpName);
    break; }
  default:
    return IERROR(this,ERR_EXPGLOBALKEY,"HFILE:",0,0);
  }

  return O_K;
}
示例#9
0
/**
 * Base class implementation of destructor.
 *
 * @param _this This instance
 */
void CDlpObject_Destructor(CDlpObject* _this)
{
  SWord*   lpWord;
  hnode_t* hn;
  hscan_t  hs;

  DEBUGMSG(-1,"CDlpObject_Destructor for '%s'",_this->m_lpInstanceName,0,0);

  /* Detach external instances */
  hash_scan_begin(&hs,_this->m_lpDictionary);
  while ((hn = hash_scan_next(&hs))!=NULL)
  {
    DLPASSERT((lpWord = (SWord*)hnode_get(hn))!=NULL); /* NULL entry in dictionary */

    if
    (
      lpWord->nWordType == WL_TYPE_FIELD &&
      lpWord->ex.fld.nType == T_INSTANCE
    )
    {
      CHECK_IPTR(*(CDlpObject**)lpWord->lpData,lpWord->ex.fld.nISerialNum);
      if (CDlpObject_GetParent(*(CDlpObject**)lpWord->lpData)!=_this)
        *(CDlpObject**)lpWord->lpData = NULL;
    }
  }

#ifndef __NORTTI
  /* Clear words */
  if(NOK(CDlpObject_UnregisterAllWords(_this)) )
    IERROR(_this,ERR_DESTROY," Error while UnregisterAllWords of instance %s !",
      _this->m_lpInstanceName,0);
  /* Clear operators */
  if(NOK(CDlpObject_UnregisterAllOperators(_this)) )
    IERROR(_this,ERR_DESTROY," Error while UnregisterAllOperators of instance %s !",
      _this->m_lpInstanceName,0);
#endif

  /* Destroy dictionaries */
  if(!hash_isempty(_this->m_lpObsIds))
    IERROR(_this,ERR_DESTROY,
      " Destructor of instance '%s': hash 'ObsIds' not empty !",
      _this->m_lpInstanceName,0);
  if(!hash_isempty(_this->m_lpDictionary))
    IERROR(_this,ERR_DESTROY,
      " Destructor of instance '%s': hash 'Dictionary' not empty !",
      _this->m_lpInstanceName,0);
  if(!hash_isempty(_this->m_lpOpDict))
    IERROR(_this,ERR_DESTROY,
      " Destructor of instance '%s': hash 'OpDict' not empty !",
      _this->m_lpInstanceName,0);

  hash_destroy(_this->m_lpObsIds    );
  hash_destroy(_this->m_lpDictionary);
  hash_destroy(_this->m_lpOpDict);

#ifdef __cplusplus
  /* Unregister */
  dlp_xalloc_unregister_object(_this);
#endif
}
示例#10
0
INT16 CGEN_PROTECTED CCgen::OnLpath()
{
  char lpName[L_INPUTLINE+1];
  GetNextDefToken(lpName);
  if (!dlp_strlen(lpName)) ERRORRET(ERR_EXPECTAFTER,"name","LPATH:",0,NOT_EXEC);

  switch(m_nCreating)
  {
  case CR_PROJECT: {
    if (m_nAncestor) return O_K;
    else             dlp_convert_name(CN_XLATPATH,m_lpsLPath,lpName);
    break;}
  case CR_ERROR:
    return IERROR(this,ERR_INVALSUBKEY,"ERROR:","LPATH:",0);
  case CR_FIELD:
    return IERROR(this,ERR_INVALSUBKEY,"FIELD:","LPATH:",0);
  case CR_OPTION:
    return IERROR(this,ERR_INVALSUBKEY,"OPTION:","LPATH:",0);
  case CR_METHOD:
    return IERROR(this,ERR_INVALSUBKEY,"METHOD:","LPATH:",0);
  case CR_NOTE:
    return IERROR(this,ERR_INVALSUBKEY,"NOTE:","LPATH:",0);
  case CR_ICLS: {
    SCGIcl* s = m_lpCreatingIcl; DLPASSERT(s);
    dlp_strcpy(s->lpLPath,lpName);
    break; }
  default:
    return IERROR(this,ERR_EXPGLOBALKEY,"LPATH:",0,0);
  }

  return O_K;
}
示例#11
0
/**
 *  Expand/reduce number of pitch markers to new number.
 *
 * @param idSrc        source object
 * @param idDst        target object
 * @param n            target number of pitch markers
 * @return O_K if sucessfull, not exec otherwise
 */
INT16 CGEN_PUBLIC CPMproc::CompressPm(CData *idSrc, CData* idDst, INT32 n)
{
  if(CData_IsEmpty(idSrc) == TRUE) return NOT_EXEC;
  if(n <= 0)                       return NOT_EXEC;

  CREATEVIRTUAL(CData,idSrc,idDst);

  DLPASSERT(CData_GetNComps(idSrc) == 2);
  CData_Reset(idDst, TRUE);
  CData_Scopy(idDst,idSrc);
  CData_Allocate(idDst, n);

  if(dlm_pm_compress((INT16*)CData_XAddr(idSrc,0,0),
                     CData_GetNRecs(idSrc),
                     (INT16*)CData_XAddr(idDst,0,0),
                     CData_GetNRecs(idDst)) != O_K) {
    return IERROR(this,ERR_NULLARG, "", NULL, NULL);
  }
  CData_CopyDescr(idDst,idSrc);

  /* clean up */
  DESTROYVIRTUAL(idSrc,idDst)

  return(O_K);
}
示例#12
0
文件: sta_aux.c 项目: gitgun/dLabPro
/**
 * Fills a data table with the sample size (frequency) or the estimated a-priori
 * probability of the classes.
 *
 * @param _this
 *          Pointer to this CStatistics instance
 * @param idDst
 *          Pointer to the destination data instance
 * @param bProb
 *          If <code>TRUE</code> the method estimates class a-priori
 *          probabilities otherwise it stores the classes' sample sizes
 * @return <code>O_K</code> if successsfull, a (negative) error code otherwise
 */
INT16 CGEN_PUBLIC CStatistics_FreqEx
(
  CStatistics* _this,
  CData*       idDst,
  BOOL         bProb
)
{
  INT32    c     = 0;                                                            /* Class loop counter                */
  INT32    C     = 0;                                                            /* Number of statistics classes      */
  INT32    nTsz  = 0;                                                            /* Total sample size                 */
  FLOAT64* lpSsz = NULL;                                                         /* Pointer to class' c sample size   */

  /* Validate */                                                                /* --------------------------------- */
  if (!idDst) return IERROR(_this,ERR_NULLARG,"idDst",0,0);                     /* Check output data instance        */
  CData_Reset(idDst,TRUE);                                                      /* Clear destination instance        */
  CHECK_THIS_RV(NOT_EXEC);                                                      /* Check this pointer                */
  IF_NOK(CStatistics_Check(_this))                                              /* Check instance data               */
    return IERROR(_this,STA_NOTSETUP," ( use -status for details)",0,0);        /* ...                               */

  /* Initialize */                                                              /* --------------------------------- */
  C = CStatistics_GetNClasses(_this);                                           /* Get number of statistics classes  */
  CData_Array(idDst,T_DOUBLE,1,C);                                              /* Allocate output data instance     */
  CData_SetNBlocks(idDst,C);                                                    /* Set block number                  */
  if (!CData_XAddr(idDst,0,0)) return IERROR(_this,ERR_NOMEM,0,0,0);            /* Should have been successfull ...  */

  /* Store sample sizes / estimated a-rpior probabilities */                    /* --------------------------------- */
  nTsz = bProb ? CStatistics_GetNSamples(_this) : 1;                            /* Get frequency divident            */
  for (c=0; c<C; c++)                                                           /* Loop over classes                 */
  {                                                                             /* >>                                */
    DLPASSERT((lpSsz = CStatistics_GetPtr(_this,c,STA_DAI_SSIZE)));             /*   Get ptr. to class' c sample size*/
    CData_Dstore(idDst,lpSsz[0]/(FLOAT64)nTsz,c,0);                              /*   Store sample size of class c    */
  }                                                                             /* <<                                */

  return O_K;
}
示例#13
0
/**
 *  Expand/reduce number of pitch markers to fit new target sum of period length.
 *
 * @param idSrc        source object
 * @param idDst        target object
 * @param n            target length
 * @return O_K if sucessfull, not exec otherwise
 */
INT16 CGEN_PUBLIC CPMproc::ExpandPm(CData *idSrc, CData* idDst, INT32 n)
{
  if(CData_IsEmpty(idSrc) == TRUE) return NOT_EXEC;
  if(n <= 0)                       return NOT_EXEC;

  CREATEVIRTUAL(CData,idSrc,idDst);

  DLPASSERT(CData_GetNComps(idSrc) == 2);

  CData_Reset(idDst, TRUE);
  CData_Scopy(idDst,idSrc);

  INT32    nRecsNew = 0;
  INT32    nRecs    = (INT32)CData_GetNRecs(idSrc);
  INT16* pm_new = NULL;

  if(dlm_pm_expand((INT16*)CData_XAddr(idSrc,0,0), nRecs, &pm_new, &nRecsNew, n) != O_K) {
    return IERROR(this,ERR_NULLARG, "", NULL, NULL);
  }
  CData_Allocate(idDst,nRecsNew);
  dlp_memmove(CData_XAddr(idDst,0,0), pm_new, nRecsNew*2*sizeof(INT16));
  dlp_free(pm_new);
  CData_CopyDescr(idDst,idSrc);

  /* clean up */
  DESTROYVIRTUAL(idSrc,idDst)

  return(O_K);
}
示例#14
0
char* CDlpObject_GetFQName(CDlpObject* _this, char* lpName, BOOL bForceArray)
{
  char        lpBuf1[255];
  char        lpBuf2[255];
  SWord*      lpWord;
  CDlpObject* lpInst = _this;

  if (!_this)
  {
    dlp_strcpy(lpName,"(null)");
    return lpName;
  }

  lpBuf2[0]='\0';

  if (!_this->m_lpContainer) dlp_strcpy(lpName,_this->m_lpInstanceName);
  else
  {
    lpWord = _this->m_lpContainer;
    while (TRUE)
    {
      /* Do no include interpreter instance name */
      if (dlp_strcmp(lpWord->lpContainer->m_lpClassName,"itp")==0) break;

      if (lpWord->nWordType==WL_TYPE_FIELD &&
          lpWord->ex.fld.nType==T_INSTANCE &&
          (lpWord->ex.fld.nArrlen!=1 || bForceArray))
      {
        /* Seek instance in array */
        INT32 i = 0;

        for (i=0; i<lpWord->ex.fld.nArrlen; i++)
          if (((CDlpObject**)lpWord->lpData)[i] == lpInst)
            break;

        if (i<lpWord->ex.fld.nArrlen)
          sprintf(lpBuf1,".%s[%ld]%s",lpWord->lpName,(long)i,lpBuf2);
        else
          /* MWX 2002-01-16:
             This is an error actually, but what should be done here ???? --> */
          sprintf(lpBuf1,".%s%s",lpWord->lpName,lpBuf2);
          /* <-- */
      }
      else sprintf(lpBuf1,".%s%s",lpWord->lpName,lpBuf2);
      strcpy(lpBuf2,lpBuf1);

      lpInst = (CDlpObject*)lpWord->lpContainer;
      DLPASSERT(lpInst); /* Word must belong to an instance! */
      if (!lpInst->m_lpContainer) break; /* No parent --> stop */
      lpWord = lpInst->m_lpContainer;
    }
    if (lpBuf2[0] == '.') dlp_memmove(lpBuf2,&lpBuf2[1],dlp_strlen(lpBuf2));
    if (strlen(lpBuf2)>0)  sprintf(lpName,"%s.%s",lpInst->m_lpInstanceName,lpBuf2);
    else                  strcpy(lpName,lpInst->m_lpInstanceName);
  }

  return lpName;
}
示例#15
0
/**
 *  Add periods to reach desired sum od periods.
 *
 * @param idSrc        source object
 * @param idDst        target object
 * @param n            target number of pitch markers
 * @param method       fill method
 * @return O_K if sucessfull, not exec otherwise
 */
INT16 CGEN_PUBLIC CPMproc::Fill(CData *idSrc, CData* idDst, INT32 n, const char* method)
{
  INT32       i               = 0;
  INT32       n_new           = 0;
  INT32       sum             = 0;
  INT16      mean_s          = 0;
  FLOAT64     mean            = 0.0;
  const char* method_default = "mean";

  if(CData_IsEmpty(idSrc) == TRUE) return NOT_EXEC;
  if(n <= 0)                       return NOT_EXEC;
  if(method == NULL)               method = method_default;

  CREATEVIRTUAL(CData,idSrc,idDst);

  DLPASSERT(CData_GetNComps(idSrc) == 2);
  CData_Reset(idDst, TRUE);
  CData_Copy(idDst,idSrc);

  for(i = 0; i < idSrc->GetNRecs(); i++) {
    sum += (INT32)idSrc->Dfetch(i,0);
  }

  if(!strcmp(method, "mean")) {
    mean = (FLOAT64)sum / (FLOAT64)idSrc->GetNRecs();
    n_new = (INT32)((FLOAT64)(n-sum) / mean);
    if(n_new >= 0) {
      n_new = MAX(n_new,1);
      i = idDst->GetNRecs();
      idDst->AddRecs(n_new, 1);
      while((sum<n) && (i < idDst->GetNRecs())) {
        mean_s = (INT16)((FLOAT64)(n-sum) / (FLOAT64)(idDst->GetNRecs()-i));
        idDst->Dstore(mean_s,i,0);
        idDst->Dstore(0,i,1);
        i++;
        sum += mean_s;
      }
    }
  }

  while((n-sum) > idDst->Dfetch(idDst->GetNRecs()-1,0)) {
    sum -= (INT32)idDst->Dfetch(idDst->GetNRecs()-1,0);
    idDst->Delete(idDst,idDst->GetNRecs()-1,1);
  }
  idDst->Dstore(idDst->Dfetch(idDst->GetNRecs()-1,0)-(sum-n),idDst->GetNRecs()-1,0);

  CData_CopyDescr(idDst,idSrc);

  /* clean up */
  DESTROYVIRTUAL(idSrc,idDst)

  return(O_K);
}
示例#16
0
文件: fst_xsr.c 项目: gitgun/dLabPro
/**
 * Returns the neutral element of the multiplication operation of the weight
 * semiring.
 *
 * @param nSrType Semiring type (<code>FST_WSR_PROB</code>,
 *                <code>FST_WSR_LOG</code> or <code>FST_WSR_TROP</code>)
 * @return The neutral element
 */
FST_WTYPE CGEN_SPROTECTED CFst_Wsr_NeMult(INT16 nSrType)
{
  switch (nSrType)
  {
    case FST_WSR_PROB: return 1.;
    case FST_WSR_LOG : return 0.;
    case FST_WSR_TROP: return 0.;
    case 0           : return 0.;                                              /* Not weighted; just do nothing */
    default          : DLPASSERT(FMSG("Invalid weight semiring type"));
  }
  return 0.;
}
示例#17
0
/*
 * Manual page at function.def
 */
INT16 CGEN_PUBLIC CFunction::OnReset()
{
  // Delegate to running function                                               // ------------------------------------
  FNC_DELEGATE OnReset();                                                       // Use a weird macro (see function.def)

  SWord*   lpWrd = NULL;
  hscan_t  hs;
  hnode_t* hn;

  // Initialize                                                                 // ------------------------------------
  CDlpObject* iCont = GetActiveInstance();                                      // Determine field container
  if (iCont==this) return NOT_EXEC;                                             // Never ever!!
  const char* lpsId = GetNextToken(TRUE);                                       // Determine field name

  // Validate                                                                   // ------------------------------------
  DLPASSERT(iCont);                                                             // Check set target

  // Do reset                                                                   // ------------------------------------
  if      (!dlp_strlen(lpsId)) iCont->Reset();                                  // Reset entire instance
  else if (!dlp_strcmp(lpsId,"*"))                                              // Reset all (writable) fields
  {                                                                             // >>
    hash_scan_begin(&hs,iCont->m_lpDictionary);                                 //   Initialize enumerating dictionary
    while ((hn=hash_scan_next(&hs)))                                            //   Loop over all dictionary entries
    {                                                                           //   >>
      DLPASSERT((lpWrd=(SWord*)hnode_get(hn)));                                 //     NULL entry in dictionary
      if (lpWrd->nWordType==WL_TYPE_FIELD && !(lpWrd->nFlags & FF_NOSET))       //     Not write-protected
        iCont->ResetField(lpWrd);                                               //       Reset single field
    }                                                                           //   <<
  }                                                                             // <<
  else                                                                          // Reset single field
  {                                                                             // >>
    lpWrd = iCont->FindWord(lpsId,WL_TYPE_FIELD);                               //   Find field
    if (!lpWrd) return IERROR(this,ERR_NOTFIELD,lpsId,0,0);                     //   Not found --> error
    if (!(lpWrd->nFlags & FF_NOSET)) iCont->ResetField(lpWrd);                  //   If not write-protected --> reset
    else return IERROR(this,FNC_NOSET,lpsId,0,0);                               //   If write-protected --> error
  }                                                                             // <<

  return O_K;                                                                   // Done.
}
示例#18
0
CFWTproc::CFWTproc(const char* lpInstanceName, BOOL bCallVirtual) : inherited(lpInstanceName,0)
{
    DEBUGMSG(-1,"CFWTproc::CFWTproc; (bCallVirtual=%d)",(int)bCallVirtual,0,0);
    dlp_strcpy(m_lpClassName,"FWTproc");
    dlp_strcpy(m_lpObsoleteName,"");
    dlp_strcpy(m_lpProjectName,"FWTproc");
    dlp_strcpy(m_version.no,"1.0");
    dlp_strcpy(m_version.date,"");
    m_nClStyle = CS_AUTOACTIVATE;

    if (bCallVirtual)
    {
        DLPASSERT(OK(AutoRegisterWords()));
        Init(TRUE);
    }
}
示例#19
0
文件: fsttools.c 项目: gitgun/dLabPro
void CFsttools_Constructor(CFsttools* _this, const char* lpInstanceName, BOOL bCallVirtual)
{
    DEBUGMSG(-1,"CFsttools_Constructor; (bCallVirtual=%d)",(int)bCallVirtual,0,0);

#ifndef __cplusplus

    /* Register instance */
    dlp_xalloc_register_object('J',_this,1,sizeof(CFsttools),
                               __FILE__,__LINE__,"fsttools",lpInstanceName);

    /* Create base instance */
    _this->m_lpBaseInstance = calloc(1,sizeof(CDlpObject));
    CDlpObject_Constructor(_this->m_lpBaseInstance,lpInstanceName,FALSE);

    /* Override virtual member functions */
    _this->m_lpBaseInstance->AutoRegisterWords = CFsttools_AutoRegisterWords;
    _this->m_lpBaseInstance->Reset             = CFsttools_Reset;
    _this->m_lpBaseInstance->Init              = CFsttools_Init;
    _this->m_lpBaseInstance->Serialize         = CFsttools_Serialize;
    _this->m_lpBaseInstance->SerializeXml      = CFsttools_SerializeXml;
    _this->m_lpBaseInstance->Deserialize       = CFsttools_Deserialize;
    _this->m_lpBaseInstance->DeserializeXml    = CFsttools_DeserializeXml;
    _this->m_lpBaseInstance->Copy              = CFsttools_Copy;
    _this->m_lpBaseInstance->ClassProc         = CFsttools_ClassProc;
    _this->m_lpBaseInstance->GetInstanceInfo   = CFsttools_GetInstanceInfo;
    _this->m_lpBaseInstance->IsKindOf          = CFsttools_IsKindOf;
    _this->m_lpBaseInstance->Destructor        = CFsttools_Destructor;
    _this->m_lpBaseInstance->ResetAllOptions   = CFsttools_ResetAllOptions;

    /* Override pointer to derived instance */
    _this->m_lpBaseInstance->m_lpDerivedInstance = _this;

#endif /* #ifndef __cplusplus */

    dlp_strcpy(BASEINST(_this)->m_lpClassName,"fsttools");
    dlp_strcpy(BASEINST(_this)->m_lpObsoleteName,"");
    dlp_strcpy(BASEINST(_this)->m_lpProjectName,"fsttools");
    dlp_strcpy(BASEINST(_this)->m_version.no,"1.00 DLC22");
    dlp_strcpy(BASEINST(_this)->m_version.date,"");
    BASEINST(_this)->m_nClStyle = CS_AUTOACTIVATE;

    if (bCallVirtual)
    {
        DLPASSERT(OK(INVOKE_VIRTUAL_0(AutoRegisterWords)));
        INVOKE_VIRTUAL_1(Init,TRUE);
    }
}
示例#20
0
/////////////////////////////////////////////////////////////////////////////////////
//
// ModEx - generates excitation from pitch file
//
// CData *gain       -> gains of excitation per frame
// CData *idPm       -> both components must be type long
// CData *idExcite   -> type FBA_FLOAT
//
INT16 CGEN_PUBLIC CFBAproc::ModEx(CData *idPm, CData *idExcite) {
  // Error handling
  if (idPm == NULL)                return IERROR(this,ERR_NULLINST,0,0,0);
  if (idPm -> IsEmpty() == TRUE)   return IERROR(idPm,DATA_EMPTY,idPm->m_lpInstanceName,0,0);
  if (idExcite == NULL)            return IERROR(this,ERR_NULLINST,idExcite->m_lpInstanceName,0,0);

  DLPASSERT(idPm->GetNComps()>1);

  FLOAT64* exc = NULL;
  INT32    n_exc = 0;

  switch(m_lpsExcType[0]) {
    case 'P':
      if(dlm_pm2exc((INT16*)idPm->XAddr(0,0),(INT32)idPm->GetNRecs(),&exc,&n_exc,m_nSrate, (BOOL)TRUE,DLM_PITCH_PULSE    ) != O_K) return NOT_EXEC;
      break;
    case 'G':
      if(dlm_pm2exc((INT16*)idPm->XAddr(0,0),(INT32)idPm->GetNRecs(),&exc,&n_exc,m_nSrate, (BOOL)TRUE,DLM_PITCH_GLOTT    ) != O_K) return NOT_EXEC;
      break;
    case 'R':
      if(dlm_pm2exc((INT16*)idPm->XAddr(0,0),(INT32)idPm->GetNRecs(),&exc,&n_exc,m_nSrate, (BOOL)TRUE,DLM_PITCH_RANDPHASE) != O_K) return NOT_EXEC;
      break;
    case 'V':
      if(dlm_pm2exc((INT16*)idPm->XAddr(0,0),(INT32)idPm->GetNRecs(),&exc,&n_exc,m_nSrate, (BOOL)TRUE,DLM_PITCH_VOICED   ) != O_K) return NOT_EXEC;
      break;
    case 'U':
      if(dlm_pm2exc((INT16*)idPm->XAddr(0,0),(INT32)idPm->GetNRecs(),&exc,&n_exc,m_nSrate, (BOOL)TRUE,DLM_PITCH_UNVOICED ) != O_K) return NOT_EXEC;
      break;
    case 'C':
      if(m_idExc == NULL) return IERROR(this,ERR_BADPTR,NULL,"of CFBAproc->m_lpExc","(FBAproc.exc)");
      for(INT32 i_pm=0; i_pm < idPm->GetNRecs(); i_pm++) n_exc += (INT16)idPm->Dfetch(i_pm,0);
      if(CData_GetNRecs(m_idExc) < n_exc) return IERROR(this,FBA_BADEXCLEN,0,0,0);
      exc = (FLOAT64*)dlp_malloc(n_exc*sizeof(FLOAT64));
      dlp_memmove(exc,m_idExc->XAddr(0,0),n_exc*sizeof(FLOAT64));
      break;
    default:
      return IERROR(this,FBA_BADARG,m_lpsExcType,"exc_type","P, G, R, V, U or C");
  }

  idExcite->Reset(TRUE);
  idExcite->AddComp("exc", T_DOUBLE);
  idExcite->Allocate(n_exc);
  dlp_memmove(idExcite->XAddr(0,0), exc, n_exc*sizeof(FLOAT64));
  dlp_free(exc);

  return O_K;
}
示例#21
0
/*
 * Manual page at function.def
 */
INT16 CGEN_PUBLIC CFunction::OnSee()
{
  // Delegate to running function                                               // ------------------------------------
  FNC_DELEGATE OnSee();                                                         // Use a weird macro (see function.def)

  // Initialize                                                                 // ------------------------------------
  CDlpObject* iCont = GetActiveInstance();                                      // Determine field container
  const char*   lpsId = GetNextToken(TRUE);                                     // Determine field name

  // Validate                                                                   // ------------------------------------
  DLPASSERT(iCont);                                                             // Check set target
  if (!dlp_strlen(lpsId))                                                       // If no field name committed
    return IERROR(this,FNC_EXPECT,"field identifier or * after -see",0,0);      //   Error

  // Print                                                                      // ------------------------------------
  return CDlpObject_PrintField(iCont,lpsId,FALSE);                              // Print selected field(s)
}
示例#22
0
/**
 * Join a thread. This method suspends the execution of the
 * calling thread until the thread identified by hThread terminates.
 *
 * @param hTread    Handle of thread to join
 * @return nonzero if succeeded, zero if an error occured. Call
 *         GetLastError to get extended error information (MS
 *         OSes only)
 * @see #dlp_create_thread dlp_create_thread
 * @see #dlp_terminate_thread dlp_terminate_thread
 */
INT16 dlp_join_thread(THREADHANDLE hThread)
{

#ifdef HAVE_MSTHREAD

 WaitForSingleObject(hThread,INFINITE);

#elif defined HAVE_PTHREAD

  pthread_join(hThread, NULL);

#else
  DLPASSERT(FALSE);
#endif

  return O_K;
}
示例#23
0
/**
 * Terminates a thread.
 *
 * @param hTread    Handle of thread to terminate
 * @param nExitCode Exit code to send to thread (MS OSes only)
 * @return nonzero if succeeded, zero if an error occured. Call
 *         GetLastError to get extended error information (MS
 *         OSes only)
 * @see #dlp_create_thread dlp_create_thread
 * @see #dlp_join_thread dlp_join_thread
 */
INT16 dlp_terminate_thread(THREADHANDLE hThread, INT32 nExitCode)
{
#ifdef HAVE_MSTHREAD

 INT16 bResult = TerminateThread(hThread,nExitCode);
 CloseHandle(hThread); /* This handle is not longer valid! */
 return bResult;

#elif defined HAVE_PTHREAD

 pthread_kill(hThread,9);

#else
  DLPASSERT(FALSE);
#endif

 return O_K;
}
示例#24
0
/**
 * Copies the global class registry into the instances dictionary.
 *
 * @param _this
 *          This instance
 * @param bAutoInst
 *          If <code>TRUE</code> create auto-instances
 * @return <code>O_K</code> if successful, a (negative) error code otherwise
 **/
INT16 CDlpObject_LoadClassRegistry(CDlpObject* _this, BOOL bAutoInst)
{
  INT32          nC            = 0;
  const SWord* lpFactoryWord = NULL;
  CDlpObject*  lpInst        = NULL;

  for (nC=0; nC<__nXClassRegistry; nC++)
  {
    lpFactoryWord = &__lpClassRegistry[nC];
    DLPASSERT(lpFactoryWord && lpFactoryWord->nWordType==WL_TYPE_FACTORY);

    /* Call installation function */
    if (NOK((lpFactoryWord->ex.fct.lpfInstall)(_this))) continue;

    /* Register singleton or auto instance in dictionary */
    if ((lpFactoryWord->nFlags & (CS_SINGLETON|CS_AUTOINSTANCE)) && bAutoInst)
    {
      SWord newword;
      const char* lpsInstanceName = lpFactoryWord->ex.fct.lpAutoname;
      if (lpFactoryWord->nFlags & CS_SINGLETON)
        lpsInstanceName = lpFactoryWord->lpName;

      if (dlp_strlen(lpFactoryWord->lpName) ==0) continue;
      lpInst = (lpFactoryWord->ex.fct.lpfFactory)(lpsInstanceName);
      if (!lpInst) continue;

      memset(&newword,0,sizeof(SWord));
      newword.nWordType = WL_TYPE_INSTANCE;
      newword.lpData    = lpInst;
      strcpy(newword.lpName,lpsInstanceName);
      strcpy(newword.lpObsname,lpFactoryWord->lpObsname);
      CDlpObject_RegisterWord(_this,&newword);
      lpInst->m_nInStyle |= IS_GLOBAL;
    }

    /* Register class factory in dictionary */
    if (!(lpFactoryWord->nFlags & CS_SINGLETON))
    {
      CDlpObject_RegisterWord(_this,lpFactoryWord);
    }
  }

  return O_K;
}
示例#25
0
文件: fst_ixp.c 项目: gitgun/dLabPro
/*
 * Manual page at fst_man.def
 */
INT16 CGEN_PUBLIC CFst_CopyUi(CFst* _this, CFst* itSrc, CData* idIndex, INT32 nPar)
{
  INT32 i  = 0;
  INT32 nU = 0;

  /* Validate */
  CHECK_THIS_RV(NOT_EXEC);
  CFst_Check(_this);
  CFst_Check(itSrc);

  if (idIndex)
  {
    if (CData_IsEmpty(idIndex)) return NOT_EXEC;
    if (nPar<0)
      for (i=0; i<CData_GetNComps(idIndex); i++)
        if (dlp_is_numeric_type_code(CData_GetCompType(idIndex,i)))
          { nPar=i; break; }

    if
    (
      nPar<0 || nPar>=CData_GetNComps(idIndex) ||
      !dlp_is_numeric_type_code(CData_GetCompType(idIndex,nPar))
    )
    {
      return IERROR(_this,FST_BADID,"component",nPar,0);
    }
  }

  /* Initialize */
  CREATEVIRTUAL(CFst,itSrc,_this);
  CFst_Reset(BASEINST(_this),TRUE);
  
  if (idIndex)
  {
    /* Loop over records of idIndex */
    for (i=0; i<CData_GetNRecs(idIndex); i++)
    {
      nU = (INT32)CData_Dfetch(idIndex,i,nPar);
      if (nU>=0 && nU<UD_XXU(itSrc)) {
        DLPASSERT(OK(CFst_CatEx(_this,itSrc,nU,1)))
      } else IERROR(_this,FST_BADID2,"unit",nU,0);
    }
  }
  else if (nPar<0)
示例#26
0
/**
 * Base class implementation of instance reset.
 *
 * @param _this         This instance
 * @param bResetMembers If TRUE reset all options and fields
 * @return O_K if successful, an error code otherwise
 */
INT16 CDlpObject_Reset(CDlpObject* _this, BOOL bResetMembers)
{
  INT16 nErr = O_K;

  DEBUGMSG(-1,"CDlpObject_Reset for '%s'; (bResetMembers=%d)",_this->m_lpInstanceName,bResetMembers,0);

#ifdef __NORTTI
  IERROR(_this,ERR_DANGEROUS,"CDlpObject_Reset","nothing will be reseted in __NORTTI mode",0);
  DLPASSERT(FALSE);
#else
  if (bResetMembers)
  {
    nErr = INVOKE_VIRTUAL_1(ResetAllOptions,FALSE); IF_NOK(nErr) return nErr;
    nErr = CDlpObject_ResetAllFields(_this,FALSE);  IF_NOK(nErr) return nErr;
  }
#endif

  return nErr;
}
示例#27
0
文件: file.c 项目: thias42/dLabPro
INT16 CDlpFile_List(CDlpFile* _this)
{
    CFILE_FTYPE* lpType = NULL;
    lnode_t*      lpNode = NULL;

    printf("\n"); dlp_fprint_x_line(stdout,'-',80);
    printf(              "\n Name      \tClass     \tMode  \tDescription\n");
    dlp_fprint_x_line(stdout,'-',80); printf("\n");

    for(lpNode=list_first(_this->m_lpFtypes); lpNode; lpNode=list_next(_this->m_lpFtypes,lpNode))
    {
      lpType = (CFILE_FTYPE*)lnode_get(lpNode);
      DLPASSERT(lpType);
      printf( " %-10s\t%-10s\t%s\t%s\n",lpType->lpName,lpType->lpClassName,
             lpType->nMode==IMPORT_FILE?"Import":"Export",lpType->lpDescr);
    }

    dlp_fprint_x_line(stdout,'-',80); printf("\n");
	return O_K;
}
示例#28
0
/**
 * Removes the variable's value from the stack. This method <em>must</em> be
 * called from all interactive methods.
 * 
 * @see Exec
 */
void CGEN_PROTECTED CVar_PopOwnValue(CVar *_this)
{
  switch (_this->m_nType)
  {
    case T_BOOL:
      CDlpObject_MicGetB(BASEINST(_this),-1,0);
      break;
    case T_COMPLEX:
    case T_RDOUBLE:
    case T_RDDATA:
      CDlpObject_MicGetN(BASEINST(_this),-1,0);
      break;
    case T_STRING:
    case T_RSDATA:
      CDlpObject_MicGetS(BASEINST(_this),-1,0);
      break;
    case T_INSTANCE:
      CDlpObject_MicGetI(BASEINST(_this),-1,0);
      break;
    default: DLPASSERT(FMSG("Unknown variable type"));
  }
}
示例#29
0
/**
 *  Convert (unequal spaced) pitch markers to f0-contour with equal spaced
 * sampling points.
 *
 * @param idSrc        source pitch marks
 * @param idDst        target fo-contour
 * @param n            target number of sampling points of f0-contour
 * @param srate        sampling rate
 * @return O_K if sucessfull, not exec otherwise
 */
INT16 CGEN_PUBLIC CPMproc::Pm2f0(CData *idSrc, CData* idDst, INT32 n, INT32 srate) {

  if(CData_IsEmpty(idSrc) == TRUE) return NOT_EXEC;
  if(n <= 0)                       return NOT_EXEC;

  DLPASSERT(CData_GetNComps(idSrc) == 2);

  CREATEVIRTUAL(CData,idSrc,idDst);

  CData_Reset(idDst, TRUE);
  CData_AddComp(idDst, "~F0", T_DOUBLE);

  CData_Allocate(idDst, n);

  dlm_pm2f0((INT16*)idSrc->XAddr(0,0), idSrc->GetNRecs(), (FLOAT64*)idDst->XAddr(0,0), idDst->GetNRecs(), srate);

  ISETFIELD_RVALUE(idDst, "fsr", 1000.0/srate);

  /* clean up */
  DESTROYVIRTUAL(idSrc,idDst)

  return(O_K);
}
示例#30
0
文件: sta_reo.c 项目: gitgun/dLabPro
/**
 * <p>INTERNAL USE ONLY. This method is called by {@link -pool} to pool the
 * statistics blocks contained in <code>idSrc</code> and store the result in
 * <code>idPool</code>. The operation is controlled through the pooling mode
 * flag <code>nMode</code> as follows:</p>
 *
 * <ul>
 *   <li>nMode=0: Pool sum data, <code>idPool</code> will be overwritten</li>
 *   <li>nMode=1: Pool min data</li>
 *   <li>nMode=2: Pool max data</li>
 * </ul>
 *
 * <h3>Remarks</h3>
 * <ul>
 *   <li>In order to pool raw statistics data, there are three calls
 *     (<code>nMode</code>=0,1 and 2) necessary. The first call of these
 *     <em>must</em> be the one with <code>nMode</code>=0!</li>
 *   <li>There are NO checks performed</li>
 * </ul>
 *
 * @param idPool
 *          Pooled raw statistics data block
 * @param idSrc
 *          Raw statistics data blocks to be pooled
 * @param nMode
 *          Pooling mode, see above
 */
void CGEN_SPRIVATE CStatistics_PoolInt(CData* idPool, CData* idSrc, INT32 nMode)
{
  CData* idAux      = NULL;                                                     /* Auxilary data instance #1         */

  if (nMode==0)                                                                 /* Sum aggregation mode              */
  {                                                                             /* >>                                */
    ISETOPTION(idPool,"/block");                                                /*   Switch target to block mode     */
    CData_Aggregate(idPool,idSrc,NULL,CMPLX(0),"sum");                          /*   Aggregate (sum up)              */
    IRESETOPTIONS(idPool);                                                      /*   Switch target to normal mode    */
  }                                                                             /* <<                                */
  else if (nMode==1 || nMode==2)                                                /* Extrama aggregation modes         */
  {                                                                             /* >>                                */
    ICREATEEX(CData,idAux,"CStatistics_Pool_int.~idAux",NULL);                  /*   Create auxilary data instance #1*/
    ISETOPTION(idAux,"/block");                                                 /*   Switch target to block mode     */
    CData_Aggregate(idAux,idSrc,NULL,CMPLX(0),nMode==1?"min":"max");            /*   Aggregate (minimum or maximum)  */
    dlp_memmove(CData_XAddr(idPool,nMode,0),CData_XAddr(idAux,nMode,0),         /*   Copy aggregated min. or max. ...*/
      CData_GetRecLen(idAux));                                                  /*   | ... to target                 */
    IRESETOPTIONS(idAux);                                                       /*   Switch target to normal mode    */
    IDESTROY(idAux);                                                            /*   Destroy auxilary data inst. #1  */
  }                                                                             /* <<                                */
  else                                                                          /* Unknown mode                      */
    DLPASSERT(FMSG("Invalid internal pooling mode"));                           /*   Not so good ...                 */
}