我正在开发一个使用MIDI的MacOS应用程序。我想做的是向MIDI设备发送s SysEx消息。现在,我用Java做过一次,但从来没有在Swift中做过。
而且,由于coremidi库对我来说几乎是全新的,我不知道它是如何工作的。到目前为止,我已经了解到,我必须编写一个MIDISysexSendRequest,而且我已经走了这么远:
let SysEx = MIDISysexSendRequest(destination: self.endpointRef, data: UnsafePointer<UInt8>, bytesToSend: 8, complete: complete, reserved: (UInt8, UInt8, UInt8), completionProc: completionProc, completionRefCon: nil)在这方面,有几件事让我感到困惑:
data变量?我知道我想发送什么字节,只是不知道如何为Swift格式化reserved应该是什么?我找不到任何例子或参考,这些我可以使用。有人能帮我/
提前谢谢。
发布于 2017-06-07 11:30:24
保留的意味着您不能使用它,如:“为内部使用保留”
struct MIDISysexSendRequest
{
MIDIEndpointRef destination;
const Byte * data;
UInt32 bytesToSend;
Boolean complete;
Byte reserved[3];
MIDICompletionProc completionProc;
void * __nullable completionRefCon;
};
/*!
@struct MIDISysexSendRequest
@abstract A request to transmit a system-exclusive event.
@field destination
The endpoint to which the event is to be sent.
@field data
Initially, a pointer to the sys-ex event to be sent.
MIDISendSysex will advance this pointer as bytes are
sent.
@field bytesToSend
Initially, the number of bytes to be sent. MIDISendSysex
will decrement this counter as bytes are sent.
@field complete
The client may set this to true at any time to abort
transmission. The implementation sets this to true when
all bytes have been sent.
@field completionProc
Called when all bytes have been sent, or after the client
has set complete to true.
@field completionRefCon
Passed as a refCon to completionProc.
@discussion
This represents a request to send a single system-exclusive MIDI event to
a MIDI destination asynchronously.
*/注意保留变量是如何在头文件中没有显示的。
一个快速的google显示了许多使用MIDI快速编写的项目。浏览其中的一些,看看有用的例子。
我看的第一个似乎很适合看事情是怎么做的。它甚至有相当多的.java文件,因此您可能更容易了解它与for (或如何连接它们)之间的关系。
看看这里:斯威夫特的MIDI
在CoreMIDI框架中,有一个名为"MIDIServices.h“的文件(finder会为您找到它)。它有很多关于MIDI的信息。
祝你好运!
https://stackoverflow.com/questions/44410914
复制相似问题