处理可可中MIDIReadProc传入的Midi信号的最佳策略 [英] Best strategy to handle incoming midi signal from MIDIReadProc in cocoa

查看:80
本文介绍了处理可可中MIDIReadProc传入的Midi信号的最佳策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须通过硬件midi控制器移动一些 NSSlider ,我已经编写了一个Midi学习程序,将硬件光标分配给 NSSlider (的子类),然后就可以了。在 MIDIReadProc 内,我处理移动 NSSlider 的方法取决于传入的控件和值,但是现在当我移动硬件光标时,滑块可以移动一个时间,就像移动光标停止其他移动一样。

I have to move some NSSlider by hardware midi controller, I have programmed a midi learn procedure to assign hardware cursor to NSSlider(sub class of), and up there it's all right. Inside MIDIReadProc, I handle moving NSSlider wich depends from incoming control and value, but now when I move hardware cursor, Sliders can be move one for time, it is like moving cursor stop the others.

我的问题是,同时处理光标移动的最佳策略是什么?
1。我是否必须使用单独的线程处理?
2。我是否应该具有一个 MIDIPacket FIFO 数据结构,并从 MIDIReadProc (有一些并发分离的过程)?

My question is, what is best strategy to handle cursor moving concurrently ? 1 . Should I have to handle with a separated thread ? 2 . Should I have one FIFO data structure of MIDIPacket and processing that out of MIDIReadProc(with some concurrency separated process) ?

对不起我的英语。
感谢您的关注。

I'm sorry for my english. Thanks for attention.

a。

推荐答案

您不应在 MIDIReadProc 回调内部进行任何UI同步。

You should not do any UI synchronisation inside MIDIReadProc callback.

此回调是从高优先级实时线程调用的,因此您必须避免做任何可能太长的事情。

This callback is called from a high priority realtime thread so you must avoid doing anything that could be "too long" in it.

如您所说,您可以使用FIFO并在另一个线程中进行处理(例如主线程) )。

As you said you can use a FIFO and treat that in another thread (for instance the main thread).

这篇关于处理可可中MIDIReadProc传入的Midi信号的最佳策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆