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.

engine.hpp 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <vector>
  3. #include "util.hpp"
  4. namespace rack {
  5. struct Module {
  6. std::vector<float> params;
  7. /** Pointers to voltage values at each port
  8. If value is NULL, the input/output is disconnected
  9. */
  10. std::vector<float*> inputs;
  11. std::vector<float*> outputs;
  12. /** For CPU usage */
  13. float cpuTime = 0.0;
  14. virtual ~Module() {}
  15. /** Advances the module by 1 audio frame with duration 1.0 / gSampleRate */
  16. virtual void step() {}
  17. };
  18. struct Wire {
  19. Module *outputModule = NULL;
  20. int outputId;
  21. Module *inputModule = NULL;
  22. int inputId;
  23. /** The voltage connected to input ports */
  24. float inputValue = 0.0;
  25. /** The voltage connected to output ports */
  26. float outputValue = 0.0;
  27. };
  28. void engineInit();
  29. void engineDestroy();
  30. /** Launches engine thread */
  31. void engineStart();
  32. void engineStop();
  33. /** Does not transfer pointer ownership */
  34. void engineAddModule(Module *module);
  35. void engineRemoveModule(Module *module);
  36. /** Does not transfer pointer ownership */
  37. void engineAddWire(Wire *wire);
  38. void engineRemoveWire(Wire *wire);
  39. void engineSetParamSmooth(Module *module, int paramId, float value);
  40. extern float gSampleRate;
  41. } // namespace rack