Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/MIDI/MIDI Synth Keys


Required plugins for this example: MBS MacOSX Plugin

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

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

Project "MIDI Synth Keys.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control list Inherits ListBox
ControlInstance list Inherits ListBox
EventHandler Sub Change() dim n as integer if me.ListIndex>=0 then n=me.CellTag(me.ListIndex,0) player.InstrumentIDOnChannel(0)=n Title="Setting instrument "+str(me.LastIndex) end if End EventHandler
End Control
Control notes Inherits BevelButton
ControlInstance notes(0) Inherits BevelButton
ControlInstance notes(1) Inherits BevelButton
ControlInstance notes(2) Inherits BevelButton
ControlInstance notes(3) Inherits BevelButton
ControlInstance notes(4) Inherits BevelButton
ControlInstance notes(5) Inherits BevelButton
ControlInstance notes(6) Inherits BevelButton
ControlInstance notes(7) Inherits BevelButton
ControlInstance notes(8) Inherits BevelButton
ControlInstance notes(9) Inherits BevelButton
ControlInstance notes(10) Inherits BevelButton
ControlInstance notes(11) Inherits BevelButton
ControlInstance notes(12) Inherits BevelButton
EventHandler Function MouseDown(index as Integer, X As Integer, Y As Integer) As Boolean me.value = true SendNoteOn(index) return true End EventHandler
EventHandler Function MouseUp(index as Integer, X As Integer, Y As Integer) As Boolean me.value = false SendNoteOff(index) return true End EventHandler
End Control
Control Error Inherits ListBox
ControlInstance Error Inherits ListBox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() InitMIDI End EventHandler
Sub InitMIDI() dim i,c,id as integer player=new MidiPlaybackMBS if player.Inited then c=player.InstrumentCount for i=0 to c-1 id=player.InstrumentID(i) list.AddRow player.InstrumentName(id) list.CellTag(list.LastIndex,0)=id next else MsgBox "Need Mac OS X 10.2 or newer! And need to be compiled for Mach-O!" end if End Sub
Sub Msg(s as string) Error.InsertRow 0,s End Sub
Sub SendNoteOff(noteValue as integer) dim Status,Data1,Data2 as integer Status = &h80 'note off Data1 = noteValue + 48 'take it up a few octaves Data2 = &h7C 'velocity player.SendMidiEvent Status,Data1,Data2,0 Msg "Send off "+str(player.Lasterror) End Sub
Sub SendNoteOn(noteValue as integer) dim Status,Data1,Data2 as integer Status = &h90 'note on Data1 = noteValue + 48 'take it up a few octaves Data2 = &h7C 'velocity player.SendMidiEvent Status,Data1,Data2,0 Msg "Send off "+str(player.Lasterror) End Sub
Property Protected player As MidiplaybackMBS
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
Module Util
Function CFString(c as cfstringMBS) As string if c<>nil then Return c.str end if Exception End Function
End Module
End Project

See also:

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


The biggest plugin in space...