UTAUSynth.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef UTAUSYNTH_H
  2. #define UTAUSYNTH_H
  3. #include <string.h>
  4. #include <fstream>
  5. #include <iostream>
  6. #include <sstream>
  7. #include <sekai/EventList.h>
  8. #include <sekai/PitchModel.h>
  9. #include <sekai/VoiceSampler.h>
  10. #include <sinsy/sinsy.h>
  11. #if 0
  12. import numpy as np
  13. f0_low_limit = 71.0
  14. fs = 44100
  15. fft_size = int(2 ** np.ceil(np.log2(3 * fs / f0_low_limit + 1)))
  16. #endif
  17. #define IMPULSE_RESPONSE_MAX 2048
  18. class UTAUSynth : /*public sinsy::ISynthOutput,*/ public VoiceSampler {
  19. int _samplerate = 0;
  20. std::map<std::string, VoiceDef *> _voicemap;
  21. std::string _utauPath;
  22. EventList<PhoEvent> _phoEvents;
  23. float *_impulseResponse;
  24. int _mbrPeriod = 0; // FIXME
  25. PitchModel *_pitch = nullptr;
  26. // new synth backend
  27. std::string _synthext;
  28. int _fft_size;
  29. float _frame_period;
  30. void getImpulseResponse(float currentTime, PhoEvent *event,
  31. float *impulseResponse, int *impulseResponseLength,
  32. float morph);
  33. protected:
  34. virtual void addUnit(const std::string &lyric, int, float *, float *);
  35. virtual void addPitchPointsForNote(float notepos, float length, float f0);
  36. virtual void addPitchPointsForRest(float notepos, float length);
  37. virtual bool addOnePulse();
  38. virtual float getLengthForUnit(const std::string &fileName);
  39. public:
  40. UTAUSynth(std::string utauPath, PitchModel *pitch,
  41. int buffer_size = IMPULSE_RESPONSE_MAX * 4);
  42. void load(std::string fileName);
  43. void synthesize(std::string fileName);
  44. // void load(VoiceRecord *rec, std::string fileName);
  45. int samplerate() { return _samplerate; }
  46. void fix();
  47. virtual std::string getPhoLine(const std::string &fileName,int index){return "";}
  48. };
  49. #endif