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.

OutMgr.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. namespace zyncarla {
  18. class AudioOut;
  19. struct SYNTH_T;
  20. class OutMgr
  21. {
  22. public:
  23. static OutMgr &getInstance(const SYNTH_T *synth=NULL);
  24. ~OutMgr();
  25. /**Execute a tick*/
  26. const Stereo<float *> tick(unsigned int frameSize) REALTIME;
  27. /**Request a new set of samples
  28. * @param n number of requested samples (defaults to 1)
  29. * @return -1 for locking issues 0 for valid request*/
  30. void requestSamples(unsigned int n = 1);
  31. /**Gets requested driver
  32. * @param name case unsensitive name of driver
  33. * @return pointer to Audio Out or NULL
  34. */
  35. AudioOut *getOut(std::string name);
  36. /**Gets the name of the first running driver
  37. * Deprecated
  38. * @return if no running output, "" is returned
  39. */
  40. std::string getDriver() const;
  41. bool setSink(std::string name);
  42. std::string getSink() const;
  43. class WavEngine * wave; /**<The Wave Recorder*/
  44. friend class EngineMgr;
  45. void setMaster(class Master *master_);
  46. void applyOscEventRt(const char *msg);
  47. private:
  48. OutMgr(const SYNTH_T *synth);
  49. void addSmps(float *l, float *r);
  50. unsigned int storedSmps() const {return priBuffCurrent.l - priBuf.l; }
  51. void removeStaleSmps();
  52. AudioOut *currentOut; /**<The current output driver*/
  53. sem_t requested;
  54. /**Buffer*/
  55. Stereo<float *> priBuf; //buffer for primary drivers
  56. Stereo<float *> priBuffCurrent; //current array accessor
  57. float *outl;
  58. float *outr;
  59. class Master *master;
  60. int stales;
  61. const SYNTH_T &synth;
  62. };
  63. }
  64. #endif