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.

68 lines
1.5KB

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