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.

audio.hpp 1.5KB

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