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.

52 lines
1.1KB

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