Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/MIDI/MIDI Destination


Required plugins for this example: MBS MacCF Plugin

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

This example is the version from Sun, 17th Mar 2012.

Project "MIDI Destination.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Close() closeMidiClient End EventHandler
EventHandler Sub Open() Client=new MidiClientMBS openMidiClient End EventHandler
Protected Sub closeMidiClient() End Sub
Sub openMidiClient() dim i,n as Integer dim myname as cfstringMBS myname=NewCFStringMBS("MidiTest") Client.Init(myname) if Client.Lasterror <> 0 then MsgBox "MidiClient MBS Init failed: " + str(Client.Lasterror) end endpoint=new myMidiEndpoint Client.Createdestination(newcfstringMBS("MyDestination"), endpoint) if endpoint.Handle=0 then MsgBox "There was an error: "+str(Client.Lasterror) end if system.debuglog "endpoint.handle: "+hex(endpoint.Handle) End Sub
Property Protected Client As midiclientMBS
Property Protected endpoint As MidiEndpointMBS
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class MyMidiEndpoint Inherits MidiEndpointMBS
EventHandler Sub Read(endpoint as MidiEndpointMBS, list as MidiPacketListMBS) dim i, j, n, x as integer dim pack as MIDIPacketMBS dim s as string dim data as memoryBlock dim k as integer // endpoint is nil! count=count+1 k=count n = list.Count-1 system.debuglog str(k)+" "+str(list.Count)+" packets." for i = 0 to n system.debuglog str(k)+" "+str(i) pack = list.item(i) data = pack.dataMemory x = data.size if data.byte(0) >= &h90 and data.byte(0) <= &h9F then 'note on s = "Note on(" + str(data.byte(1)) + ") + velocity("+str(data.byte(2)) + ")" elseif data.byte(0) >= &h80 and data.byte(0) <= &h8F then 'note off s = "Note off(" + str(data.byte(1)) + ") + velocity("+str(data.byte(2)) + ")" elseif data.byte(0) >= &hB0 and data.byte(0) <= &hBF then s = "Controller change(" + str(data.byte(1)) + ") + value("+str(data.byte(2)) + ")" elseif data.byte(0) >= &hE0 and data.byte(0) <= &hEF then s = "Pitchbend" elseif data.byte(0) = &hFE then 'don't do anything with active sensing s = "" else system.debuglog str(k)+" something else" 'more midi events go here s = "" for j = 0 to x-1 s = s + str(data.byte(j)) + " " next end if s <> "" then system.debuglog str(k)+" insertrow" window1.ListBox1.Insertrow 0,s end next system.debuglog str(k)+" finished. " End EventHandler
Property Protected count As integer
End Class
End Project

See also:

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


The biggest plugin in space...