00001 /******************************************************************************* 00002 * JackPort.h (JackFX) 00003 ******************************************************************************/ 00004 00005 #ifndef _JACK_PORT_H_ 00006 #define _JACK_PORT_H_ 00007 00008 #include "common.h" 00009 #include "ISoundElement.h" 00010 00011 class JackClient; 00012 class JackPort 00013 { 00014 public: 00017 JackPort(const string& name, bool writer, const char* type); 00018 00021 ~JackPort(); 00022 00023 bool ConnectTo(const string& destport); 00024 void DisconnectFrom(const string& destport); 00025 00026 protected: 00027 jack_port_t* GetPort() const { return m_port; } 00028 00029 private: 00030 jack_port_t* m_port; 00031 bool m_writer; 00032 }; 00033 00034 class JackMidiPort : public JackPort 00035 { 00036 friend class JackClient; 00037 public: 00038 JackMidiPort(const string& name, bool writer = false); 00039 00040 ~JackMidiPort(); 00041 00042 queue<jack_midi_event_t>& GetEventQueue(); 00043 00044 python::object GetPyEventQueue(); 00045 00046 private: 00047 void Read(jack_nframes_t count); 00048 queue<jack_midi_event_t> m_eventqueue; 00049 pthread_mutex_t m_mtx; 00050 }; 00051 00052 class JackAudioPort : public JackPort 00053 { 00054 public: 00055 JackAudioPort(const string& name, bool writer) : 00056 JackPort(name, writer, JACK_DEFAULT_AUDIO_TYPE) 00057 {} 00058 00059 virtual ~JackAudioPort() {} 00060 00061 protected: 00062 void GetFrame(SoundFrame& frame, jack_nframes_t nframes); 00063 void PutFrame(const SoundFrame& frame); 00064 }; 00065 00066 class JackInput : public ISoundSource, public JackAudioPort 00067 { 00068 public: 00071 JackInput(const string& name); 00072 00075 ~JackInput(); 00076 00077 protected: 00078 void Process(jack_nframes_t samples); 00079 00080 private: 00081 }; 00082 00083 class JackOutput : public ISoundElement, public JackAudioPort 00084 { 00085 public: 00088 JackOutput(const string& name); 00089 00092 ~JackOutput(); 00093 00094 protected: 00095 void Process(jack_nframes_t samples); 00096 00097 private: 00098 }; 00099 00100 #endif