Session.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. This file is part of QTau
  3. Copyright (C) 2013-2018 Tobias "Tomoko" Platen <tplaten@posteo.de>
  4. Copyright (C) 2013 digited <https://github.com/digited>
  5. Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>
  6. QTau is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is 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. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. SPDX-License-Identifier: GPL-3.0+
  17. */
  18. #ifndef SESSION_H
  19. #define SESSION_H
  20. #include "Utils.h"
  21. #include "NoteEvents.h"
  22. #include <QJsonArray>
  23. #include "PluginInterfaces.h"
  24. #include "ustjkeys.h"
  25. #include <QMap>
  26. /** Work session that contains one voice setup (notes/lyrics/effects)
  27. and voicebank selection+setup to synthesize one song.
  28. */
  29. class qtauSession : public qtauEventManager
  30. {
  31. Q_OBJECT
  32. public:
  33. explicit qtauSession(QObject *parent = 0);
  34. ~qtauSession();
  35. bool loadUST(QString fileName);
  36. bool loadUST(QJsonArray array);
  37. QString documentName() { return _docName; }
  38. QString documentFile() { return _filePath; }
  39. void setDocName(const QString &name);
  40. void setFilePath(const QString &fp);
  41. QString getFilePath(){return _filePath;}
  42. bool isSessionEmpty() const { return _objectMap.isEmpty(); } /// returns true if doesn't contain any data
  43. bool isSessionModified() const { return _isModified; } /// if has changes from last save/load
  44. void setModified(bool m);
  45. void setSaved(); // if doc was saved at this point
  46. void importMIDI(QString fileName);
  47. void exportMIDI(QString fileName);
  48. void importMusicXML(QString fileName);
  49. void importUST(QString fileName);
  50. void ustJson(QJsonArray& ret);
  51. void setSingerName(QString singerName);
  52. QString getSingerName();
  53. QJsonArray getTempoMap();
  54. void setTempoMap(QJsonArray ts);
  55. quint64 getNote(QJsonObject note);
  56. QString undoAction();
  57. QString redoAction();
  58. signals:
  59. void modifiedStatus(bool); /// if document is modified
  60. void undoStatus (bool); /// if can undo last stored action
  61. void redoStatus (bool); /// if can apply previously reverted action
  62. void dataReloaded(); /// when data is changed completely
  63. void vocalSet(); // when session gets synthesized audio from score
  64. void musicSet(); // when user adds bg (off-vocal?) music to play with synthesized vocals
  65. // signals to controller
  66. void requestSynthesis(); // means synth & play
  67. public slots:
  68. void onUIEvent(qtauEvent *);
  69. void onNewSession();
  70. protected:
  71. bool parseUSTStrings(QStringList ustStrings);
  72. QString _filePath;
  73. QString _docName;
  74. bool _isModified;
  75. bool _hadSavePoint; // if was saved having a non-empty event stack
  76. QMap<qint64, QJsonObject> _objectMap; // need to store copies until changing data structure to something better
  77. QJsonObject _defaults;
  78. void applyEvent_NoteAdded (const qtauEvent_NoteAddition &event);
  79. void applyEvent_NoteMoved (const qtauEvent_NoteMove &event);
  80. void applyEvent_NoteResized(const qtauEvent_NoteResize &event);
  81. void applyEvent_NoteLyrics (const qtauEvent_NoteText &event);
  82. void applyEvent_NoteEffects(const qtauEvent_NoteEffect &event);
  83. bool processEvent(qtauEvent *) override;
  84. void stackChanged() override;
  85. };
  86. #endif // SESSION_H