ecantorix_synth.h 3.3 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 ECANTORIX_SYNTH_H
  19. #define ECANTORIX_SYNTH_H
  20. #include "PluginInterfaces.h"
  21. #include <QJsonArray>
  22. #include <QList>
  23. #include <QMap>
  24. #include "sekai/VVDReader.h"
  25. #include "jack/ringbuffer.h"
  26. #include <sinsy/ringbuffer.h>
  27. #include "wavtool.h"
  28. #define VOWEL 0
  29. #define VCONSONANT 1
  30. #define HCONSONANT 2
  31. #define NASAL 3
  32. #define LIQUID 4
  33. struct phoType
  34. {
  35. int defaultLength;
  36. int voxtype;
  37. };
  38. struct phoEvent
  39. {
  40. phoType type;
  41. QString symbol;
  42. };
  43. struct eCantorixNote
  44. {
  45. float vstart;
  46. float rlength;
  47. float f0;
  48. float preutter;
  49. QList<phoEvent> eventList;
  50. QString mbrolaPho;
  51. };
  52. class eCantorixSynth : public QObject, public ISynth
  53. {
  54. Q_OBJECT
  55. Q_PLUGIN_METADATA(IID c_isynth_comname FILE "ecantorix_synth.json")
  56. Q_INTERFACES(ISynth)
  57. int _jack_samplerate=0;
  58. QString _cacheDir;
  59. QString _voiceName;
  60. QMap<QString,QString> _voices;
  61. QString _internalVoice;
  62. QJsonArray _score;
  63. IController* _ctrl=nullptr;
  64. RingBuffer* _rb=nullptr;
  65. QMap<QString,phoType> _phoTypes;
  66. QList<phoEvent> _eventList;
  67. QList<eCantorixNote> _notes;
  68. WavTool _wavtool;
  69. public:
  70. eCantorixSynth() {}
  71. //plugin loading
  72. QString name() override;
  73. QString description() override;
  74. QString version() override;
  75. void setup(IController *ctrl) override;
  76. //synth base
  77. bool setCacheDir(QString cacheDir) override;
  78. bool synthesize(IScore* score) override;
  79. bool synthIsRealtime() override;
  80. int readData(float *data, int size) override;
  81. //lyricizer
  82. QString getTranscription(QString txt) override;
  83. bool doPhonemeTransformation(QStringList& lyrics) override;
  84. //voice manager
  85. bool setVoice(QString voiceName) override;
  86. QStringList listVoices() override;
  87. private:
  88. void lyricize(QString lyric);
  89. void lookupPho(QString pho);
  90. float getPreutter();
  91. signals:
  92. void signalStatus(int status);
  93. void logError(QString error);
  94. void logSuccess(QString success);
  95. void logDebug(QString debug);
  96. public slots:
  97. // void synthprocess_finished(int exitCode, QProcess::ExitStatus exitStatus);
  98. void on_logError(QString error);
  99. void on_logSuccess(QString success);
  100. void on_logDebug(QString debug);
  101. };
  102. #define SETSEEK 1
  103. #endif // LESYNTH_H