/** * 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); }
/** * 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); }
/* * Synthesis * * @return O_K if successfull, NOT_EXEC otherwise */ INT16 CGEN_PUBLIC CFBAproc::Synthesize(data *idFea, data *idControl, data *idSyn) { if((idFea != NULL) && (idSyn != NULL)) { if (idControl == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idFea == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idSyn == NULL) return IERROR(this,ERR_NULLINST,0,0,0); if (idControl->IsEmpty()) return IERROR(idControl,DATA_EMPTY,idControl->m_lpInstanceName,0,0); if (idFea->IsEmpty()) return IERROR(idFea,DATA_EMPTY,idFea->m_lpInstanceName,0,0); if (idFea->GetCompType(0)!=T_DOUBLE) return IERROR(idFea,DATA_BADCOMPTYPE,0,idFea->m_lpInstanceName,"double"); if(dlp_is_numeric_type_code(idControl->GetCompType(0)) && dlp_is_numeric_type_code(idControl->GetCompType(1))) { if(SynthesizeUsingPM(idFea, idControl, idSyn) != O_K) return NOT_EXEC; } else if(dlp_is_symbolic_type_code(idControl->GetCompType(0)) && dlp_is_numeric_type_code (idControl->GetCompType(1)) && dlp_is_symbolic_type_code(idControl->GetCompType(2)) && dlp_is_numeric_type_code (idControl->GetCompType(3)) && dlp_is_numeric_type_code (idControl->GetCompType(4)) && dlp_is_symbolic_type_code(idControl->GetCompType(5)) && dlp_is_numeric_type_code (idControl->GetCompType(6)) && dlp_is_numeric_type_code (idControl->GetCompType(7))) { if(SynthesizeUsingInto(idFea, idControl, idSyn) != O_K) return NOT_EXEC; } else { IERROR(this,FBA_BADPITCH,idControl->m_lpInstanceName,0,0); return IERROR(this,FBA_BADINTO, idControl->m_lpInstanceName,0,0); } ISETFIELD_RVALUE(idSyn,"rinc",1000/m_nSrate); for(INT32 i = 0; i < idFea->GetNComps(); i++) { if(dlp_is_symbolic_type_code(idFea->GetCompType(i))) { idSyn->AddComp(idFea->GetCname(i),idFea->GetCompType(i)); } } idSyn->CopyLabels(idFea); } return O_K; }