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.

72 lines
1.5KB

  1. #pragma once
  2. #include <common.hpp>
  3. #include <jansson.h>
  4. #pragma GCC diagnostic push
  5. #ifndef __clang__
  6. #pragma GCC diagnostic ignored "-Wsuggest-override"
  7. #endif
  8. #include <RtAudio.h>
  9. #pragma GCC diagnostic pop
  10. namespace rack {
  11. /** Audio driver
  12. */
  13. namespace audio {
  14. struct Port {
  15. // Stream properties
  16. int driverId = 0;
  17. int deviceId = -1;
  18. int offset = 0;
  19. int maxChannels = 8;
  20. int sampleRate = 44100;
  21. int blockSize = 256;
  22. int numOutputs = 0;
  23. int numInputs = 0;
  24. RtAudio* rtAudio = NULL;
  25. /** Cached */
  26. RtAudio::DeviceInfo deviceInfo;
  27. Port();
  28. virtual ~Port();
  29. std::vector<int> getDriverIds();
  30. std::string getDriverName(int driverId);
  31. void setDriverId(int driverId);
  32. int getDeviceCount();
  33. bool getDeviceInfo(int deviceId, RtAudio::DeviceInfo* deviceInfo);
  34. /** Returns the number of inputs or outputs, whichever is greater */
  35. int getDeviceChannels(int deviceId);
  36. std::string getDeviceName(int deviceId);
  37. std::string getDeviceDetail(int deviceId, int offset);
  38. void setDeviceId(int deviceId, int offset);
  39. std::vector<int> getSampleRates();
  40. void setSampleRate(int sampleRate);
  41. std::vector<int> getBlockSizes();
  42. void setBlockSize(int blockSize);
  43. void setChannels(int numOutputs, int numInputs);
  44. /** Must close the stream before opening */
  45. void openStream();
  46. void closeStream();
  47. virtual void processStream(const float* input, float* output, int frames) {}
  48. virtual void onCloseStream() {}
  49. virtual void onOpenStream() {}
  50. virtual void onChannelsChange() {}
  51. json_t* toJson();
  52. void fromJson(json_t* rootJ);
  53. };
  54. } // namespace audio
  55. } // namespace rack