Suppose a Mac API has the following struct, referenced here: Apple Developer Documentation (with code from here ):
struct MIDISysexSendRequest
{
MIDIEndpointRef destination;
const Byte * data;
UInt32 bytesToSend;
Boolean complete;
Byte reserved[3];
MIDICompletionProc completionProc;
void * completionRefCon;
};
How to import it into Xojo? The intention is to be able to create one so I can send it with the MIDISendSysex CoreMIDI API command.
The Xojo tutorial mainly talks about importing Functions, not structures.
You’ll have to manually recreate the structure in Xojo (Insert->Structure). Something like this:
Structure MIDISysexSendRequest
MIDIEndpointRef As Ptr
Data As Ptr
BytesToSend As UInt32
Complete As Boolean
Reserved As String*3
MIDICompletionProc As Ptr
CompletionRefCon As Ptr
1 Like
Thank you, barring other solutions I will use that.
Is there a way to embed Swift or Objective-C code into Xojo? The call I would like to execute requires a lot of CoreMIDI variables and functions.
What about the following structs:
struct MIDIPacket
{
MIDITimeStamp timeStamp;
UInt16 length;
Byte data[256];
};
and
struct MIDIPacketList
{
UInt32 numPackets;
MIDIPacket packet[1];
};
My current implementations (which do not work):
Structure MIDIPacket
timestamp As Integer
length As Uint16
data As String*256
Structure MIDIPacketList
numPackets As UInt32
packet(1) As MidiPacket
A problem I can think of is structs do not support MemoryBlocks (what I would guess equals the ‘Byte’ data type).
So my solution was to assign my binary data to memory block (mb.byte(0) = &hf0 etc), then assign the data string to that memoryblock.
EDIT: Nevermind it works! I forgot to set the packet.length property.
1 Like