#include <JackPort.h>
Public Member Functions | |
queue< jack_midi_event_t > & | GetEventQueue () |
python::object | GetPyEventQueue () |
JackMidiPort (const string &name, bool writer=false) | |
~JackMidiPort () | |
Private Member Functions | |
void | Read (jack_nframes_t count) |
Private Attributes | |
queue< jack_midi_event_t > | m_eventqueue |
pthread_mutex_t | m_mtx |
Friends | |
class | JackClient |
Definition at line 34 of file JackPort.h.
JackMidiPort::JackMidiPort | ( | const string & | name, | |
bool | writer = false | |||
) |
Definition at line 50 of file JackPort.cpp.
References JackClient::GetSingleton(), JackClient::m_midiports, and m_mtx.
00050 : 00051 JackPort(name, writer, JACK_DEFAULT_MIDI_TYPE) 00052 { 00053 pthread_mutex_init(&m_mtx, NULL); 00054 JackClient::GetSingleton()->m_midiports.push_back(this); 00055 }
JackMidiPort::~JackMidiPort | ( | ) |
Definition at line 57 of file JackPort.cpp.
References JackClient::GetSingleton(), JackClient::m_midiports, and m_mtx.
00058 { 00059 pthread_mutex_destroy(&m_mtx); 00060 if (JackClient::GetSingleton()) { 00061 JackClient::GetSingleton()->m_midiports.remove(this); 00062 } 00063 }
queue< jack_midi_event_t > & JackMidiPort::GetEventQueue | ( | ) |
Definition at line 65 of file JackPort.cpp.
References m_eventqueue.
00066 { 00067 return m_eventqueue; 00068 }
python::object JackMidiPort::GetPyEventQueue | ( | ) |
Definition at line 70 of file JackPort.cpp.
References m_eventqueue, and m_mtx.
Referenced by BOOST_PYTHON_MODULE().
00071 { 00072 pthread_mutex_lock(&m_mtx); 00073 python::list ret; 00074 while (m_eventqueue.size()) { 00075 jack_midi_event_t& evt = m_eventqueue.front(); 00076 00077 //I don't know a better way of doing this. 00078 //using namespace boost::python; 00079 switch(evt.size) { 00080 case 1: 00081 ret.append(python::make_tuple(evt.buffer[0])); 00082 break; 00083 case 2: 00084 ret.append(python::make_tuple(evt.buffer[0], evt.buffer[1])); 00085 break; 00086 case 3: 00087 ret.append(python::make_tuple(evt.buffer[0], evt.buffer[1], evt.buffer[2])); 00088 break; 00089 case 4: 00090 ret.append(python::make_tuple(evt.buffer[0], evt.buffer[1], evt.buffer[2], evt.buffer[3])); 00091 break; 00092 default: 00093 ret.append(python::make_tuple(evt.buffer[0], evt.buffer[1], evt.buffer[2], evt.buffer[3], evt.buffer[4])); 00094 break; 00095 } 00096 00097 m_eventqueue.pop(); 00098 } 00099 pthread_mutex_unlock(&m_mtx); 00100 00101 return ret; 00102 }
void JackMidiPort::Read | ( | jack_nframes_t | count | ) | [private] |
Definition at line 104 of file JackPort.cpp.
References JackPort::GetPort(), m_eventqueue, and m_mtx.
00105 { 00106 pthread_mutex_lock(&m_mtx); 00107 void* port_buf = jack_port_get_buffer(GetPort(), nframes); 00108 00109 jack_nframes_t eventcount = jack_midi_get_event_count(port_buf); 00110 for (int i = 0; i < eventcount; ++i) { 00111 jack_midi_event_t in_evt; 00112 jack_midi_event_get(&in_evt, port_buf, i); 00113 m_eventqueue.push(in_evt); 00114 /*cout << "Event " << i << " time is " << in_evt.time << ". 1st byte is " << (int)*(in_evt.buffer) << endl; 00115 for (unsigned int x = 0; x < in_evt.size; ++x) { 00116 cout << "\tByte " << x << " is " << (int)(in_evt.buffer[x]) << endl; 00117 }*/ 00118 } 00119 pthread_mutex_unlock(&m_mtx); 00120 }
friend class JackClient [friend] |
Definition at line 36 of file JackPort.h.
queue<jack_midi_event_t> JackMidiPort::m_eventqueue [private] |
Definition at line 48 of file JackPort.h.
Referenced by GetEventQueue(), GetPyEventQueue(), and Read().
pthread_mutex_t JackMidiPort::m_mtx [private] |
Definition at line 49 of file JackPort.h.
Referenced by GetPyEventQueue(), JackMidiPort(), Read(), and ~JackMidiPort().