Interested in a training?
Contact us for a trainings and events or meet us at Real World in Orlando, Florida.
Contact us for a trainings and events or meet us at Real World in Orlando, Florida.
MBS Real Studio Plugin Tutorial Videos
Midi Send Source
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete
End Class
Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub ValueChanged() Handles Event
StaticText3.text = str(me.Value)
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Function MouseDown(index as Integer, X As Integer, Y As Integer) As Boolean Handles Event
me.Value = true
SendNoteOn index
Return true
End Function
Function MouseUp(index as Integer, X As Integer, Y As Integer) As Boolean Handles Event
me.Value = false
SendNoteOff index
Return true
End Function
End ControlInstance
// Properties
Dim p As PortMidiMBS
Dim s As PortMidiStreamMBS
Dim m As MidiPlaybackMBS
// Event implementations
Sub Open()
p = new PortMidiMBS
m = new MidiPlaybackMBS
dim c as integer = p.CountDevices - 1
for DeviceID as integer = 0 to c
dim info as PortMidiDeviceInfoMBS = p.DeviceInfo(DeviceID)
if info<>nil and info.HasOutput then
s = new PortMidiStreamMBS
dim e as integer = s.OpenOutput(DeviceID, 10000, 100)
if e = 0 then
Title = info.Name + " - " + info.InterfaceName
Return
end if
end if
next
MsgBox "No MIDI output device found."
quit
End Sub
Function KeyDown(Key As String) As Boolean
Select case key
case "c"
bevel(0).Value = true
SendNoteOn 0
Return true
case "d"
bevel(2).Value = true
SendNoteOn 2
Return true
case "e"
bevel(4).Value = true
SendNoteOn 4
Return true
case "f"
bevel(5).Value = true
SendNoteOn 5
Return true
case "g"
bevel(7).Value = true
SendNoteOn 7
Return true
end Select
End Function
Sub KeyUp(Key As String)
Select case key
case "c"
bevel(0).Value = false
SendNoteOff 0
case "d"
bevel(2).Value = false
SendNoteOff 2
case "e"
bevel(4).Value = false
SendNoteOff 4
case "f"
bevel(5).Value = false
SendNoteOff 5
case "g"
bevel(7).Value = false
SendNoteOff 7
end Select
End Sub
// Methods
Function GetOffset() As integer
Return PopupMenu1.ListIndex * 12
End Function
Function GetVelocity() As integer
Return Slider1.Value
End Function
Sub SendNoteOn(noteValue as integer)
dim d as new PortMidiEventMBS
d.set &h90, noteValue + GetOffset, GetVelocity
call s.Write d
m.SendMidiEvent &h90, noteValue + GetOffset, GetVelocity, 0
End Sub
Sub SendNoteOff(noteValue as integer)
dim d as new PortMidiEventMBS
d.set &h80, noteValue + GetOffset, GetVelocity
call s.Write d
m.SendMidiEvent &h80, noteValue + GetOffset, GetVelocity, 0
End Sub
End Class
Loading
Links
MBS Realbasic Chart Plugins - Pfarrgemeinde St. Arnulf Nickenich