Audio plugin host https://kx.studio/carla
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.

82 lines
2.1KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. OutMgr.h - Audio Engine Interfacer
  4. Copyright (C) 2016 Mark McCurry
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. */
  10. #ifndef OUTMGR_H
  11. #define OUTMGR_H
  12. #include "../Misc/Stereo.h"
  13. #include "../globals.h"
  14. #include <list>
  15. #include <string>
  16. #include <semaphore.h>
  17. class AudioOut;
  18. struct SYNTH_T;
  19. class OutMgr
  20. {
  21. public:
  22. static OutMgr &getInstance(const SYNTH_T *synth=NULL);
  23. ~OutMgr();
  24. /**Execute a tick*/
  25. const Stereo<float *> tick(unsigned int frameSize) REALTIME;
  26. /**Request a new set of samples
  27. * @param n number of requested samples (defaults to 1)
  28. * @return -1 for locking issues 0 for valid request*/
  29. void requestSamples(unsigned int n = 1);
  30. /**Gets requested driver
  31. * @param name case unsensitive name of driver
  32. * @return pointer to Audio Out or NULL
  33. */
  34. AudioOut *getOut(std::string name);
  35. /**Gets the name of the first running driver
  36. * Deprecated
  37. * @return if no running output, "" is returned
  38. */
  39. std::string getDriver() const;
  40. bool setSink(std::string name);
  41. std::string getSink() const;
  42. class WavEngine * wave; /**<The Wave Recorder*/
  43. friend class EngineMgr;
  44. void setMaster(class Master *master_);
  45. void applyOscEventRt(const char *msg);
  46. private:
  47. OutMgr(const SYNTH_T *synth);
  48. void addSmps(float *l, float *r);
  49. unsigned int storedSmps() const {return priBuffCurrent.l - priBuf.l; }
  50. void removeStaleSmps();
  51. AudioOut *currentOut; /**<The current output driver*/
  52. sem_t requested;
  53. /**Buffer*/
  54. Stereo<float *> priBuf; //buffer for primary drivers
  55. Stereo<float *> priBuffCurrent; //current array accessor
  56. float *outl;
  57. float *outr;
  58. class Master *master;
  59. int stales;
  60. const SYNTH_T &synth;
  61. };
  62. #endif