Note.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. #include "Note.h"
  42. namespace sinsy
  43. {
  44. /*!
  45. constructor
  46. */
  47. Note::Note() : restNote(true), duration(0), breathMark(false), accent(false), staccato(false),
  48. tieStart(false), tieStop(false), slurStart(false), slurStop(false)
  49. {
  50. }
  51. /*!
  52. copy constructor
  53. */
  54. Note::Note(const Note& obj) :
  55. restNote(obj.restNote), duration(obj.duration), breathMark(obj.breathMark),
  56. accent(obj.accent), staccato(obj.staccato), tieStart(obj.tieStart), tieStop(obj.tieStop),
  57. slur(obj.slur), slurStart(obj.slurStart), slurStop(obj.slurStop), pitch(obj.pitch), syllabic(obj.syllabic), lyric(obj.lyric)
  58. {
  59. }
  60. /*!
  61. destructor
  62. */
  63. Note::~Note()
  64. {
  65. }
  66. /*!
  67. set duration
  68. */
  69. void Note::setDuration(size_t d)
  70. {
  71. duration = d;
  72. }
  73. /*!
  74. get duration
  75. */
  76. size_t Note::getDuration() const
  77. {
  78. return duration;
  79. }
  80. /*!
  81. set pitch
  82. */
  83. void Note::setPitch(const Pitch& p)
  84. {
  85. pitch = p;
  86. }
  87. /*!
  88. get pitch
  89. */
  90. const Pitch& Note::getPitch() const
  91. {
  92. return pitch;
  93. }
  94. /*!
  95. set rest
  96. */
  97. void Note::setRest(bool b)
  98. {
  99. restNote = b;
  100. }
  101. /*!
  102. is rest or not
  103. */
  104. bool Note::isRest() const
  105. {
  106. return restNote;
  107. }
  108. /*!
  109. set lyric
  110. */
  111. void Note::setLyric(const std::string& s)
  112. {
  113. lyric = s;
  114. }
  115. /*!
  116. get lyric
  117. */
  118. const std::string& Note::getLyric() const
  119. {
  120. return lyric;
  121. }
  122. /*!
  123. set syllabic
  124. */
  125. void Note::setSyllabic(const Syllabic& s)
  126. {
  127. syllabic = s;
  128. }
  129. /*!
  130. get syllabic
  131. */
  132. const Syllabic& Note::getSyllabic() const
  133. {
  134. return syllabic;
  135. }
  136. /*!
  137. set breath mark
  138. */
  139. void Note::setBreathMark(bool b)
  140. {
  141. breathMark = b;
  142. }
  143. /*!
  144. has breath mark or not
  145. */
  146. bool Note::hasBreathMark() const
  147. {
  148. return breathMark;
  149. }
  150. /*!
  151. set accent
  152. */
  153. void Note::setAccent(bool b)
  154. {
  155. accent = b;
  156. }
  157. /*!
  158. has accent or not
  159. */
  160. bool Note::hasAccent() const
  161. {
  162. return accent;
  163. }
  164. /*!
  165. set staccato
  166. */
  167. void Note::setStaccato(bool b)
  168. {
  169. staccato = b;
  170. }
  171. /*!
  172. has staccato or not
  173. */
  174. bool Note::hasStaccato() const
  175. {
  176. return staccato;
  177. }
  178. /*!
  179. set tie start
  180. */
  181. void Note::setTieStart(bool b)
  182. {
  183. tieStart = b;
  184. }
  185. /*!
  186. is tie start or not
  187. */
  188. bool Note::isTieStart() const
  189. {
  190. return tieStart;
  191. }
  192. /*!
  193. set tie stop
  194. */
  195. void Note::setTieStop(bool b)
  196. {
  197. tieStop = b;
  198. }
  199. /*!
  200. is tie stop or not
  201. */
  202. bool Note::isTieStop() const
  203. {
  204. return tieStop;
  205. }
  206. /*!
  207. get slur
  208. */
  209. const Slur& Note::getSlur() const
  210. {
  211. return slur;
  212. }
  213. /*!
  214. get slur
  215. */
  216. Slur& Note::getSlur()
  217. {
  218. return slur;
  219. }
  220. /*!
  221. set slur start
  222. */
  223. void Note::setSlurStart(bool b)
  224. {
  225. slurStart = b;
  226. }
  227. /*!
  228. is slur start or not
  229. */
  230. bool Note::isSlurStart() const
  231. {
  232. return slurStart;
  233. }
  234. /*!
  235. set slur stop
  236. */
  237. void Note::setSlurStop(bool b)
  238. {
  239. slurStop = b;
  240. }
  241. /*!
  242. is slur stop or not
  243. */
  244. bool Note::isSlurStop() const
  245. {
  246. return slurStop;
  247. }
  248. /*!
  249. to stream
  250. */
  251. std::ostream& operator<<(std::ostream& os, const Note& note)
  252. {
  253. if (note.isRest()) {
  254. os << "[rest(" << note.getDuration() << ") " << note.getLyric();
  255. } else {
  256. os << "[pitch(" << note.getDuration() << ") " << note.getPitch() << " " << note.getLyric();
  257. }
  258. os << " (tie:";
  259. if (note.isTieStop()) {
  260. os << "Stop";
  261. }
  262. if (note.isTieStart()) {
  263. os << "Start";
  264. }
  265. os << ")";
  266. os << " (slur:";
  267. if (note.isSlurStop()) {
  268. os << "Stop";
  269. }
  270. if (note.isSlurStart()) {
  271. os << "Start";
  272. }
  273. os << ")";
  274. os << "]";
  275. return os;
  276. }
  277. }; // namespace sinsy