ustfile.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "ustfile.h"
  2. #include "Utils.h"
  3. #include "ustjkeys.h"
  4. #define __devloglevel__ 4
  5. USTFile::USTFile()
  6. {
  7. }
  8. void USTFile::handleKey(QString key, QString value)
  9. {
  10. (void) key;
  11. (void) value;
  12. //if(_isNote) DEVLOG_DEBUG("ustkey:"+key+" value:"+value);
  13. if(_isSetting)
  14. {
  15. if(key=="Tempo") _tempo = QVariant(value).toFloat();
  16. }
  17. // Tempo : default value = 120,00
  18. if(_isNote)
  19. {
  20. if(key=="Length"){
  21. int duration = QVariant(value).toInt();
  22. _note[NOTE_PULSE_LENGTH] = duration;
  23. _note[NOTE_PULSE_OFFSET] = _posPulses;
  24. _posPulses += duration;
  25. }
  26. else if(key=="Lyric") _note[NOTE_LYRIC]=value;
  27. else if(key=="NoteNum") _note[NOTE_KEY_NUMBER]=QVariant(value).toInt();
  28. else if(key=="Intensity") _note[NOTE_INTENSITY]=QVariant(value).toInt();
  29. else if(key=="Modulation") _note[NOTE_MODULATION]=QVariant(value).toInt();
  30. else _note["UST:"+key]=value;
  31. }
  32. // notes:
  33. // Length value:480
  34. // Lyric value:do
  35. // NoteNum value:60
  36. // Intensity value:100
  37. // Modulation value:0
  38. }
  39. void USTFile::genSetup(){
  40. QJsonObject setup;
  41. setup[TEMPO] = _tempo;
  42. _ust.push_back(setup);
  43. }
  44. void USTFile::handleSection(QString section)
  45. {
  46. if(_isSetting)
  47. {
  48. DEVLOG_DEBUG("genSetup");
  49. genSetup();
  50. }
  51. if(_isNote)
  52. {
  53. _ust.push_back(_note);
  54. }
  55. if(section=="#SETTING"){
  56. _noteCounter = -1;
  57. _isSetting = true;
  58. }
  59. QString number = QString("#%1").arg(_noteCounter, 4, 10, QChar('0'));
  60. _isNote = (number==section);
  61. _noteCounter++;
  62. if(_isNote) _isSetting = false;
  63. }
  64. bool USTFile::writeOutputToStream()
  65. {
  66. return false;
  67. }
  68. #if 0
  69. QString USTFile::codec() {
  70. return "SJIS";
  71. }
  72. #endif