Well, even if I push the fader up real slow.. say 6 seconds from bottom to top, the same problem occurs.
That would mean around 16 messages per second.The code in the MIDI thread is actually still a bit of a mystery to me.. as its taken from some other o/s projects
void midiThread::run()
{
snd_seq_t *seq_handle;
int npfd;
struct pollfd *pfd;
seq_handle = open_seq();
npfd = snd_seq_poll_descriptors_count(seq_handle, POLLIN);
pfd = (struct pollfd *)alloca(npfd * sizeof(struct pollfd));
snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
while (1) {
if (poll(pfd, npfd, 100000) > 0) {
midi_action(seq_handle);
}
}
}
void midiThread::run()
{
snd_seq_t *seq_handle;
int npfd;
struct pollfd *pfd;
seq_handle = open_seq();
npfd = snd_seq_poll_descriptors_count(seq_handle, POLLIN);
pfd = (struct pollfd *)alloca(npfd * sizeof(struct pollfd));
snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
while (1) {
if (poll(pfd, npfd, 100000) > 0) {
midi_action(seq_handle);
}
}
}
To copy to clipboard, switch view to plain text mode
This is the run part of the QThread. The other relevant bit is:
void midiThread::midi_action(snd_seq_t *seq_handle) {
snd_seq_event_t *ev;
MyDataEvent dataEvent(0,0);
do {
snd_seq_event_input(seq_handle, &ev);
switch (ev->type) {
case SND_SEQ_EVENT_CONTROLLER:
dataEvent.setParam(ev->data.control.param);
dataEvent.setValue(ev->data.control.value);
break;
}
snd_seq_free_event(ev);
} while (snd_seq_event_input_pending(seq_handle, 0) > 0);
}
void midiThread::midi_action(snd_seq_t *seq_handle) {
snd_seq_event_t *ev;
MyDataEvent dataEvent(0,0);
do {
snd_seq_event_input(seq_handle, &ev);
switch (ev->type) {
case SND_SEQ_EVENT_CONTROLLER:
dataEvent.setParam(ev->data.control.param);
dataEvent.setValue(ev->data.control.value);
QApplication::sendEvent( parent, &dataEvent );
break;
}
snd_seq_free_event(ev);
} while (snd_seq_event_input_pending(seq_handle, 0) > 0);
}
To copy to clipboard, switch view to plain text mode
If this is a horrible way to do things.. I would much appreciate any ideas on how to handle MIDI better.
On windows I used Borland C++ Builder.. and found a great component that pretty much did it all for me, passing the messages to my callback function. I guess I have to learn more C++ to program on Linux ;-)
Bookmarks