JACK midi 事件在 64 位机器上丢失
我有一个在 Linux 下使用 JACK MIDI 的应用程序。它在 32 位机器上完美运行,但在我的新机器(64 位机器)上,我总是遇到事件丢失的情况。
我检查过:
- 来自
jack_ringbuffer_read
的值,它们正常(有效的 2-3 字节 MIDI 消息); midi_out_port
和client
,它们正常(非空)并且出现在我的 JACK 端口列表中;
这是代码的一部分:
#define MidiMessageSize 3
jack_client_t* client;
jack_port_t* midi_out_port;
char current_message[MidiMessageSize];
jack_ringbuffer_t* midi_rb;
int process (jack_nframes_t nframes, void *arg)
{
void* output_buffer = jack_port_get_buffer(midi_out_port, nframes);
jack_midi_clear_buffer(output_buffer);
int read_space = jack_ringbuffer_read_space(midi_rb);
if (read_space == 0) return 0;
int i;
for (i = 0; i < read_space; i += MidiMessageSize)
{
jack_ringbuffer_read(midi_rb, current_message, MidiMessageSize);
jack_midi_event_write(output_buffer, i/MidiMessageSize,
(jack_midi_data_t*)current_message, MidiMessageSize);
if (jack_midi_get_lost_event_count(midi_out_port)) {
printf("Lost\n"); // I get here always
}
}
jack_ringbuffer_reset(midi_rb);
return 0;
}
可能出了什么问题?
谢谢,
I have an application using JACK MIDI under Linux. It works perfectly on 32 bit machines, but on my new one, which is 64 bits, I get event loss all the time.
I checked:
- Values coming from
jack_ringbuffer_read
, they are OK (valid 2-3 bytes MIDI messages); midi_out_port
andclient
, they are OK (non-null) and appearing on my JACK port list;
Here's part of the code:
#define MidiMessageSize 3
jack_client_t* client;
jack_port_t* midi_out_port;
char current_message[MidiMessageSize];
jack_ringbuffer_t* midi_rb;
int process (jack_nframes_t nframes, void *arg)
{
void* output_buffer = jack_port_get_buffer(midi_out_port, nframes);
jack_midi_clear_buffer(output_buffer);
int read_space = jack_ringbuffer_read_space(midi_rb);
if (read_space == 0) return 0;
int i;
for (i = 0; i < read_space; i += MidiMessageSize)
{
jack_ringbuffer_read(midi_rb, current_message, MidiMessageSize);
jack_midi_event_write(output_buffer, i/MidiMessageSize,
(jack_midi_data_t*)current_message, MidiMessageSize);
if (jack_midi_get_lost_event_count(midi_out_port)) {
printf("Lost\n"); // I get here always
}
}
jack_ringbuffer_reset(midi_rb);
return 0;
}
What may be wrong?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
奇怪的是,JACK(上一个版本)正确发送了所有 midi 事件,但是
jack_midi_get_lost_event_count
总是返回我 1。只是忽略它,现在我的代码正在工作。这在 32 位中仍然不会发生,但无论如何现在它可以工作了。
Strangely JACK (last version) is sending all midi events right, but
jack_midi_get_lost_event_count
is always returning me 1. Just ignored it and now my code is working.Still this don't happen in 32 bit, but anyway now it's working.