Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/MIDI/MIDI Devices


Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/MIDI/MIDI Devices

This example is the version from Sun, 2nd May 2020.

Project "MIDI Devices.xojo_binary_project"
Class MainWindow Inherits Window
Control PopupWhich Inherits PopupMenu
ControlInstance PopupWhich Inherits PopupMenu
EventHandler Sub Change() update End EventHandler
End Control
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Change() loadproperties End EventHandler
End Control
Control Countfield Inherits Label
ControlInstance Countfield Inherits Label
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control lasterror Inherits Label
ControlInstance lasterror Inherits Label
End Control
Control plist Inherits ListBox
ControlInstance plist Inherits ListBox
End Control
Control eList Inherits ListBox
ControlInstance eList Inherits ListBox
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
EventHandler Sub Close() client.Close End EventHandler
EventHandler Sub Open() client=new MyMidiClientMBS client.Init newcfstringmbs("RB test application") lasterror.text=str(client.lasterror) update Title=st(client.kMIDIPropertyManufacturer) End EventHandler
Sub loadproperties() dim o as MidiObjectMBS dim l as CFDictionaryListMBS dim i,c as integer dim d as CFDictionaryMBS dim s as CFObjectMBS if list.ListIndex<0 then plist.DeleteAllRows else plist.DeleteAllRows o=olist(List.ListIndex) if o<>Nil then s=o.Properties(false) if s isa CFDictionaryMBS then d=CFDictionaryMBS(s) if d<>nil then l=d.List if l<>nil then c=l.Count-1 // 0 based for i=0 to c s=l.Key(i) if s<>nil then plist.AddRow st(s) plist.cell(plist.LastIndex,1)=st(l.Value(i)) end if next end if end if end if end if end if End Sub
Function st(o as cfobjectMBS) As string dim s as CFStringMBS dim n as CFNumberMBS dim oo as CFObjectMBS if o<>Nil then // check string if o isa CFStringMBS then s=CFStringMBS(o) if s<>nil then Return s.str end if end if // check number if o isa CFNumberMBS then n=CFNumberMBS(o) if n<>nil then Return format(n.integerValue,"0") end if end if s=o.TypeDescription if s<>Nil then Return "#"+s.str end if Return "#?" end if End Function
Sub update() dim i,c as integer dim o as MidiObjectMBS dim what as String // Clear lists: List.DeleteAllRows plist.DeleteAllRows redim olist(-1) // which one choosen? select case PopupWhich.ListIndex case 0 c=client.NumberOfDevices what="devices" case 1 c=client.NumberOfExternalDevices what="external devices" case 2 c=client.NumberOfSources what="sources" case 3 c=client.NumberOfDestinations what="destinations" end Select Countfield.text=str(c)+" "+what redim olist(c) c=c-1 // 0 based for i=0 to c select case PopupWhich.ListIndex case 0 o=client.GetDevice(i) case 1 o=client.GetExternalDevice(i) case 2 o=client.GetSource(i) case 3 o=client.GetDestination(i) end Select if o<>Nil then olist(i)=o List.AddRow st(o.StringProperty(client.kMIDIPropertyName)) end if next End Sub
Property client As MidiClientMBS
Property Protected currentobject As midiobjectMBS
Property Protected olist(0) As midiobjectMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
Class MyMidiClientMBS Inherits MidiClientMBS
EventHandler Sub ObjectAdded(parent as MidiObjectMBS, child as MidiObjectMBS) w "Object added: "+child.DisplayName MainWindow.update End EventHandler
EventHandler Sub ObjectRemoved(parent as MidiObjectMBS, child as MidiObjectMBS) w "Object removed." MainWindow.update End EventHandler
EventHandler Sub PropertyChanged(target as MidiObjectMBS, theProperty as CFStringMBS) w "Property changed." MainWindow.loadproperties End EventHandler
EventHandler Sub SerialPortOwnerChanged() w "Serial port owner changed." End EventHandler
EventHandler Sub SetupChanged() w "Setup changed." End EventHandler
EventHandler Sub ThruConnectionsChanged() w "Thru connections changed." End EventHandler
Sub w(s as string) MainWindow.eList.InsertRow 0,s End Sub
End Class
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...