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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. namespace zyncarla {
  18. struct OssMidiParse {
  19. unsigned char *temp_cmd;
  20. unsigned char temp_0[4];
  21. unsigned char temp_1[4];
  22. unsigned char state;
  23. #define OSSMIDI_ST_UNKNOWN 0 /* scan for command */
  24. #define OSSMIDI_ST_1PARAM 1
  25. #define OSSMIDI_ST_2PARAM_1 2
  26. #define OSSMIDI_ST_2PARAM_2 3
  27. #define OSSMIDI_ST_SYSEX_0 4
  28. #define OSSMIDI_ST_SYSEX_1 5
  29. #define OSSMIDI_ST_SYSEX_2 6
  30. };
  31. class OssEngine:public AudioOut, MidiIn
  32. {
  33. public:
  34. OssEngine(const SYNTH_T &synth, const class oss_devs_t& oss_devs);
  35. ~OssEngine();
  36. bool Start();
  37. void Stop();
  38. void setAudioEn(bool nval);
  39. bool getAudioEn() const;
  40. void setMidiEn(bool nval);
  41. bool getMidiEn() const;
  42. protected:
  43. void *audioThreadCb();
  44. static void *_audioThreadCb(void *arg);
  45. void *midiThreadCb();
  46. static void *_midiThreadCb(void *arg);
  47. private:
  48. pthread_t *audioThread;
  49. pthread_t *midiThread;
  50. //Audio
  51. bool openAudio();
  52. void stopAudio();
  53. struct audio {
  54. int handle;
  55. int buffersize;
  56. union {
  57. /* Samples to be sent to soundcard */
  58. short int *ps16;
  59. int *ps32;
  60. } smps;
  61. /* peak values used for compressor */
  62. float peaks[1];
  63. bool en;
  64. bool is32bit;
  65. } audio;
  66. const char* linux_oss_wave_out_dev;
  67. //Midi
  68. bool openMidi();
  69. void stopMidi();
  70. struct midi {
  71. struct OssMidiParse state;
  72. int handle;
  73. bool en;
  74. bool run;
  75. } midi;
  76. const char* linux_oss_seq_in_dev;
  77. };
  78. }
  79. #endif