/** * Initializes the instance from the interpreter command line. * <h3>Note</h3> * <p>You must setup the method invocation context <code>m_lpMic</code> (see * <a href="dlpinst.html"><code class="link">CDlpInstance</code></a>) before * calling this method. Otherwise it will do noting.</p> * * @param _this This instance * @param nRec First record to read * @param nComp First component to read * @param nCount Number of items to read * @return O_K if successfull, an error code otherwise */ INT16 CGEN_PUBLIC CData_InitializeEx(CData* _this, INT32 nRec, INT32 nComp, INT32 nCount) { INT32 nXXR = 0; INT32 nXC = 0; INT32 nR = 0; INT32 nC = 0; INT32 nCtr = 0; BOOL bRead = 0; const char* lpsToken = NULL; if (_this && !CDlpObject_MicGet(BASEINST(_this))) return IERROR(_this,ERR_GENERIC,"No method invocation context",0,0); if (!_this || CData_IsEmpty(_this)) { /* _this == NULL is ok, just remove the tokens between { and } */ do { lpsToken = MIC_NEXTTOKEN_FORCE; if (!lpsToken) return IERROR(_this,DATA_HERESCAN,"}",0,0); } while (dlp_strcmp(lpsToken,"}")!=0); return O_K; } /* Actual setup */ nXXR = CData_GetMaxRecs(_this); nXC = CData_GetNComps(_this); nR = nRec; nC = nComp; bRead = TRUE; for (;;) { lpsToken = MIC_NEXTTOKEN_FORCE; if (!lpsToken) return IERROR(_this,DATA_HERESCAN,"}",0,0); if (dlp_strcmp(lpsToken,"}")==0) break; if (!bRead) continue; if (nR==nXXR || (nCount>=0 && nCtr>=nCount)) { /* Ignore further initializers */ bRead = FALSE; continue; } /* Initialize cell value; skip cell on wildcard '*' initializer */ if (dlp_strcmp(lpsToken,"*")!=0) IF_NOK(dlp_sscanx(lpsToken,CData_GetCompType(_this,nC),CData_XAddr(_this,nR,nC))) IERROR(_this,DATA_BADINITIALIZER,lpsToken,(int)nR,(int)nC); nCtr++; nC++; if (nC==nXC) { nC=nComp; nR++; } } if (nCount>=0&&nCtr<nCount) return IERROR(_this,DATA_INITIALIZERS,"few" ,0,0); if (!bRead ) return IERROR(_this,DATA_INITIALIZERS,"many",0,0); return O_K; }
/* * Manual page at function.def */ BOOL CGEN_PUBLIC CFunction::Platform(const char* lpsPlatformId) { if (dlp_strcmp(lpsPlatformId,"WIN32")==0) { #if (defined __WIN32 && !defined __CYGWIN__) return TRUE; #else return FALSE; #endif } if (dlp_strcmp(lpsPlatformId,"LINUX")==0) { #ifdef __LINUX return TRUE; #else return FALSE; #endif } if (dlp_strcmp(lpsPlatformId,"SPARC")==0) { #ifdef __SPARC return TRUE; #else return FALSE; #endif } // Deprecated platform IDs if (dlp_strcmp(lpsPlatformId,"_WINDOWS")==0) { IERROR(this,ERR_OBSOLETEID,"_WINDOWS","WIN32",0); #ifdef __WIN32 return TRUE; #else return FALSE; #endif } if (dlp_strcmp(lpsPlatformId,"_LINUX")==0) { IERROR(this,ERR_OBSOLETEID,"_LINUX","LINUX",0); #ifdef __LINUX return TRUE; #else return FALSE; #endif } return FALSE; }
/** * Initialize one record from a token list. * * @param lpsInit Null ('\0') separated list of tokens. A double null "\0\0" * is expected as list terminator! * @param nRec Record index of first cell to initialize * @param nComp Component index of first cell to initialize * @return O_K if successfull, a negative error code otherwise */ INT16 CGEN_PUBLIC CData_InitializeRecordEx ( CData* _this, const char* lpsInit, INT32 nRec, INT32 nComp ) { const char* lpsToken = NULL; INT32 nXC = 0; INT32 nC = 0; nXC = CData_GetNComps(_this); nC = nComp; if (nC<0 || nC>=nXC ) return NOT_EXEC; if (nRec<0 || nRec>=CData_GetNRecs(_this)) return NOT_EXEC; for (lpsToken=lpsInit; *lpsToken && nC<nXC; lpsToken+=dlp_strlen(lpsToken)+1, nC++) if (dlp_strcmp(lpsToken,"*")!=0) IF_NOK(dlp_sscanx(lpsToken,CData_GetCompType(_this,nC),CData_XAddr(_this,nRec,nC))) IERROR(_this,DATA_BADINITIALIZER,lpsToken,(int)nRec,(int)nC); if (*lpsToken) return IERROR(_this,DATA_INITIALIZERS,"many",0,0); if (nC<nXC ) IERROR(_this,DATA_INITIALIZERS,"few" ,0,0); return O_K; }
/** * Writes the data transfer file of this process. This method is called * immediately before starting the operating system process. */ INT16 CGEN_PUBLIC CProcess::SendData() { DLP_FILE* pfScr; // Slave script file pointer INT32 i; // Loop counter char sScrFn[L_PATH]; // Slave script file name char sDtoFn[L_PATH]; // Data transfer file name if (m_nState & PRC_DATASENT) return NOT_EXEC; // Data have already been sent if (m_iDto) // This process is a function call { // >> sprintf(sScrFn,"%s.xtp",m_psTmpFile); // Get slave script file name sprintf(sDtoFn,"%s.xml",m_psTmpFile); // Get data transfer fine name pfScr = dlp_fopen(sScrFn,"w"); // Open temporary script file for (i=0; dlp_strcmp(__sSlaveScript[i],"\0")!=0; i++) // Loop over slave script lines { // >> dlp_fwrite(__sSlaveScript[i],1,dlp_strlen(__sSlaveScript[i]),pfScr); // Write a line dlp_fwrite("\n",1,1,pfScr); // Write a line break } // << dlp_fclose(pfScr); // Close temporary script file CDlpObject_Save(m_iDto,sDtoFn,SV_XML|SV_ZIP); // Save data transfer object sprintf(m_psCmdLine,"%s %s %s",dlp_get_binary_path(),sScrFn,sDtoFn); // Change the command line // -- ???? --> IDESTROY(m_iDto); IFIELD_RESET(CDlpObject,"dto"); // Save memory! // <---------- } // << m_nState |= PRC_DATASENT; // Remember data have been sent return O_K; }
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; }
/** * Checks if a dLabPro class identifier denotes a given type or a type which * can be casted to the given type. * * <h3>Note</h3> * <p>This procedure is quite large-scaled. Use OfKind whenever possible!</p> * * @param lpsClassName dLabPro class identifier to check for * @param lpsBaseClassName Base class to check for * @return TRUE if a type case is possible, FALSE otherwise * @see CDlpObject_OfKind */ BOOL CDlpObject_OfKindStr(const char* lpsClassName, const char* lpsBaseClassName) { INT32 nC = 0; const char* lpsBuf = NULL; while (lpsClassName) { if (dlp_strcmp(lpsClassName,lpsBaseClassName)==0) return TRUE; lpsBuf = NULL; for (nC=0; nC<__nXClassRegistry; nC++) if (dlp_strcmp(__lpClassRegistry[nC].lpName,lpsClassName)==0) lpsBuf = __lpClassRegistry[nC].ex.fct.lpBaseClass; lpsClassName = lpsBuf; } return FALSE; }
/** * Creates a new instance of class <code>lpsClassName</code>. * * @param lpsClassName dLabPro class identifier * @param lpsInstanceName Name of new instance * @return A pointer to a new instance of class <code>lpsClassName</code> or * <code>NULL</code> in case of errors. * @see CDlpObject_RegisterClass * @see CDlpObject_UnregisterAllClasses */ CDlpObject* CDlpObject_CreateInstanceOf ( const char* lpsClassName, const char* lpsInstanceName ) { INT32 nC = 0; /* Current class index */ for (nC=0; nC<__nXClassRegistry; nC++) /* Loop over classes */ if /* If dLabPro or C/C++ id matches */ ( /* | */ dlp_strcmp(lpsClassName,__lpClassRegistry[nC].lpName )==0 || /* | */ dlp_strcmp(lpsClassName,__lpClassRegistry[nC].ex.fct.lpCname)==0 /* | */ ) /* | */ if (__lpClassRegistry[nC].ex.fct.lpfFactory) /* If there is a class factory */ return (__lpClassRegistry[nC].ex.fct.lpfFactory)(lpsInstanceName); /* Instantiate */ return NULL; /* Sorry, it didn't work out */ }
/** * Get data initializer '{ ... }' from command line and store into token list * lpsInit. * <h3>Note</h3> * <p>You must setup the method invocation context <code>m_lpMic</code> (see * <a href="dlpinst.html"><code class="link">CDlpInstance</code></a>) before * calling this method. Otherwise it will do noting.</p> * * @param lpsInit Pointer to character buffer to store initializer in. The * tokens will be separated by nulls '\0', opening and closing * curly braces will not be included! The token list will be * terminated with a double null "\0\0". * @param nLen Maximal number of characters to place on lpsInit (including * the terminal double null) * @param bForce If TRUE the method does not seek for the opening curly brace * but starts reading initializers until it encounters a closing * curly brace '}'. A leading opening curly brace will, however, * be tolerated. If FALSE the method <i>expects</i> an opening * curly brace and does not read any initializers if no leading * opening brace is found. * @return The number of initializers read */ INT32 CGEN_PROTECTED CData_ReadInitializer ( CData* _this, char* lpsInit, INT32 nLen, BOOL bForce ) { const char* lpsToken; /* Current token */ INT32 nCnt; /* Token counter */ INT32 nPos; /* Position in output buffer */ BOOL bStor; /* Store next token */ /* Initialize */ /* --------------------------------- */ if (!CDlpObject_MicGet(BASEINST(_this))) return 0; /* Need invocation context */ if (!lpsInit) return 0; /* Need output buffer */ dlp_memset(lpsInit,0,nLen); /* Clear output buffer */ /* Do initializers follow? */ /* --------------------------------- */ lpsToken = MIC_NEXTTOKEN_FORCE; /* Ruthlessly get next token */ if (!lpsToken || dlp_strcmp(lpsToken,"{")!=0) /* No or not the "{" token */ { /* >> */ if (bForce) IERROR(_this,DATA_NOTFOUND,"Constant initializer ","'{'",0); /* If there should be some-> error */ if (lpsToken) MIC_REFUSETOKEN; /* Wrong token -> push it back */ return 0; /* Now get out'a here */ } /* << */ /* Get 'em tokens */ /* --------------------------------- */ for (nCnt=0,nPos=0,bStor=TRUE; ; nCnt++) /* Infinitely ... */ { /* >> */ lpsToken = MIC_NEXTTOKEN_FORCE; /* Ruthlessly get next token */ if (!lpsToken) return IERROR(_this,DATA_HERESCAN,"}",0,0); /* No more tokens -> forget it */ if (dlp_strcmp(lpsToken,"}")==0) break; /* End token -> get out'a here */ if (nLen<nPos+(INT32)dlp_strlen(lpsToken)+2) bStor = FALSE; /* Cannot store more tokens :( */ if (!bStor) continue; /* Ignore ALL following tokens */ dlp_strcpy(&lpsInit[nPos],lpsToken); /* Store token */ nPos+=(INT32)dlp_strlen(&lpsInit[nPos])+1; /* Set next token pointer */ } /* << */ return nCnt; /* Return number of tokens read */ }
/** * Returns a pointer to the specified static field of CDlpObject. * * @param lpsName Identifier of field * - "in_file" : __lpInFile * - "in_line" : __nInLine * - "last_error_inst": __lpLastErrorInst * - "last_error" : __nLastError * - "elevel" : __nElevel * - "errors" : __nErrors * - "warnings" : __nWarnings * - "trace_error" : __lpsTraceError * @return The pointer if successfull, NULL otherwise. */ void* CDlpObject_GetStaticFieldPtr(const char* lpFieldIdentifier) { if (dlp_strcmp(lpFieldIdentifier,"in_file" )==0) return &__lpInFile; else if (dlp_strcmp(lpFieldIdentifier,"in_line" )==0) return &__nInLine; else if (dlp_strcmp(lpFieldIdentifier,"last_error_inst")==0) return &__iLastErrorInst; else if (dlp_strcmp(lpFieldIdentifier,"last_error" )==0) return &__nLastError; else if (dlp_strcmp(lpFieldIdentifier,"elevel" )==0) return &__nElevel; else if (dlp_strcmp(lpFieldIdentifier,"errors" )==0) return &__nErrors; else if (dlp_strcmp(lpFieldIdentifier,"warnings" )==0) return &__nWarnings; else if (dlp_strcmp(lpFieldIdentifier,"trace_error" )==0) return &__lpsTraceError; else return NULL; }
/* * Manual page in data.def */ INT16 CGEN_PUBLIC CData_Initialize(CData* _this) { const char* lpsToken = NULL; lpsToken = MIC_NEXTTOKEN_FORCE; if (!lpsToken) return 0; if (dlp_strcmp(lpsToken,"{")!=0) { MIC_REFUSETOKEN; return IERROR(_this,DATA_NOTFOUND,"Constant initializer ","'{'",0); } return CData_InitializeEx(_this,0,0,-1); }
/* * 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. }
INT16 CGEN_PRIVATE CFBAproc::SynthesizeUsingIntoGetFeaIntoLab(CData* idFea, CData* idInto, SLAB** sFeaLab, SLAB** sIntoLab, INT32* nSamples, INT32* nLab) { INT32 nSamplingPoints = idInto->GetNRecs(); INT32 iSamplingPoints1 = 0; INT32 iSamplingPoints2 = 0; INT32 nCompPho = -1; INT32 iFrames = 0; INT32 nFrames = idFea->GetNRecs(); INT32 iLab = 0; const char* lastUnit = NULL; const char* currUnit = NULL; FLOAT64 currDura = 0.0; nCompPho = idFea->FindComp("~PHO"); if(nCompPho < 0) nCompPho = idFea->FindComp("lab"); if(nCompPho < 0) return IERROR(this,FBA_SYNTHESISE,0,"Missing label track.",0); iLab = 0; iFrames = 1; lastUnit = idFea->Sfetch(0, nCompPho); while(iFrames < nFrames) { currUnit = idFea->Sfetch(iFrames, nCompPho); if(dlp_strcmp(currUnit, lastUnit)) { (*sFeaLab) = (SLAB*)dlp_realloc((*sFeaLab), iLab+1, sizeof(SLAB)); (*sFeaLab)[iLab].phoneme = lastUnit; (*sFeaLab)[iLab].pos = iFrames*m_nCrate; lastUnit = currUnit; iLab++; } iFrames++; } (*sFeaLab) = (SLAB*)dlp_realloc((*sFeaLab), iLab+1, sizeof(SLAB)); (*sFeaLab)[iLab].phoneme = lastUnit; (*sFeaLab)[iLab].pos = iFrames*m_nCrate; iLab++; *nLab = 0; lastUnit = ""; iSamplingPoints1 = 0; while(iSamplingPoints1 < nSamplingPoints) { currUnit = idInto->Sfetch(iSamplingPoints1, 0); currDura = idInto->Dfetch(iSamplingPoints1, 1); if((currDura <= 0) || (idInto->m_lpCunit[0] == '%')) { if(*nLab < iLab) { if((currDura >= 0) && (idInto->m_lpCunit[0] == '%')) { currDura = (((*sFeaLab)[*nLab].pos - ((*nLab==0)? 0: (*sFeaLab)[*nLab-1].pos)) * 1000 / m_nSrate) * (currDura / 100.0); } else { currDura = ((*sFeaLab)[*nLab].pos - ((*nLab==0)? 0: (*sFeaLab)[*nLab-1].pos)) * 1000 / m_nSrate; } iSamplingPoints2 = iSamplingPoints1; while((iSamplingPoints2 < nSamplingPoints) && !dlp_strcmp(idInto->Sfetch(iSamplingPoints2, 0), currUnit) && (idInto->Dfetch(iSamplingPoints2,1) <= 0)) { idInto->Dstore(currDura, iSamplingPoints2, 1); iSamplingPoints2++; } } else { dlp_free(*sFeaLab); return IERROR(this, FBA_SYNINTOLAB, currUnit, iLab-1, 0); } } if(dlp_strcmp(currUnit, lastUnit)) { if(dlp_strcmp(currUnit, (*sFeaLab)[*nLab].phoneme)) { dlp_free(*sFeaLab); return IERROR(this, FBA_SYNINTOLAB, lastUnit, iLab, 0); } lastUnit = currUnit; *nSamples += (INT32)(currDura * (FLOAT64)m_nSrate / 1000.0 +0.5); (*sIntoLab) = (SLAB*)dlp_realloc((*sIntoLab), *nLab+1, sizeof(SLAB)); (*sIntoLab)[*nLab].phoneme = currUnit; (*sIntoLab)[*nLab].pos = *nSamples; (*nLab)++; } iSamplingPoints1++; } return O_K; }
/** * Polymorphic set operations. * * @param lpsOpname * <p>Operator name</p> * <table> * <tr><th><code>lpsOpname</code></th><th>Boolean</th><th>Numeric</th><th>String</th><th>Instance</th></tr> * <tr><td><code>= </code></td><td>x</td><td>x</td><td>x</td><td>x</td></tr> * <tr><td><code>+= </code></td><td>x</td><td>x</td><td>x</td><td>-</td></tr> * <tr><td><code>-= </code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr> * <tr><td><code>*= </code></td><td>x</td><td>x</td><td>-</td><td>-</td></tr> * <tr><td><code>/= </code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr> * <tr><td><code>++=</code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr> * <tr><td><code>--=</code></td><td>-</td><td>x</td><td>-</td><td>-</td></tr> * </table> * <p>For type conversion rules see * <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackLogic</code>, * <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackNumber</code>, * <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackString</code> and * <code><a href="function.html"><code�class="link">CFunction</code></a><code>::StackInstance</code>. * </p> * @return <code>O_K</code> if successfull, a (negative) error code otherwise */ INT16 CGEN_PROTECTED CVar_SetOp(CVar *_this,const char* lpsOpname) { StkItm si; if (dlp_strcmp(lpsOpname,"++=")!=0 && dlp_strcmp(lpsOpname,"--=")!=0) { if (!CDlpObject_MicGet(BASEINST(_this))->GetX) return IERROR(_this,VAR_NOTSUPPORTED,"Polymorphic signatures"," by caller",0); if (!MIC_GET_X(1,&si)) return NOT_EXEC; } if (dlp_strcmp(lpsOpname,"=")==0) switch (si.nType) { case T_BOOL : return CVar_Bset(_this,si.val.b); case T_COMPLEX : return CVar_Vset(_this,si.val.n); case T_STRING : return CVar_Sset(_this,si.val.s); case T_INSTANCE: return CVar_Iset(_this,si.val.i); default: DLPASSERT(FMSG("Unknown variable type")); return NOT_EXEC; } else if (dlp_strcmp(lpsOpname,"+=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_PLUS(_this->m_nNVal,si.val.n)); if (_this->m_nType==T_STRING) { char* lpsSi = NULL; MIC_PUT_X(&si); lpsSi = MIC_GET_S(1,0); _this->m_lpsSVal = (char*)dlp_realloc(_this->m_lpsSVal, dlp_strlen(_this->m_lpsSVal)+dlp_strlen(lpsSi)+1,sizeof(char)); if (!_this->m_lpsSVal) return IERROR(_this,ERR_NOMEM,0,0,0); dlp_strcat(_this->m_lpsSVal,lpsSi); return O_K; } if (_this->m_nType==T_BOOL) { MIC_PUT_X(&si); _this->m_bBVal|=MIC_GET_B(1,0); return O_K; } return IERROR(_this,VAR_NOTSUPPORTED,"Operator +="," for this variable type",0); } else if (dlp_strcmp(lpsOpname,"*=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MULT(_this->m_nNVal,si.val.n)); if (_this->m_nType==T_BOOL) { MIC_PUT_X(&si); _this->m_bBVal&=MIC_GET_B(1,0); return O_K; } return IERROR(_this,VAR_NOTSUPPORTED,"Operator *="," for this variable type",0); } else if (dlp_strcmp(lpsOpname,"-=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MINUS(_this->m_nNVal,si.val.n)); return IERROR(_this,VAR_NOTSUPPORTED,"Operator -="," for this variable type",0); } else if (dlp_strcmp(lpsOpname,"/=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_MULT(_this->m_nNVal,CMPLX_INVT(si.val.n))); return IERROR(_this,VAR_NOTSUPPORTED,"Operator /="," for this variable type",0); } else if (dlp_strcmp(lpsOpname,"++=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_INC(_this->m_nNVal)); return IERROR(_this,VAR_NOTSUPPORTED,"Operator ++="," for this variable type",0); } else if (dlp_strcmp(lpsOpname,"--=")==0) { if (_this->m_nType==T_COMPLEX) return CVar_Vset(_this,CMPLX_DEC(_this->m_nNVal)); return IERROR(_this,VAR_NOTSUPPORTED,"Operator --="," for this variable type",0); } return NOT_EXEC; }
/** * Command handler for the "dlgupd" command: performs a dialog FST transition. * * @param lpsCmd * The command in the format "dlgupd <state>", where <state> * is the input label of the dialog transition to perform. */ void dlgupd(char* lpsCmd){ char *lpsRes=dlp_strsep(&lpsCmd," \t",NULL); if (dlp_strcmp(lpsRes,"__WAKEUP__")==0) nLastActive = nFrame; dlg_upd(lpsRes); }
INT16 CGEN_VPROTECTED CFBAproc::SynthesizeUsingInto(data *idFea, data *idInto, data *idSyn) { INT32 nSamplingPoints = idInto->GetNRecs(); INT32 iSamplingPoints1 = 0; INT32 iSamples = 0; INT32 iSamplesOld = 0; INT32 nSamples = 0; INT32 nSamplesOfLastUnits = 0; INT32 nSampleOfLastF0SamplingPoint = 0; INT32 nSampleOfNextF0SamplingPoint = 0; INT32 nPer = 0; INT32 iFrames = 0; INT32 iFramesOld = 0; INT32 nFrames = idFea->GetNRecs(); INT32 iLab = 0; INT32 nLab = 0; INT32 iFea = 0; INT32 nCompVuv = idFea->FindComp("v/uv"); INT32 nFea = idFea->GetNNumericComps() - (nCompVuv >= 0 ? 1 : 0); const char* nextF0Pho = NULL; FLOAT64 lastF0Val = 1.0; FLOAT64 currF0Val = 1.0; FLOAT64 nextF0Val = 1.0; FLOAT64 nextF0Pos = 0.0; FLOAT64 lastI0Val = 1.0; FLOAT64 currI0Val = 1.0; FLOAT64 nextI0Val = 1.0; FLOAT64* exc = NULL; FLOAT64* fea = NULL; FLOAT64* feaBefore = NULL; FLOAT64* feaUsed = NULL; FLOAT64* feaUsedBefore = NULL; BOOL isVoiceless = FALSE; BOOL isSmoothable = FALSE; BOOL isSmoothableBefore = FALSE; SLAB* sIntoLab = NULL; SLAB* sFeaLab = NULL; if(nSamplingPoints <= 0) { return O_K; } if(SynthesizeUsingIntoGetFeaIntoLab(idFea, idInto, &sFeaLab, &sIntoLab, &nSamples, &nLab) != O_K) { if(sFeaLab != NULL) dlp_free(sFeaLab); if(sIntoLab != NULL) dlp_free(sIntoLab); return NOT_EXEC; } exc = (FLOAT64*)dlp_malloc(nSamples * sizeof(FLOAT64)); fea = (FLOAT64*)dlp_malloc(nFea * sizeof(FLOAT64)); feaBefore = (FLOAT64*)dlp_malloc(nFea * sizeof(FLOAT64)); idSyn->Reset(TRUE); idSyn->AddComp("syn", T_DOUBLE); idSyn->Allocate(nSamples); iFrames = 0; iLab = 0; iSamplingPoints1 = 0; iSamples = 0; iSamplesOld = 0; iFramesOld = 0; nSamplesOfLastUnits = 0; while(iSamples < nSamples) { if(iSamples >= nSampleOfNextF0SamplingPoint) { lastF0Val = nextF0Val; lastI0Val = nextI0Val; nSampleOfLastF0SamplingPoint = nSampleOfNextF0SamplingPoint; while(iSamples >= nSampleOfNextF0SamplingPoint) { for(; iSamplingPoints1 < nSamplingPoints; iSamplingPoints1++) { nextF0Pho = idInto->Sfetch(iSamplingPoints1, 2); nextF0Val = idInto->Dfetch(iSamplingPoints1, 3); nextI0Val = idInto->Dfetch(iSamplingPoints1, 6); nextF0Pos = idInto->Dfetch(iSamplingPoints1, 4); if(iSamplingPoints1 && dlp_strcmp(idInto->Sfetch(iSamplingPoints1-1, 0), idInto->Sfetch(iSamplingPoints1, 0))) { nSamplesOfLastUnits += (INT32)idInto->Dfetch(iSamplingPoints1-1, 1); } if((nextF0Val > 0.0) && (nextF0Pos >= 0.0) && (nextF0Pho != NULL) && (dlp_strlen(nextF0Pho) > 0)) { break; } else { if(this->m_nCheck > 0) { dlp_message(__FILE__,__LINE__,"no next f0 value"); } } } if(iSamplingPoints1 >= nSamplingPoints) { nextF0Val = 1.0; nextI0Val = 1.0; nSampleOfNextF0SamplingPoint = nSamples; } else { nSampleOfNextF0SamplingPoint = (INT32)(((FLOAT64)nSamplesOfLastUnits + idInto->Dfetch(iSamplingPoints1, 1) * nextF0Pos) * (FLOAT64)m_nSrate / 1000.0 + 0.5); iSamplingPoints1++; } } } currF0Val = lastF0Val + (nextF0Val - lastF0Val) * (iSamples - nSampleOfLastF0SamplingPoint) / (nSampleOfNextF0SamplingPoint+1 - nSampleOfLastF0SamplingPoint); nPer = (INT32)((FLOAT64)m_nSrate / (currF0Val * (FLOAT64)m_nBaseF0) + 0.5); if((iSamples+nPer) > nSamples) nPer = nSamples-iSamples; currI0Val = lastI0Val + (nextI0Val - lastI0Val) * (iSamples - nSampleOfLastF0SamplingPoint) / (nSampleOfNextF0SamplingPoint+1 - nSampleOfLastF0SamplingPoint); while((iLab < nLab) && (sIntoLab[iLab].pos < iSamples)) { iSamplesOld = sIntoLab[iLab].pos; iFramesOld = INT32((FLOAT64)sFeaLab[iLab].pos / (FLOAT64)m_nCrate + 0.5); iLab++; } while((iFrames < nFrames) && (((FLOAT64)(((iFrames-iFramesOld+1L))*m_nCrate)/((iLab>0)?(FLOAT64)(sFeaLab[iLab].pos -sFeaLab[iLab-1].pos ):sFeaLab[iLab].pos )) < ((FLOAT64)(iSamples-iSamplesOld) /((iLab>0)?(FLOAT64)(sIntoLab[iLab].pos-sIntoLab[iLab-1].pos):sIntoLab[iLab].pos)))) iFrames++; dlp_memmove(fea, (FLOAT64*)idFea->XAddr(iFrames, 0), nFea*sizeof(FLOAT64)); if(m_bSynEnhancement) { FeaEnhancement(fea, nFea); } if(nCompVuv>=0) { isVoiceless = (*(INT16*)idFea->XAddr(iFrames, nCompVuv) & 1) == 0; isSmoothable = (*(INT16*)idFea->XAddr(iFrames, nCompVuv) & 2) == 0; } else { isVoiceless = IsFeaVoiceless(fea, nFea); isSmoothable = 1; } if(feaUsed == NULL) { feaUsed = (FLOAT64*)dlp_malloc(nFea*sizeof(FLOAT64)); dlp_memmove(feaUsed, fea, nFea*sizeof(FLOAT64)); } if(m_bSynSmoothFea) { if(feaUsedBefore == NULL) { feaUsedBefore = (FLOAT64*)dlp_malloc(nFea*sizeof(FLOAT64)); dlp_memmove(feaUsedBefore, fea, nFea*sizeof(FLOAT64)); } else { if(isSmoothableBefore && isSmoothable) { for(iFea = 0; iFea < nFea; iFea++) { feaUsed[iFea] = 0.29289322 * (feaBefore[iFea] + fea[iFea]) + 0.41421356 * feaUsedBefore[iFea]; } } else if(isSmoothableBefore && !isSmoothable) { for(iFea = 0; iFea < nFea; iFea++) { feaUsed[iFea] = 0.75 * feaBefore[iFea] + 0.25 * fea[iFea]; } } else if(!isSmoothableBefore && isSmoothable) { for(iFea = 0; iFea < nFea; iFea++) { feaUsed[iFea] = 0.25 * feaBefore[iFea] + 0.75 * fea[iFea]; } } else { dlp_memmove(feaUsed, fea, nFea*sizeof(FLOAT64)); } } isSmoothableBefore = isSmoothable; dlp_memmove(feaUsedBefore, feaUsed, nFea*sizeof(FLOAT64)); } else { dlp_memmove(feaUsed, fea, nFea*sizeof(FLOAT64)); } dlp_memmove(feaBefore, fea, nFea*sizeof(FLOAT64)); FLOAT64 gain = ((m_nWnorm == 0 ) ? 1.0 : (FLOAT64)sqrt((double)nPer)) * exp(m_nBaseI0) * currI0Val; switch(m_lpsExcType[0]) { case 'P': dlm_getExcPeriod(nPer, !isVoiceless, DLM_PITCH_PULSE, 1.0/gain, m_nSrate, exc+iSamples); break; case 'G': dlm_getExcPeriod(nPer, !isVoiceless, DLM_PITCH_GLOTT, 1.0/gain, m_nSrate, exc+iSamples); break; case 'R': dlm_getExcPeriod(nPer, !isVoiceless, DLM_PITCH_RANDPHASE, 1.0/gain, m_nSrate, exc+iSamples); break; case 'V': dlm_getExcPeriod(nPer, !isVoiceless, DLM_PITCH_VOICED, 1.0/gain, m_nSrate, exc+iSamples); break; case 'U': dlm_getExcPeriod(nPer, !isVoiceless, DLM_PITCH_UNVOICED, 1.0/gain, m_nSrate, exc+iSamples); break; default: return IERROR(this,FBA_BADARG,m_lpsExcType,"exc_type","P, G, R, V or U"); } if(this->m_nCheck > 0) { dlp_message(__FILE__,__LINE__,"nPer=%5d, uv/v=%1d, s/ns=%ld, pos=%7.1f, F0=%4.2f/%4.2f/%4.2f, idFea (%3d) %5s, Fea (%3d): %5s (%3d), Into (%3d) %5s (%3d)", \ (int)nPer, (int)!isVoiceless, (int)isSmoothable, (double)((FLOAT64)iSamples*1000.0/(FLOAT64)m_nSrate), (double)lastF0Val, (double)currF0Val, (double)nextF0Val, (int)iFrames, idFea->Sfetch(iFrames, nFea), (int)iLab, sFeaLab[iLab].phoneme, (int)sFeaLab[iLab].pos, (int)iLab, sIntoLab[iLab].phoneme, (int)sIntoLab[iLab].pos); } if(SynthesizeFrame(feaUsed, nFea, &exc[iSamples], nPer, (FLOAT64*)idSyn->XAddr(iSamples, 0)) != O_K) return IERROR(this,FBA_SYNTHESISE, iFrames, 0,0); iSamples += nPer; } dlp_free(exc); dlp_free(sIntoLab); dlp_free(sFeaLab); dlp_free(fea); dlp_free(feaBefore); dlp_free(feaUsed); if(m_bSynSmoothFea) { dlp_free(feaUsedBefore); } 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; }
/* * Manual page at function.def */ INT16 CGEN_PUBLIC CFunction::OnInternalize() { // Delegate to running function // ------------------------------------ FNC_DELEGATE OnInternalize(); // 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 // Error IERROR(this,FNC_EXPECT,"field identifier or * after -internalize",0,0); // | // Initialize // ------------------------------------ INT16 bAll = (!dlp_strcmp(lpsId,"*")); // Determine if processing all fields SWord* lpWrd = NULL; // Pointer to current field word hscan_t hs; // Pointer to hash table scan struct hnode_t* hn = NULL; // Pointer to current hash table node hash_scan_begin(&hs,iCont->m_lpDictionary); // Initialize enumerating dictionary if (bAll) // Internalize all fields? { // >> hn = hash_scan_next(&hs); // Get pointer to first word DLPASSERT((lpWrd=(SWord*)hnode_get(hn))); // NULL entry in dictionary } // << else // Internalize single field { // >> lpWrd = iCont->FindWord(lpsId,WL_TYPE_FIELD); // Find field word if (!lpWrd) return IERROR(this,ERR_NOTFIELD,lpsId,0,0); // Not found --> error } // << // Do internalize // ------------------------------------ while (lpWrd) // Loop over words { // >> if // Word must: ( // | lpWrd->nWordType==WL_TYPE_FIELD && // - be field ... lpWrd->ex.fld.nType==T_INSTANCE && // - ... of instance type lpWrd->lpData // - have data ) // | { // >> CHECK_IPTR(*(CDlpObject**)lpWrd->lpData,lpWrd->ex.fld.nISerialNum); // If ptr. invalid, make it NULL CDlpObject* iInst = *(CDlpObject**)lpWrd->lpData; // Get pointer to instance if (iInst) // Pointer is valid { // >> SWord* lpCcnt = iInst->m_lpContainer; // Get current instance container if (lpCcnt && lpCcnt->nWordType==WL_TYPE_INSTANCE) // If curr. cont. is inst. word { // >> (take over ownership) if (lpCcnt->lpContainer) // Current container instance? ((CDlpObject*)lpCcnt->lpContainer)->UnregisterWord(lpCcnt,FALSE); // Unregister (don't destroy) iInst->m_lpContainer = lpWrd; // Set curr. word as container } // << } // << } // << if (!bAll) break; // Processing single field: stop if (!(hn = hash_scan_next(&hs))) break; // Get next dictionary entry DLPASSERT((lpWrd=(SWord*)hnode_get(hn))); // NULL entry in dictionary } // << return O_K; // Done. }
INT16 CGEN_VPROTECTED CCPproc::OnPfaLambdaChangedImpl() { if(!dlp_strcmp(m_lpsType, "MelFilter")) { return CMELproc::OnPfaLambdaChangedImpl(); } return O_K; }