LabelMaker.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* ----------------------------------------------------------------- */
  2. /* The HMM-Based Singing Voice Synthesis System "Sinsy" */
  3. /* developed by Sinsy Working Group */
  4. /* http://sinsy.sourceforge.net/ */
  5. /* ----------------------------------------------------------------- */
  6. /* */
  7. /* Copyright (c) 2009-2015 Nagoya Institute of Technology */
  8. /* Department of Computer Science */
  9. /* */
  10. /* All rights reserved. */
  11. /* */
  12. /* Redistribution and use in source and binary forms, with or */
  13. /* without modification, are permitted provided that the following */
  14. /* conditions are met: */
  15. /* */
  16. /* - Redistributions of source code must retain the above copyright */
  17. /* notice, this list of conditions and the following disclaimer. */
  18. /* - Redistributions in binary form must reproduce the above */
  19. /* copyright notice, this list of conditions and the following */
  20. /* disclaimer in the documentation and/or other materials provided */
  21. /* with the distribution. */
  22. /* - Neither the name of the Sinsy working group nor the names of */
  23. /* its contributors may be used to endorse or promote products */
  24. /* derived from this software without specific prior written */
  25. /* permission. */
  26. /* */
  27. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
  28. /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  29. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  30. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  31. /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
  32. /* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
  33. /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
  34. /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
  35. /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
  36. /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
  37. /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
  38. /* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  39. /* POSSIBILITY OF SUCH DAMAGE. */
  40. /* ----------------------------------------------------------------- */
  41. #ifndef SINSY_LABEL_MAKER_H_
  42. #define SINSY_LABEL_MAKER_H_
  43. #include <string>
  44. #include <vector>
  45. #include <deque>
  46. #include "IScoreWritable.h"
  47. #include "Beat.h"
  48. #include "Dynamics.h"
  49. #include "Mode.h"
  50. #include "IConvertable.h"
  51. #include "Converter.h"
  52. #include "IConf.h"
  53. #include "TempScore.h"
  54. #include "NoteLabeler.h"
  55. #include "SyllableLabeler.h"
  56. #include "PhonemeLabeler.h"
  57. #include "LabelData.h"
  58. #include "ILabelOutput.h"
  59. #ifdef HAVE_HTS
  60. #include "SynthConditionImpl.h"
  61. #endif
  62. namespace sinsy
  63. {
  64. class LabelMaker : public IScoreWritable
  65. {
  66. public:
  67. //! constructor
  68. explicit LabelMaker(Converter& converter, bool sepRests = true);
  69. //! destructor
  70. virtual ~LabelMaker();
  71. //! set encoding
  72. virtual void setEncoding(const std::string& e);
  73. //! change tempo
  74. virtual void changeTempo(double t);
  75. //! change beat
  76. virtual void changeBeat(const Beat& b);
  77. //! change dynamics
  78. virtual void changeDynamics(const Dynamics& d);
  79. //! change key
  80. virtual void changeKey(const Key& k);
  81. //! start crescendo
  82. virtual void startCrescendo();
  83. //! start diminuendo
  84. virtual void startDiminuendo();
  85. //! stop crescendo
  86. virtual void stopCrescendo();
  87. //! stop diminuendo
  88. virtual void stopDiminuendo();
  89. //! add note
  90. virtual void addNote(const Note& note);
  91. //! fix
  92. void fix();
  93. //! output label
  94. void outputLabel(ILabelOutput& output, bool monophoneFlag = false, int overwriteEnableFlag = 0, int timeFlag = 0) const;
  95. private:
  96. //! copy constructor (donot use)
  97. LabelMaker(const LabelMaker&);
  98. //! assignment operator (donot use)
  99. LabelMaker& operator=(const LabelMaker&);
  100. //! get last measure
  101. LabelMeasure* getLastMeasure();
  102. //! converter
  103. Converter& converter;
  104. //! encoding of lyrics
  105. std::string encoding;
  106. //! ...
  107. bool separateWholeNoteRests;
  108. //! is fixed or not
  109. bool isFixed;
  110. //! temporary score
  111. TempScore tempScore;
  112. //! tempo
  113. double tempo;
  114. //! key
  115. Key key;
  116. //! beat
  117. Beat beat;
  118. //! dynamics
  119. Dynamics dynamics;
  120. //! number of syllables
  121. size_t syllableNum;
  122. //! in tie
  123. bool inTie;
  124. //! in crescendo
  125. bool inCrescendo;
  126. //! in diminuendo
  127. bool inDiminuendo;
  128. //! position of measure
  129. LabelPosition measurePosition;
  130. //! duration of residual measure
  131. int residualMeasureDuration;
  132. typedef std::deque<LabelMeasure*> MeasureQue;
  133. //! stock of measures
  134. MeasureQue stockMeasures;
  135. typedef std::vector<LabelMeasure*> MeasureList;
  136. //! list of measures
  137. MeasureList measureList;
  138. typedef std::vector<NoteGroup*> NoteGroupList;
  139. //! list of phrases
  140. NoteGroupList phraseList;
  141. //! list of crescendos
  142. NoteGroupList crescendoList;
  143. //! list of diminuendos
  144. NoteGroupList diminuendoList;
  145. typedef std::vector<NoteLabeler*> NoteList;
  146. //! list of notes
  147. NoteList noteList;
  148. typedef NoteList::const_iterator ConstNoteItr;
  149. //! move to previous note
  150. bool moveToPrevNote(ConstNoteItr& nItr, bool skipRests) const;
  151. //! move to next note
  152. bool moveToNextNote(ConstNoteItr& nItr, bool skipRests) const;
  153. typedef NoteLabeler::List::const_iterator ConstSyllableItr;
  154. //! move to previous syllable
  155. bool moveToPrevSyllable(ConstNoteItr& nItr, ConstSyllableItr& sItr, bool skipRests) const;
  156. //! move to next syllable
  157. bool moveToNextSyllable(ConstNoteItr& nItr, ConstSyllableItr& sItr, bool skipRests) const;
  158. typedef SyllableLabeler::List::const_iterator ConstPhonemeItr;
  159. //! move to previous phoneme
  160. bool moveToPrevPhoneme(ConstNoteItr& nItr, ConstSyllableItr& sItr, ConstPhonemeItr& pItr, bool skipRests) const;
  161. //! move to next phoneme
  162. bool moveToNextPhoneme(ConstNoteItr& nItr, ConstSyllableItr& sItr, ConstPhonemeItr& pItr, bool skipRests) const;
  163. //! set label data
  164. void setLabelData(LabelData& label, const ConstNoteItr& noteItr, const ConstSyllableItr& syllableItr, const ConstPhonemeItr& phonemeItr, int overwriteEnableFlag, int timeFlag) const;
  165. //! apply stocks
  166. void applyStocks();
  167. };
  168. };
  169. #endif // SINSY_LABEL_MAKER_H_