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.

99 lines
2.3KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. OSSaudiooutput.h - Audio output for Open Sound System
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef OSS_ENGINE_H
  12. #define OSS_ENGINE_H
  13. #include <sys/time.h>
  14. #include "../globals.h"
  15. #include "AudioOut.h"
  16. #include "MidiIn.h"
  17. struct OssMidiParse {
  18. unsigned char *temp_cmd;
  19. unsigned char temp_0[4];
  20. unsigned char temp_1[4];
  21. unsigned char state;
  22. #define OSSMIDI_ST_UNKNOWN 0 /* scan for command */
  23. #define OSSMIDI_ST_1PARAM 1
  24. #define OSSMIDI_ST_2PARAM_1 2
  25. #define OSSMIDI_ST_2PARAM_2 3
  26. #define OSSMIDI_ST_SYSEX_0 4
  27. #define OSSMIDI_ST_SYSEX_1 5
  28. #define OSSMIDI_ST_SYSEX_2 6
  29. };
  30. class OssEngine:public AudioOut, MidiIn
  31. {
  32. public:
  33. OssEngine(const SYNTH_T &synth, const class oss_devs_t& oss_devs);
  34. ~OssEngine();
  35. bool Start();
  36. void Stop();
  37. void setAudioEn(bool nval);
  38. bool getAudioEn() const;
  39. void setMidiEn(bool nval);
  40. bool getMidiEn() const;
  41. protected:
  42. void *audioThreadCb();
  43. static void *_audioThreadCb(void *arg);
  44. void *midiThreadCb();
  45. static void *_midiThreadCb(void *arg);
  46. private:
  47. pthread_t *audioThread;
  48. pthread_t *midiThread;
  49. //Audio
  50. bool openAudio();
  51. void stopAudio();
  52. struct audio {
  53. int handle;
  54. int buffersize;
  55. union {
  56. /* Samples to be sent to soundcard */
  57. short int *ps16;
  58. int *ps32;
  59. } smps;
  60. /* peak values used for compressor */
  61. float peaks[1];
  62. bool en;
  63. bool is32bit;
  64. } audio;
  65. const char* linux_oss_wave_out_dev;
  66. //Midi
  67. bool openMidi();
  68. void stopMidi();
  69. struct midi {
  70. struct OssMidiParse state;
  71. int handle;
  72. bool en;
  73. bool run;
  74. } midi;
  75. const char* linux_oss_seq_in_dev;
  76. };
  77. #endif