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.

64 lines
1.4KB

  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. // Stream properties
  10. int driver = 0;
  11. int device = -1;
  12. int offset = 0;
  13. int maxChannels = 8;
  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. bool getDeviceInfo(int device, RtAudio::DeviceInfo *deviceInfo);
  28. /** Returns the number of inputs or outputs, whichever is greater */
  29. int getDeviceChannels(int device);
  30. std::string getDeviceName(int device);
  31. std::string getDeviceDetail(int device, int offset);
  32. void setDevice(int device, int offset);
  33. std::vector<int> getSampleRates();
  34. void setSampleRate(int sampleRate);
  35. std::vector<int> getBlockSizes();
  36. void setBlockSize(int blockSize);
  37. void setChannels(int numOutputs, int numInputs);
  38. /** Must close the stream before opening */
  39. void openStream();
  40. void closeStream();
  41. virtual void processStream(const float *input, float *output, int frames) {}
  42. virtual void onCloseStream() {}
  43. virtual void onOpenStream() {}
  44. virtual void onChannelsChange() {}
  45. json_t *toJson();
  46. void fromJson(json_t *rootJ);
  47. };
  48. } // namespace rack