Basic concept for System Exclusive with MIDI CoolTools Copyright (C)1995, Artic Software Artic Software PO Box 28 Waterford, WI 53185-0028 ===================================================== ' ** SENDING SYSEX MESSAGES ** ' You need to open the MIDIOUT first. ' MIDIOutput1.Action = MIDIOUT_OPEN ' Define the Message Byte as the first byte. In the case of ' sysex messages, it's always &HF0 ' MIDIOutput1.Message = &HF0 ' Define the .Buffer property (string) ' Use Chr$(&HF7) at the end of buffer string. ' ' This is what the message is based on - all in Hex: ' ' F0 Start byte ' 0F Manufacturer Code ' 03 Product Code ' 00 MIDI Channel ' ' 11 Parameter Update command Code (Ensoniq Only) ' ' 00 00 00 00 00 ' 01 Instrument, Layer, Wavesample - all Ensoniq only) ' ' 34 System Parameter ' 01 Master Tune Parameter 00 00 00 ' 0F This is the value to change the Master Tune to - +15 ' ' F7 End of message ' ' The following is the example message: ' MIDIOutput1.Buffer = Chr$(&HF0) & Chr$(15) & Chr$(3) & Chr$(0) & Chr$(3) & Chr$(0) & Chr$(InstNum) & Chr$(0) & Chr$(0) & Chr$(0) & Chr$(1) & Chr$(&HF7) ' Set the Time (optional), ' MIDIOutput1.Time = 0 ' Place message into Queue and Start later ' MIDIOutput1.Action = MIDIOUT_QUEUE MIDIOutput1.Action = MIDIOUT_START ' or send message immediately ' MIDIOutput1.Action = MIDIOUT_SEND ======================================================= ' ** RECEIVING SYSEX MESSAGES ** ' First, you need to open the MIDIIN. ' MIDIInput1.Action = MIDIIN_OPEN 'Set the MIDIIn Port to Start ' MIDIInput1.Action = MIDIIN_START 'Set your code to be ready to capture the incoming text. ' ' 'From inside the Sub MIDIInput1 Message event, this Do While Loop allows you to receive 'sysex messages that are waiting in MIDIInput1.Buffer. You will only find 'sysex messages in the MIDIInput Buffer. To set the size of this buffer, you must do this 'at design time using the MaxSysexSize property of MIDIInput1. ' 'A MIDI Message is waiting because MessageCount is > 0 and the length of the Buffer 'is > 0 so there is a sysex message in this buffer. ' Do While MIDIInput1.MessageCount > 0 And Len(MIDIInput1.Buffer) > 0 'A complete sysex message has been received into the 'MIDIInput.Buffer ' 'Now we'll put the first data byte of sysex message into 'the DisplayBufferString. ' DisplayBufferString = Hex(Asc(Left(MIDIInput1.Buffer, 1))) 'Now we're going to go through the remaining portion of the 'sysex message and get it ready to display. We'll then be able 'to view and edit the complete sysex message. ' For n = 2 To Len(MIDIInput1.Buffer) DisplayBufferString = DisplayBufferString & " " & Hex(Asc(Mid(MIDIInput1.Buffer, n, 1))) Next n ' 'DisplayBufferString now contains the sysex message in a viewable 'format ' 'Remove the MIDI data from the MIDI IN queue ' MIDIInput1.Action = MIDIIN_REMOVE Loop 'DisplayBufferString now contains the sysex message in a viewable 'format. Now let see it. Label1.Caption = DisplayBufferString ' IF the buffer is > 0 then we've received some sysex data If Len(DisplayBufferString(SysexListCount)) > 0 Then MIDIOutput1.Message = MIDIInput1.Message MIDIOutput1.Data1 = MIDIInput1.Data1 MIDIOutput1.Data2 = MIDIInput1.Data2 MIDIInput1.Action = MIDIIN_REMOVE MIDIOutput1.Action = MIDIOUT_START MIDIOutput1.Action = MIDIOUT_SEND MIDIOutput1.Action = MIDIOUT_STOP End If ' When the program is exited, you need to close both the ' MIDIIN and MIDIOUT. ' MIDIOutput1.Action = MIDIOUT_CLOSE MIDIInput1.Action = MIDIIN_CLOSE