Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/MIDI/MIDI Devices
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/MIDI/MIDI Devices
This example is the version from Tue, 18th Jan 2010.
Notes: Last modified: Tue, 18th Jan 2010
Class MainWindow
Inherits Window
// Controls
ControlInstance
Sub Change() Handles Event
update
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
loadproperties
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance

// Properties
Dim client As MidiClientMBS
Protected Dim currentobject As midiobjectMBS
Protected Dim olist(0) As midiobjectMBS

// Event implementations
Sub Close()
client.Close
End Sub
Sub Open()


client=new MyMidiClientMBS

client.Init newcfstringmbs("RB test application")

lasterror.text=str(client.lasterror)
update

Title=st(client.kMIDIPropertyManufacturer)
End Sub

// Methods
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
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 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
End Class

Class MyMidiClientMBS
Inherits Object
// Event implementations
Sub ThruConnectionsChanged()
w "Thru connections changed."

End Sub
Sub SetupChanged()
w "Setup changed."

End Sub
Sub SerialPortOwnerChanged()
w "Serial port owner changed."

End Sub
Sub PropertyChanged(target as MidiObjectMBS, theProperty as CFStringMBS)
w "Property changed."
MainWindow.loadproperties
End Sub
Sub ObjectRemoved(parent as MidiObjectMBS, child as MidiObjectMBS)
w "Object removed."
MainWindow.update

End Sub
Sub ObjectAdded(parent as MidiObjectMBS, child as MidiObjectMBS)
w "Object added."
MainWindow.update

End Sub

// Methods
Sub w(s as string)
MainWindow.eList.InsertRow 0,s
End Sub
End Class

Class App
Inherits Application
End Class


See also:




Links
MBS Realbasic PDF Plugins - Pfarrgemeinde Messdiener Nickenich