corpusManager.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. *
  3. * corpusManager.h
  4. * (c) HAL 2010-
  5. *
  6. * This files is a part of v.Connect.
  7. * corpusManager is a class that controls corpus based on UTAU.
  8. * This class convert UTAU WAVE corpus into WORLD specgrams.
  9. *
  10. * These files are distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. */
  15. #ifndef __corpusManager_h__
  16. #define __corpusManager_h__
  17. #include <list>
  18. #include <tuple>
  19. #include "stand.h"
  20. #include "utau/UtauDB.h"
  21. #include "vConnectSetting.h"
  22. #include "RuntimeOption.h"
  23. #include "vsq/Sequence.h"
  24. #include "Mutex.h"
  25. using namespace vconnect;
  26. class vConnectPhoneme;
  27. class corpusManager
  28. {
  29. public:
  30. corpusManager();
  31. ~corpusManager();
  32. class phoneme {
  33. public:
  34. phoneme()
  35. {
  36. p = NULL;
  37. isProcessing = false;
  38. isValid = false;
  39. #if defined( STND_MULTI_THREAD )
  40. waitHandle = NULL;
  41. #endif
  42. fixedLength = 0;
  43. brightness = 64;
  44. enableBrightness = false;
  45. frequency = 0.0f;
  46. enableFrequency = false;
  47. children = NULL;
  48. }
  49. vConnectPhoneme *p;
  50. bool isProcessing;
  51. bool isValid;
  52. float fixedLength;
  53. int brightness;
  54. bool enableBrightness;
  55. float frequency;
  56. bool enableFrequency;
  57. phoneme *children;
  58. #if defined( STND_MULTI_THREAD )
  59. Mutex *waitHandle;
  60. #endif
  61. };
  62. struct itemForAnalyze {
  63. list<Event*> itemList;
  64. };
  65. void setUtauDB( UtauDB *p, RuntimeOption &option );
  66. /// <summary>
  67. /// 歌詞にマッチする音素片を得ます.
  68. /// </summary>
  69. /// <param name="lyric"> 検索する音素片に対応する歌詞 </param>
  70. /// <returns> 検索に成功したとき該当する音素片へのポインタ,それ以外のときはNULLを返します. </returns>
  71. phoneme *getPhoneme(string const& lyric, int note_number );
  72. /// <summary>
  73. /// 歌詞にマッチする音素片を引数で指定したリストへ追加します.
  74. /// 追加データベースを使用する場合はこちらの関数を使用してください.
  75. /// </summary>
  76. /// <param name="lyric"> 検索する音素片に対応する歌詞 </param>
  77. /// <param name="phonemeList"> 音素片を追加するリスト </param>
  78. phoneme *getPhoneme(string const& lyric, int note_number, list<phoneme*> &phonemeList);
  79. /// <summary>
  80. /// 今のところ分析済みファイルの読み込みを行っています.
  81. /// 動作が変わる可能性も.
  82. /// </summary>
  83. /// <param name="phonemes">解析する音素と音程のリスト.</param>
  84. void analyze( vector<tuple<string, int>> &phonemes );
  85. void setCorpusSetting(librarySetting *setting);
  86. bool checkEnableExtention();
  87. void setIsAppend(bool isAppend){ mIsAppend = isAppend; }
  88. void setBrightness(int bri){ if(0 <= bri && bri <= 128) mBrightness = bri; }
  89. private:
  90. Map<string, phoneme *> objectMap;
  91. vector<corpusManager *> mAppendCorpus;
  92. UtauDB *mUtauDB;
  93. string mDBPath;
  94. vConnectSetting setting;
  95. bool mEnableExtention;
  96. int mBrightness;
  97. bool mEnableBrightness;
  98. float mFrequency;
  99. bool mEnableFrequency;
  100. bool mIsAppend;
  101. };
  102. #endif // __corpusManager_h__