当前位置: 首页>>代码示例>>C++>>正文


C++ CData::SelectRecs方法代码示例

本文整理汇总了C++中CData::SelectRecs方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::SelectRecs方法的具体用法?C++ CData::SelectRecs怎么用?C++ CData::SelectRecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CData的用法示例。


在下文中一共展示了CData::SelectRecs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AlignFramesToPitch

INT16 CGEN_PUBLIC CFBAproc::AlignFramesToPitch(CData *idPitch, CData *idFea, CData* idNewFea) {
  CData* idAuxF  = NULL;
  INT32 nSamplesP = 0;
  INT32  nFea      = 0;
  INT32  nPer      = 0;
  INT32  i         = 0;
  INT32  j         = 0;

  if(m_nSync) return O_K;

  if(idFea == NULL)       return IERROR(this,ERR_NULLINST,0,0,0);
  if(idFea->IsEmpty())    return IERROR(idPitch,DATA_EMPTY,idPitch->m_lpInstanceName,0,0);

  if(idPitch == NULL)       return IERROR(this,ERR_NULLINST,0,0,0);
  if(idPitch->IsEmpty())    return IERROR(idPitch,DATA_EMPTY,idPitch->m_lpInstanceName,0,0);
  if(idPitch->GetNComps()!=2                            ||
     !dlp_is_numeric_type_code(idPitch->GetCompType(0)) ||
     !dlp_is_numeric_type_code(idPitch->GetCompType(1))) {
    return IERROR(this,FBA_BADARG,idPitch,"idPitch","contains invalid data.");
  }

  CREATEVIRTUAL(CData,idFea,idNewFea);
  ICREATEEX(CData,idAuxF  ,"~idAuxF"  ,NULL);

  if(idFea->m_lpTable->m_fsr <= 0.0) {
    idFea->m_lpTable->m_fsr = 1000.0 * (FLOAT64)m_nCrate / (FLOAT64)m_nSrate;
  }

  nFea = idFea->GetNRecs();

  for(i = 0, j = 0, nSamplesP = 0; i < idPitch->GetNRecs(); i++, nSamplesP+=nPer) {
    nPer = (INT32)idPitch->Dfetch(i,0);

    while((idFea->m_lpTable->m_fsr * (FLOAT64)(j+0.5)) < (1000.0 * (FLOAT64)nSamplesP / (FLOAT64)m_nSrate)) j++;

    j = (j>=nFea) ? nFea-1 : j;

    idAuxF->SelectRecs(idFea,j,1);
    idNewFea->Cat(idAuxF);
  }

  IDESTROY(idAuxF);
  DESTROYVIRTUAL(idFea, idNewFea);
  return O_K;
}
开发者ID:thias42,项目名称:dLabPro,代码行数:45,代码来源:fba_synt.cpp

示例2: ResamplePitch

/*
 * Resample voiced parts of pitch to match a given mean fundamential frequency.
 * The length of voiced segments is preserved to avoid loss of synchronization
 * between pitch and corresponding signal
 *
 * @param   idPitch     Source data instance containing original pitch
 * @param   idNewPitch  Target data instance containing new pitch
 * @param   nFFreq      Target fundamential frequency (mean over voiced parts)
 */
INT16 CGEN_PUBLIC CFBAproc::ResamplePitch(CData *idPitch, CData *idNewPitch, INT32 nFFreq)
{
  INT16  bVoiced    = FALSE;
  INT32   i          = 0;
  INT32   k          = 0;
  INT32   nCount     = 0;
  INT32   nStartL    = 0;
  FLOAT32  nTargetPeriodLength = (FLOAT32)m_nSrate/(FLOAT32)nFFreq;
  FLOAT32  nMeanPeriodLengthL  = 0.0;
  FLOAT32  nMeanPeriodLength   = 0.0;
  CData* idVoiced   = NULL;
  CData* idAux      = NULL;

  // Validation
  if(idPitch == NULL)       return IERROR(this,ERR_NULLINST,0,0,0);
  if(idPitch->IsEmpty())    return IERROR(idPitch,DATA_EMPTY,idPitch->m_lpInstanceName,0,0);
  if(nFFreq<50||nFFreq>500) return IERROR(this,FBA_BADARG,nFFreq,"nFFreq","a value between 50 and 500");
  if
  (
    idPitch->GetNComps()!=2                            ||
    !dlp_is_numeric_type_code(idPitch->GetCompType(0)) ||
    !dlp_is_numeric_type_code(idPitch->GetCompType(1))
  )
  {
    return IERROR(this,FBA_BADARG,idPitch,"idPitch","contains invalid data.");
  }

  // Initialization
  CREATEVIRTUAL(CData,idPitch,idNewPitch);
  ICREATEEX(CData,idVoiced,"~idVoiced",NULL);
  ICREATEEX(CData,idAux   ,"~idAux"   ,NULL);
  idNewPitch->Reset();
  idVoiced->AddComp("start",T_INT);
  idVoiced->AddComp("count",T_INT);
  idVoiced->AddComp("mplen",T_FLOAT);
  idVoiced->Alloc(10);

  // Determine start and length of voiced parts and mean of periods in samples
  for(i=0; i<idPitch->GetNRecs(); i++)
  {
    if(idPitch->Dfetch(i,1)>0)
    {
      if(bVoiced==FALSE)    // Start of new voiced segment
      {
        bVoiced=TRUE;
        nStartL=i;
        nMeanPeriodLengthL=0;
        if(idVoiced->GetNRecs()==idVoiced->GetMaxRecs())
          idVoiced->Realloc(idVoiced->GetNRecs()+10);
        idVoiced->IncNRecs(1);
        idVoiced->Dstore(i,idVoiced->GetNRecs()-1,0);
      }
      nMeanPeriodLength+=(INT32)idPitch->Dfetch(i,0);
      nMeanPeriodLengthL+=(INT32)idPitch->Dfetch(i,0);
      nCount++;
    }
    else if(bVoiced==TRUE)  // End of voiced segment
    {
      bVoiced=FALSE;
      nMeanPeriodLengthL=nMeanPeriodLengthL/(FLOAT32)(i-nStartL);
      idVoiced->Dstore(i-nStartL,idVoiced->GetNRecs()-1,1);
      idVoiced->Dstore(nMeanPeriodLengthL,idVoiced->GetNRecs()-1,2);
    }
  }
  nMeanPeriodLength=nMeanPeriodLength/(FLOAT32)nCount;

  IFCHECK idVoiced->Print();
  IFCHECK printf("\n Input mean period length in voiced parts: %f",nMeanPeriodLength);
  IFCHECK printf("\n Target mean period length: %f",nTargetPeriodLength);

  // Resample
  for(i=0,nStartL=0; i<idVoiced->GetNRecs(); i++)
  {
    INT32 j       = 0;
    INT32 nSum    = 0;
    INT32 nSumNew = 0;
    INT32 nDiff   = 0;

    // Copy unvoiced
    idAux->SelectRecs(idPitch,nStartL,(INT32)idVoiced->Dfetch(i,0)-nStartL);
    idNewPitch->Cat(idAux);
    nStartL=(INT32)idVoiced->Dfetch(i,0)+(INT32)idVoiced->Dfetch(i,1);

    // Resample voiced
    idAux->SelectRecs(idPitch,(INT32)idVoiced->Dfetch(i,0),(INT32)idVoiced->Dfetch(i,1));
    for(j=0,nSum=0;j<idAux->GetNRecs();j++) nSum+=(INT32)idAux->Dfetch(j,0);  // Target sum
    idAux->Resample(idAux,nMeanPeriodLength/nTargetPeriodLength);
    idAux->Tconvert(idAux,T_FLOAT);
    idAux->Scalop(idAux,CMPLX(nTargetPeriodLength/nMeanPeriodLength),"mult");
    idAux->Tconvert(idAux,T_INT);
    //DLPASSERT(FALSE);
//.........这里部分代码省略.........
开发者ID:thias42,项目名称:dLabPro,代码行数:101,代码来源:fba_synt.cpp

示例3: AdjustSpeechRate

INT16 CGEN_PUBLIC CFBAproc::AdjustSpeechRate(CData *idPitch, CData *idNewPitch, CData* idFea, CData* idNewFea, FLOAT32 rate) {
  INT16  bVoiced    = FALSE;
  INT32   i          = 0;
  INT32   k          = 0;
  INT32   nCount     = 0;
  INT32   nStartL    = 0;
  FLOAT32  nMeanPeriodLengthL  = 0.0;
  FLOAT32  nMeanPeriodLength   = 0.0;
  CData* idVoiced   = NULL;
  CData* idAuxP     = NULL;
  CData* idAuxF     = NULL;

  // Validation
  if(idPitch == NULL)       return IERROR(this,ERR_NULLINST,0,0,0);
  if(idPitch->IsEmpty())    return IERROR(idPitch,DATA_EMPTY,idPitch->m_lpInstanceName,0,0);
  if
  (
    idPitch->GetNComps()!=2                            ||
    !dlp_is_numeric_type_code(idPitch->GetCompType(0)) ||
    !dlp_is_numeric_type_code(idPitch->GetCompType(1))
  )
  {
    return IERROR(this,FBA_BADARG,idPitch,"idPitch","contains invalid data.");
  }

  // Initialization
  CREATEVIRTUAL(CData,idPitch,idNewPitch);
  CREATEVIRTUAL(CData,idFea,idNewFea);
  ICREATEEX(CData,idVoiced,"~idVoiced",NULL);
  ICREATEEX(CData,idAuxP  ,"~idAuxP"  ,NULL);
  ICREATEEX(CData,idAuxF  ,"~idAuxF"  ,NULL);
  idNewPitch->Reset();
  idVoiced->AddComp("start",T_INT);
  idVoiced->AddComp("count",T_INT);
  idVoiced->AddComp("mplen",T_FLOAT);
  idVoiced->Alloc(10);

  AlignFramesToPitch(idPitch, idFea, idFea);

  // Determine start and length of voiced parts and mean of periods in samples
  for(i=0; i<idPitch->GetNRecs(); i++)
  {
    if(idPitch->Dfetch(i,1)>0)
    {
      if(bVoiced==FALSE)    // Start of new voiced segment
      {
        bVoiced=TRUE;
        nStartL=i;
        nMeanPeriodLengthL=0;
        if(idVoiced->GetNRecs()==idVoiced->GetMaxRecs())
          idVoiced->Realloc(idVoiced->GetNRecs()+10);
        idVoiced->IncNRecs(1);
        idVoiced->Dstore(i,idVoiced->GetNRecs()-1,0);
      }
      nMeanPeriodLength+=(INT32)idPitch->Dfetch(i,0);
      nMeanPeriodLengthL+=(INT32)idPitch->Dfetch(i,0);
      nCount++;
    }
    else if(bVoiced==TRUE)  // End of voiced segment
    {
      bVoiced=FALSE;
      nMeanPeriodLengthL=nMeanPeriodLengthL/(FLOAT32)(i-nStartL);
      idVoiced->Dstore(i-nStartL,idVoiced->GetNRecs()-1,1);
      idVoiced->Dstore(nMeanPeriodLengthL,idVoiced->GetNRecs()-1,2);
    }
  }
  nMeanPeriodLength=nMeanPeriodLength/(FLOAT32)nCount;

  IFCHECK idVoiced->Print();
  IFCHECK printf("\n Input mean period length in voiced parts: %f",nMeanPeriodLength);

  // Resample
  for(i=0,nStartL=0; i<idVoiced->GetNRecs(); i++)
  {
    INT32 j       = 0;
    INT32 nSum    = 0;
    INT32 nRecOld = 0;
    INT32 nRecNew = 0;

    // Copy unvoiced
    idAuxP->SelectRecs(idPitch,nStartL,(INT32)idVoiced->Dfetch(i,0)-nStartL);
    idNewPitch->Cat(idAuxP);
    idAuxF->SelectRecs(idFea,nStartL,(INT32)idVoiced->Dfetch(i,0)-nStartL);
    idNewFea->Cat(idAuxF);
    nStartL=(INT32)idVoiced->Dfetch(i,0)+(INT32)idVoiced->Dfetch(i,1);

    // Resample voiced
    idAuxP->SelectRecs(idPitch,(INT32)idVoiced->Dfetch(i,0),(INT32)idVoiced->Dfetch(i,1));
    nRecOld = idAuxP->GetNRecs();

    for(j=0,nSum=0;j<nRecOld;j++) nSum+=(INT32)idAuxP->Dfetch(j,0);  // Target sum

    idAuxP->Resample(idAuxP, rate);

    nRecNew = idAuxP->GetNRecs();

    for(j=0;j<nRecNew;j++) {
      INT32 tmp = (INT32)idAuxP->Dfetch(j,0);
      tmp = (INT32)MAX(m_nSrate/500, tmp);
      tmp = (INT32)MIN(m_nSrate/50, tmp);
//.........这里部分代码省略.........
开发者ID:thias42,项目名称:dLabPro,代码行数:101,代码来源:fba_synt.cpp


注:本文中的CData::SelectRecs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。