Session.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. //void setTempo(int tempo);
  54. //int getTempo();
  55. //QJsonArray getTimeSignature();
  56. //void setTimeSignature(QJsonArray ts);
  57. QJsonArray getTempoMap();
  58. void setTempoMap(QJsonArray ts);
  59. quint64 getNote(QJsonObject note);
  60. QString undoAction();
  61. QString redoAction();
  62. signals:
  63. void modifiedStatus(bool); /// if document is modified
  64. void undoStatus (bool); /// if can undo last stored action
  65. void redoStatus (bool); /// if can apply previously reverted action
  66. void dataReloaded(); /// when data is changed completely
  67. void vocalSet(); // when session gets synthesized audio from score
  68. void musicSet(); // when user adds bg (off-vocal?) music to play with synthesized vocals
  69. // signals to controller
  70. void requestSynthesis(); // means synth & play
  71. public slots:
  72. void onUIEvent(qtauEvent *);
  73. void onNewSession();
  74. protected:
  75. bool parseUSTStrings(QStringList ustStrings);
  76. QString _filePath;
  77. QString _docName;
  78. bool _isModified;
  79. bool _hadSavePoint; // if was saved having a non-empty event stack
  80. //bool _needsSynth;
  81. QMap<qint64, QJsonObject> _objectMap; // need to store copies until changing data structure to something better
  82. QJsonObject _defaults;
  83. void applyEvent_NoteAdded (const qtauEvent_NoteAddition &event);
  84. void applyEvent_NoteMoved (const qtauEvent_NoteMove &event);
  85. void applyEvent_NoteResized(const qtauEvent_NoteResize &event);
  86. void applyEvent_NoteLyrics (const qtauEvent_NoteText &event);
  87. void applyEvent_NoteEffects(const qtauEvent_NoteEffect &event);
  88. bool processEvent(qtauEvent *) override;
  89. void stackChanged() override;
  90. //EAudioPlayback playSt;
  91. };
  92. #endif // SESSION_H