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 "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. namespace audio {
  12. struct IO {
  13. // Stream properties
  14. int driver = 0;
  15. int device = -1;
  16. int offset = 0;
  17. int maxChannels = 8;
  18. int sampleRate = 44100;
  19. int blockSize = 256;
  20. int numOutputs = 0;
  21. int numInputs = 0;
  22. RtAudio *rtAudio = NULL;
  23. /** Cached */
  24. RtAudio::DeviceInfo deviceInfo;
  25. IO();
  26. virtual ~IO();
  27. std::vector<int> getDrivers();
  28. std::string getDriverName(int driver);
  29. void setDriver(int driver);
  30. int getDeviceCount();
  31. bool getDeviceInfo(int device, RtAudio::DeviceInfo *deviceInfo);
  32. /** Returns the number of inputs or outputs, whichever is greater */
  33. int getDeviceChannels(int device);
  34. std::string getDeviceName(int device);
  35. std::string getDeviceDetail(int device, int offset);
  36. void setDevice(int device, int offset);
  37. std::vector<int> getSampleRates();
  38. void setSampleRate(int sampleRate);
  39. std::vector<int> getBlockSizes();
  40. void setBlockSize(int blockSize);
  41. void setChannels(int numOutputs, int numInputs);
  42. /** Must close the stream before opening */
  43. void openStream();
  44. void closeStream();
  45. virtual void processStream(const float *input, float *output, int frames) {}
  46. virtual void onCloseStream() {}
  47. virtual void onOpenStream() {}
  48. virtual void onChannelsChange() {}
  49. json_t *toJson();
  50. void fromJson(json_t *rootJ);
  51. };
  52. } // namespace audio
  53. } // namespace rack