Platforms to show: All Mac Windows Linux Cross-Platform

Back to MidiClientMBS class.

MidiClientMBS.Available as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
True if the MIDI stuff was successfull loaded.

MidiClientMBS.close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
The destructor.

There is no need to call this method except you want to free all resources of this object now without waiting for Xojo to do it for you.

MidiClientMBS.CreateDestination(name as CFStringMBS, TargetEndpointObject as MidiEndpointMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Create a virtual destination in a client.

Clients may use this to create virtual destinations.
Lasterror is set.
You must pass a valid new MidiEndpointMBS for TargetEndpointObject. Best is if you make a subclass from MidiEndpointMBS and fill the event. You can add there additional methods and properties. CreateDestination will than fill the handle property on success.

Some examples using this method:

MidiClientMBS.CreateInputPort(name as CFStringMBS, targetportobject as MidiPortMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Create an input port through which the client may receive incoming MIDI messages from any MIDI source.
Example
dim mc as MidiClientMBS
dim mp as MidiPortMBS

mc=new MidiClientMBS
mc.Init NewCFStringMBS("Testapp")

mp=new MidiPortMBS
mc.CreateInputPort NewCFStringMBS("Testport"), mp

if mp.Handle=0 then
MsgBox "There was an error: "+str(mc.Lasterror)
else
MsgBox "ok"
end if

After creating a port, use MIDIPortConnectSource to establish an input connection from any number of sources to your port.

Lasterror is set.

As you can subclass the MidiPortMBS class you must pass to this function a valid MidiPortMBS object so it can be filled.

Some examples using this method:

MidiClientMBS.CreateOutputPort(name as CFStringMBS, targetportobject as MidiPortMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Create an output port through which the client may send outgoing MIDI messages to any MIDI destination.
Example
dim mc as MidiClientMBS
dim mp as MidiPortMBS

mc=new MidiClientMBS
mc.Init NewCFStringMBS("Testapp")

mp=new MidiPortMBS
mc.CreateOutputPort NewCFStringMBS("Testport"), mp

if mp.Handle=0 then
MsgBox "There was an error: "+str(mc.Lasterror)
else
MsgBox "ok"
end if

Output ports provide a mechanism for MIDI merging. The system assumes that each output port will be responsible for sending only a single MIDI stream to each destination, although a single port may address all of the destinations in the system.

Lasterror is set.

As you can subclass the MidiPortMBS class you must pass to this function a valid MidiPortMBS object so it can be filled.

Some examples using this method:

MidiClientMBS.CreateSource(name as CFStringMBS) as MidiEndpointMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new virtual Midi source.
Example
dim m as MidiClientMBS
dim e as MidiEndpointMBS

m=new MidiClientMBS

// Initialize
m.Init NewCFStringMBS("Hallo")

// Create device:
e=m.CreateSource(NewCFStringMBS("Hallo"))

// if error is 0 and handle is not 0, it's okay
MsgBox "error: "+str(m.Lasterror)+", handle: "+str(e.Handle)

Lasterror is set.
Returns nil on any error.

Clients may use this to create virtual sources.

After creating a virtual source, use Received to transmit MIDI messages from your virtual source to any clients connected to the virtual source.

Some examples using this method:

MidiClientMBS.FindObjectByUniqueID(id as Integer) as MidiObjectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Locate a device, typedefal device, entity, or endpoint by its uniqueID.

New for CoreMIDI 1.3.
You may cast the returned object to MidiEndpointMBS, MidiEntityMBS or MidiDeviceMBS. RB's "isa" command may help you.
Returns nil on any error. Lasterror is set.

Some examples using this method:

MidiClientMBS.GetDestination(index as Integer) as MidiEndpointMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return one of the destinations in the system.

The index goes from 0 to NumberOfDestinations-1.
Lasterror is set.
Returns nil on any error.

MidiClientMBS.GetDevice(index as Integer) as MidiDeviceMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return one of the devices in the system.

To enumerate the entities in the system, you can walk through the devices, then walk through the devices' entities.

Note: If a client iterates through the devices and entities in the system, it will not ever visit any virtual sources and destinations created by other clients. Also, a device iteration will return devices which are "offline" (were present in the past but are not currently present), while iterations through the system's sources and destinations will not include the endpoints of offline devices.

Thus clients should usually prefer NumberOfSources, GetSource, NumberOfDestinations and GetDestination to iterating through devices and entities to locate endpoints.

Lasterror is set.
Returns nil on any error.

Some examples using this method:

MidiClientMBS.GetExternalDevice(index as Integer) as MidiDeviceMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return one of the external devices in the system.

The index goes from 0 to NumberOfDevices-1.
Lasterror is set.
Returns nil on any error.

Some examples using this method:

MidiClientMBS.GetSource(index as Integer) as MidiEndpointMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Return one of the sources in the system.

The index goes from 0 to NumberOfSources-1.
Lasterror is set.
Returns nil on any error.

MidiClientMBS.Init(name as CFStringMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new Client object with the given client name.

Lasterror is set.

MidiClientMBS.NumberOfDestinations as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the number of destinations in the system.
Example
dim m as new MidiClientMBS
dim n as Integer = m.NumberOfDestinations

MsgBox "NumberOfDestinations: "+str(n)

Returns 0 on any error.
Lasterror is set.

MidiClientMBS.NumberOfDevices as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the number of devices in the system.
Example
dim m as new MidiClientMBS
dim n as Integer = m.NumberOfDevices

MsgBox "NumberOfDevices: "+str(n)

Returns 0 on any error.
Lasterror is set.

Some examples using this method:

MidiClientMBS.NumberOfExternalDevices as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the number of typedefal MIDI devices in the system.
Example
dim m as new MidiClientMBS
dim n as Integer = m.NumberOfExternalDevices

MsgBox "NumberOfExternalDevices: "+str(n)

External MIDI devices are MIDI devices connected to endpoints via a standard MIDI cable. Their presence is completely optional, only when a UI somewhere adds them.

New for CoreMIDI 1.1.

Returns 0 on any error.
Lasterror is set.

Some examples using this method:

MidiClientMBS.NumberOfSources as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the number of sources in the system.
Example
dim m as new MidiClientMBS
dim n as Integer = m.NumberOfSources

MsgBox "NumberOfSources: "+str(n)

Returns 0 on any error.
Lasterror is set.

MidiClientMBS.Send(port as MidiPortMBS, endpoint as MidiEndpointMBS, packets as MidiPacketListMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method MIDI MBS MacCF Plugin 3.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Sends midi data using the port to the given endpoint.
Example
// Not 100% if this example works:
dim client as MIDIClientMBS
dim outport as MIDIPortMBS
dim dest as MIDIEndpointMBS
dim pack as MIDIPacketMBS
dim list as MIDIPacketListMBS
dim packs(-1) as MIDIPacketMBS

client = new MidiClientMBS

if client <> nil then
client.Init newcfstringmbs("CoreMIDI")
outport = new MIDIPortMBS
client.CreateOutputPort(NewCFStringMBS("outport"), outport)
dest = client.getDestination(0)
outport.connectSource dest

pack = new MIDIPacketMBS
list = new MIDIPacketListMBS
pack.timeStamp = nil
pack.datastring = chrb(&h90)+chrb(&h5A)+chrb(&h7C)
packs.append pack
if not list.FillList(packs) then
msgBox "bad"
end

client.Send(outport, dest, list)
end

Events with future timestamps are scheduled for future delivery. The system performs any needed MIDI merging.

Lasterror is set.

The items on this page are in the following plugins: MBS MacCF Plugin.


The biggest plugin in space...