You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0KB

  1. #pragma once
  2. #include "common.hpp"
  3. #include "engine/Module.hpp"
  4. #include "engine/Cable.hpp"
  5. #include "engine/ParamHandle.hpp"
  6. #include <vector>
  7. namespace rack {
  8. namespace engine {
  9. struct Engine {
  10. struct Internal;
  11. Internal *internal;
  12. Engine();
  13. ~Engine();
  14. /** Starts engine thread. */
  15. void start();
  16. /** Stops engine thread. */
  17. void stop();
  18. void setPaused(bool paused);
  19. bool isPaused();
  20. float getSampleRate();
  21. /** Returns the inverse of the current sample rate. */
  22. float getSampleTime();
  23. // Modules
  24. /** Adds a module to the rack engine.
  25. The module ID must not be taken by another module.
  26. If the module ID is -1, an ID is automatically assigned.
  27. Does not transfer pointer ownership.
  28. */
  29. void addModule(Module *module);
  30. void removeModule(Module *module);
  31. Module *getModule(int moduleId);
  32. void resetModule(Module *module);
  33. void randomizeModule(Module *module);
  34. void bypassModule(Module *module, bool bypass);
  35. // Cables
  36. /** Adds a cable to the rack engine.
  37. The cable ID must not be taken by another cable.
  38. If the cable ID is -1, an ID is automatically assigned.
  39. Does not transfer pointer ownership.
  40. */
  41. void addCable(Cable *cable);
  42. void removeCable(Cable *cable);
  43. // Params
  44. void setParam(Module *module, int paramId, float value);
  45. float getParam(Module *module, int paramId);
  46. void setSmoothParam(Module *module, int paramId, float value);
  47. float getSmoothParam(Module *module, int paramId);
  48. void addParamHandle(ParamHandle *paramHandle);
  49. void removeParamHandle(ParamHandle *paramHandle);
  50. /** Returns the unique ParamHandle for the given paramId */
  51. ParamHandle *getParamHandle(Module *module, int paramId);
  52. /** Sets the ParamHandle IDs and module pointer.
  53. If the given ParamHandle is added to the engine and another ParamHandle points to the same param, unsets that one and replaces it with the given handle.
  54. */
  55. void updateParamHandle(ParamHandle *paramHandle, int moduleId, int paramId, bool overwrite = true);
  56. };
  57. } // namespace engine
  58. } // namespace rack