ControlTrack.h 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef SINSY_CONTROL_TRACK_H_
  2. #define SINSY_CONTROL_TRACK_H_
  3. #include <gsl/gsl_errno.h>
  4. #include <gsl/gsl_spline.h>
  5. #include <vector>
  6. struct GSLInterp
  7. {
  8. float startPos;
  9. float endPos;
  10. gsl_interp_accel *acc;
  11. gsl_spline *cspline;
  12. };
  13. struct DynSegment
  14. {
  15. float start;
  16. float end;
  17. float dyn0;
  18. float dyn1;
  19. };
  20. class ControlTrack {
  21. public:
  22. //F0 control -- a spline is used here
  23. void addNote(float start, float length, float f0);
  24. void addPoint(float pos,float f0);
  25. void fix();
  26. float getF0atTime(float time);
  27. float getLength();
  28. void append(float delta);
  29. // dynamics -- linear interpolation is used here
  30. inline void addDynamicsSegment(const DynSegment& d) { dyn.push_back(d); }
  31. float getDynamicsAtTime(float time);
  32. private:
  33. std::vector<double> time;
  34. std::vector<double> pitch;
  35. GSLInterp interp;
  36. float lastpos=0;
  37. std::vector<DynSegment> dyn;
  38. };
  39. #endif