Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.0 KiB

  1. /******************************************************************************
  2. * vapiIo.h *
  3. *----------*
  4. * I/O library functions for extended speech files (vapi format)
  5. *------------------------------------------------------------------------------
  6. * Copyright (C) 2000 Microsoft Corporation Date: 03/02/00
  7. * All Rights Reserved
  8. *
  9. ********************************************************************* PACOG ***/
  10. #ifndef __VAPIIO_H_
  11. #define __VAPIIO_H_
  12. #include <windows.h>
  13. #include <mmreg.h>
  14. #define VAPI_MAX_LABEL 80
  15. // File open modes
  16. enum {
  17. VAPI_IO_READ = 1,
  18. VAPI_IO_WRITE,
  19. VAPI_IO_READWRITE
  20. };
  21. // Error codes
  22. enum {
  23. VAPI_IOERR_NOERROR,
  24. VAPI_IOERR_MODE,
  25. VAPI_IOERR_MEMORY,
  26. VAPI_IOERR_CANTOPEN,
  27. VAPI_IOERR_NOWAV,
  28. VAPI_IOERR_NOFORMAT,
  29. VAPI_IOERR_STEREO,
  30. VAPI_IOERR_FORMAT,
  31. VAPI_IOERR_NOCHUNK,
  32. VAPI_IOERR_DATAACCESS,
  33. VAPI_IOERR_F0SFACCESS,
  34. VAPI_IOERR_FEATACCESS,
  35. VAPI_IOERR_EPOCHACCESS,
  36. VAPI_IOERR_LABELACCESS,
  37. VAPI_IOERR_WRITEWAV,
  38. VAPI_IOERR_CREATECHUNK,
  39. VAPI_IOERR_WRITECHUNK
  40. };
  41. // Possible values for sample format
  42. enum {
  43. VAPI_PCM16,
  44. VAPI_PCM8,
  45. VAPI_ALAW,
  46. VAPI_ULAW
  47. };
  48. // TYPES
  49. struct Epoch {
  50. double time;
  51. char voiced;
  52. };
  53. struct Label {
  54. char label[VAPI_MAX_LABEL];
  55. float endTime;
  56. };
  57. struct F0Vector {
  58. float* f0;
  59. int nF0;
  60. int sampFreq;
  61. };
  62. //----------------------------------------------------------------------
  63. // VAPI FILE I/O CLASS
  64. //
  65. class VapiIO
  66. {
  67. public:
  68. virtual ~VapiIO() {};
  69. virtual int OpenFile ( const char* pszFileName, int iMode ) = 0;
  70. virtual int OpenFile ( const WCHAR* wcsFileName, int iMode ) = 0;
  71. virtual void CloseFile ( ) = 0;
  72. virtual int CreateChunk ( const char* pszNname ) = 0;
  73. virtual int CloseChunk ( ) = 0;
  74. virtual int WriteToChunk (const char* pcData, int iSize) = 0;
  75. virtual int GetDataSize (long* lDataSize) = 0;
  76. virtual int Format (int* piSampFreq, int* piFormat, WAVEFORMATEX* pWaveFormatEx = NULL) = 0;
  77. virtual int WriteFormat (int iSampFreq, int iFormat) = 0;
  78. virtual int ReadSamples (double dFrom, double dTo, void** pvSamples, int* iNumSamples, bool bClosedInterval) = 0;
  79. virtual int WriteSamples (void* pvSamples, int iNumSamples) = 0;
  80. virtual int ReadF0SampFreq (int* piSampFreq) = 0;
  81. virtual int WriteF0SampFreq (int iSampFreq) = 0;
  82. virtual int ReadFeature (char* pszName, float** ppfSamples, int* piNumSamples) = 0;
  83. virtual int WriteFeature (char* pszName, float* pfSamples, int iNumSamples) = 0;
  84. virtual int ReadEpochs (Epoch** ppEpochs, int* piNumEpochs) = 0;
  85. virtual int WriteEpochs (Epoch* pEpochs, int iNumEpochs) = 0;
  86. virtual int ReadLabels (char* pszName, Label** ppLabels, int* piNumLabels) = 0;
  87. virtual int WriteLabels (char* pszName, Label* pLabels, int iNumLabels) = 0;
  88. virtual char* ErrMessage (int iErrCode) = 0;
  89. static int TypeOf (WAVEFORMATEX *pWavFormat);
  90. static int SizeOf (int iType);
  91. static int DataFormatConversion (char* pcInput, int iInType,
  92. char* pcOutput, int iOutType, int iNumSamples);
  93. static VapiIO* ClassFactory();
  94. // High Level Functions
  95. static int ReadVapiFile (const char* pszFileName, short** ppnSamples, int* piNumSamples,
  96. int* piSampFreq, int* piSampFormat,int* piF0SampFreq, float** ppfF0, int* piNumF0,
  97. float** ppfRms, int* piNumRms, Epoch** ppEpochs, int* piNumEpochs,
  98. Label** ppPhones, int* piNumPhones, Label** ppWords, int* piNumWords);
  99. static int WriteVapiFile (const char* pszFileName, short* pnSamples, int iNumSamples, int iFormat,
  100. int iSampFreq, int iF0SampFreq, float* pfF0, int iNumF0,
  101. float* pfRms, int iNumRms, Epoch* pEpochs, int iNumEpochs,
  102. Label* pPhones, int iNumPhones, Label* pWords, int iNumWords);
  103. };
  104. #endif