epr_synth.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 LESYNTH_H
  19. #define LESYNTH_H
  20. #include "PluginInterfaces.h"
  21. #include <QJsonArray>
  22. #include <QList>
  23. #include <QMap>
  24. //for epr synth
  25. #include <sekai/hzosc.h>
  26. #include <sekai/epr.h>
  27. #include "sekai/common.h"
  28. #define RES_COUNT 5
  29. #include "jack/ringbuffer.h"
  30. #include "sndfile.h"
  31. #include <QThread>
  32. #include <QMap>
  33. #include <QString>
  34. #include <QStringList>
  35. struct formant
  36. {
  37. int f1;
  38. int f2;
  39. };
  40. struct noteEvent
  41. {
  42. float startPos;
  43. float endPos;
  44. formant fo;
  45. float f0;
  46. };
  47. class EpRSynth : public QObject, public ISynth
  48. {
  49. Q_OBJECT
  50. Q_PLUGIN_METADATA(IID c_isynth_comname FILE "epr_synth.json")
  51. Q_INTERFACES(ISynth)
  52. public:
  53. EpRSynth() {}
  54. //plugin loading
  55. QString name() override;
  56. QString description() override;
  57. QString version() override;
  58. void setup(IController *ctrl) override;
  59. //synth base
  60. bool setCacheDir(QString cacheDir) override;
  61. bool synthesize(IScore* score) override;
  62. bool synthIsRealtime() override;
  63. int readData(float *data, int size) override;
  64. //lyricizer
  65. QString getTranscription(QString txt) override;
  66. bool doPhonemeTransformation(QStringList& lyrics) override;
  67. //voice manager
  68. bool setVoice(QString voiceName) override;
  69. QStringList listVoices() override;
  70. private:
  71. void genOneFrame();
  72. private:
  73. QMap<QString,formant> _formantMap;
  74. QList<noteEvent> _notes;
  75. int _pos;
  76. int _currentNote;
  77. bool _stop;
  78. IController* _ctrl;
  79. int _jack_samplerate;
  80. IFFTOsc _osc;
  81. EprResonance _res[RES_COUNT+2];
  82. bool _resEnabled[RES_COUNT+2];
  83. EprSourceParams _src;
  84. signals:
  85. void endOfThread();
  86. void logError(QString error);
  87. void logSuccess(QString success);
  88. void logDebug(QString debug);
  89. public slots:
  90. void on_logError(QString error);
  91. void on_logSuccess(QString success);
  92. void on_logDebug(QString debug);
  93. void on_endOfThread();
  94. };
  95. #define SETSEEK 1
  96. #endif // LESYNTH_H