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.

OssEngine.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #ifndef OSS_ENGINE_H
  18. #define OSS_ENGINE_H
  19. #include <sys/time.h>
  20. #include "../globals.h"
  21. #include "AudioOut.h"
  22. #include "MidiIn.h"
  23. struct OssMidiParse {
  24. unsigned char *temp_cmd;
  25. unsigned char temp_0[4];
  26. unsigned char temp_1[4];
  27. unsigned char state;
  28. #define OSSMIDI_ST_UNKNOWN 0 /* scan for command */
  29. #define OSSMIDI_ST_1PARAM 1
  30. #define OSSMIDI_ST_2PARAM_1 2
  31. #define OSSMIDI_ST_2PARAM_2 3
  32. #define OSSMIDI_ST_SYSEX_0 4
  33. #define OSSMIDI_ST_SYSEX_1 5
  34. #define OSSMIDI_ST_SYSEX_2 6
  35. };
  36. class OssEngine:public AudioOut, MidiIn
  37. {
  38. public:
  39. OssEngine(const SYNTH_T &synth, const class oss_devs_t& oss_devs);
  40. ~OssEngine();
  41. bool Start();
  42. void Stop();
  43. void setAudioEn(bool nval);
  44. bool getAudioEn() const;
  45. void setMidiEn(bool nval);
  46. bool getMidiEn() const;
  47. protected:
  48. void *audioThreadCb();
  49. static void *_audioThreadCb(void *arg);
  50. void *midiThreadCb();
  51. static void *_midiThreadCb(void *arg);
  52. private:
  53. pthread_t *audioThread;
  54. pthread_t *midiThread;
  55. //Audio
  56. bool openAudio();
  57. void stopAudio();
  58. struct audio {
  59. int handle;
  60. int buffersize;
  61. union {
  62. /* Samples to be sent to soundcard */
  63. short int *ps16;
  64. int *ps32;
  65. } smps;
  66. bool en;
  67. bool is32bit;
  68. } audio;
  69. const char* linux_oss_wave_out_dev;
  70. //Midi
  71. bool openMidi();
  72. void stopMidi();
  73. struct midi {
  74. struct OssMidiParse state;
  75. int handle;
  76. bool en;
  77. bool run;
  78. } midi;
  79. const char* linux_oss_seq_in_dev;
  80. };
  81. #endif