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.

55 lines
1.1KB

  1. #pragma once
  2. #include <jansson.h>
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wsuggest-override"
  5. #include <RtAudio.h>
  6. #pragma GCC diagnostic pop
  7. namespace rack {
  8. struct AudioIO {
  9. int maxOutputs = 8;
  10. int maxInputs = 8;
  11. // Stream properties
  12. int driver = 0;
  13. int device = -1;
  14. int sampleRate = 44100;
  15. int blockSize = 256;
  16. int numOutputs = 0;
  17. int numInputs = 0;
  18. RtAudio *rtAudio = NULL;
  19. /** Cached */
  20. RtAudio::DeviceInfo deviceInfo;
  21. AudioIO();
  22. virtual ~AudioIO();
  23. std::vector<int> getDrivers();
  24. std::string getDriverName(int driver);
  25. void setDriver(int driver);
  26. int getDeviceCount();
  27. std::string getDeviceName(int device);
  28. std::string getDeviceDetail(int device);
  29. void openStream();
  30. void closeStream();
  31. /** Returns whether the audio stream is open and running */
  32. bool isActive();
  33. std::vector<int> getSampleRates();
  34. virtual void processStream(const float *input, float *output, int length) {}
  35. virtual void onCloseStream() {}
  36. virtual void onOpenStream() {}
  37. json_t *toJson();
  38. void fromJson(json_t *rootJ);
  39. };
  40. } // namespace rack