Jump to content

Component: MIDI (Comms: System): Difference between revisions

From Flowcode Help
XML import
No edit summary
Line 1: Line 1:
 
{| style="width:50%"
 
{| width="50%"
|-
|-
| width="20%" style="color: gray;" | Author
| width="20%" style="color:gray;" | Author
| Matrix Ltd.
| Matrix Ltd.
|-
|-
| width="20%" style="color: gray;" | Version
| width="20%" style="color:gray;" | Version
| 2.0 (Release)
| 2.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Comms: System
| Comms: System
|}
|}




==MIDI component==
Low level routines for controlling or interacting with a standard MIDI interface.
==Detailed description==


==[[File:Component Icon a9b43242_9ccc_4f1c_b2d1_acdfbe420fc1.png|Image]] MIDI component==
''No detailed description exists yet for this component''
Low level routines for controlling or interacting with a standard MIDI interface.


==Examples==
==Examples==
Basic example to play a series of notes getting higher in pitch and then going down in pitch. This repeats in a loop and each time the loop repeats the instrument is changed. The current note and instrument are displayed on the LCD.
Basic example to play a series of notes getting higher in pitch and then going down in pitch. This repeats in a loop and each time the loop repeats the instrument is changed. The current note and instrument are displayed on the LCD.
{{Fcfile|Midi.fcfx|MIDI Test File}}
{{Fcfile|Midi.fcfx|MIDI Test File}}
Line 45: Line 48:
==Downloadable macro reference==
==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>SendMIDI</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Sends a MIDI packet consisting of up to three bytes of information,
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendMIDI'''
|-
| colspan="2" | Sends a MIDI packet consisting of up to three bytes of information,&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Status
|-
| colspan="2" | MIDI Status Byte - Used for commands such as NoteOn, NoteOff etc.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Data1
|-
| colspan="2" | MIDI Data Byte - Used as a parameter specific to the specified command&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Data2
|-
| colspan="2" | MIDI Data Byte - Used as a parameter specific to the specified command&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Parameters'''


:[[Variable Types|BYTE]] ''Status''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::MIDI Status Byte - Used for commands such as NoteOn, NoteOff etc.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendPitchChange'''
|-
| colspan="2" | Sends out a pitch change command on the specified channel.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Channel to send the pitch change to&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Pitch_Change
|-
| colspan="2" | New pitch value to use, Default 0x2000&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Data1''
::MIDI Data Byte - Used as a parameter specific to the specified command


:[[Variable Types|BYTE]] ''Data2''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::MIDI Data Byte - Used as a parameter specific to the specified command
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendNoteOff'''
|-
| colspan="2" | Sends a note off command using the channel, note and velocity specified.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Note
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Velocity
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendControl'''
|-
| colspan="2" | Sends a control command using the channel, controller and value specified.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Controller
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Value
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:''This call does not return a value''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendNoteOn'''
|-
| colspan="2" | Sends a note on command using the channel, note and velocity specified.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Note
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Velocity
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>SendPitchChange</tt></u></span>===
Sends out a pitch change command on the specified channel.


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveMIDI'''
|-
| colspan="2" | Waits for the time specified in the timeout parameter for an incoming MIDI message. Returns 0 to indicate a timeout, otherwise returns the first value from the MIDI message. &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Timeout
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Channel''
::Channel to send the pitch change to


:[[Variable Types|UINT]] ''Pitch_Change''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::New pitch value to use, Default 0x2000
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendPolyPressure'''
|-
| colspan="2" | Sends a note press with an associated polyphonic pressure value.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Note
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Pressure
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadData'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Idx
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:''This call does not return a value''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendPatch'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Instrument
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>SendNoteOff</tt></u></span>===
Sends a note off command using the channel, note and velocity specified.


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendChannelPressure'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Pressure
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Channel''


:[[Variable Types|BYTE]] ''Note''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Initialises the MIDI component and sets up the UART.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Velocity''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CommsBaud'''
|-
| colspan="2" | Sets the Baud rate of the alt communications channel&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Baud
|-
| colspan="2" | Range: 0-7 : 0=1200 / 7=115200&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Return value'''


:''This call does not return a value''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDOptions'''
|-
| colspan="2" | Controls some of the LCD options&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Foreground
|-
| colspan="2" | Range: 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Background
|-
| colspan="2" | Range: 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Transparent
|-
| colspan="2" | Range: 0-1&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




===<span style="font-weight: normal;"><u><tt>SendControl</tt></u></span>===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Sends a control command using the channel, controller and value specified.
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDVerbose'''
|-
| colspan="2" | Controls the Verbose mode.  When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Mode
|-
| colspan="2" | Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Parameters'''


:[[Variable Types|BYTE]] ''Channel''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInput'''
|-
| colspan="2" | Reads a single digital input.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Controller''


:[[Variable Types|BYTE]] ''Value''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMConfig'''
|-
| colspan="2" | Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 :  0=1:1 1=1:8 2=1:64 3=1:256&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 0-1&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Period
|-
| colspan="2" | Range: 0-65535&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Scaler
|-
| colspan="2" | Range: 0-3&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}




'''Return value'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMEnable'''
|-
| colspan="2" | Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | EnableMask
|-
| colspan="2" | Range 0-63 or 0b00000 to 0b111111&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:''This call does not return a value''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''PWMDuty'''
|-
| colspan="2" | Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 0-5&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | Duty
|-
| colspan="2" | &nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


===<span style="font-weight: normal;"><u><tt>SendNoteOn</tt></u></span>===
Sends a note on command using the channel, note and velocity specified.


'''Parameters'''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDCursor'''
|-
| colspan="2" | Sets the cursor position for the MIAC display&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | X
|-
| colspan="2" | Range: 0-21&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Y
|-
| colspan="2" | Range: 0-4&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Channel''


:[[Variable Types|BYTE]] ''Note''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteTran'''
|-
| colspan="2" | Allows a single transistor output to be switched on or off.&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Channel
|-
| colspan="2" | Range 1-4&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Value
|-
| colspan="2" | 0 = Off, 1 = On&nbsp;
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


:[[Variable Types|BYTE]] ''Velocity''


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | &nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}


'''Return value'''


:''This call does not return a value''
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
===<span style="font-weight: normal;"><u><tt>ReceiveMIDI</tt></u></span>===
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''LCDClear'''
Waits for the time specified in the timeout parameter for an incoming MIDI message.
|-
 
| colspan="2" | Clears the MIAC display&nbsp;
Returns 0 to indicate a timeout, otherwise returns the first value from the MIDI message.
|-
 
|-
'''Parameters'''
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
:[[Variable Types|BYTE]] ''Timeout''
|}
 
 
'''Return value'''
 
:[[Variable Types|BYTE]]
 
 
===<span style="font-weight: normal;"><u><tt>SendPolyPressure</tt></u></span>===
Sends a note press with an associated polyphonic pressure value.
 
'''Parameters'''
 
:[[Variable Types|BYTE]] ''Channel''
 
:[[Variable Types|BYTE]] ''Note''
 
:[[Variable Types|BYTE]] ''Pressure''
 
 
'''Return value'''
 
:''This call does not return a value''
 
 
===<span style="font-weight: normal;"><u><tt>ReadData</tt></u></span>===
''<span style="color:red;">No additional information</span>''




'''Parameters'''
:[[Variable Types|BYTE]] ''Idx''
'''Return value'''
:[[Variable Types|BYTE]]
===<span style="font-weight: normal;"><u><tt>SendPatch</tt></u></span>===
''<span style="color:red;">No additional information</span>''
'''Parameters'''
:[[Variable Types|BYTE]] ''Channel''
:[[Variable Types|BYTE]] ''Instrument''
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>SendChannelPressure</tt></u></span>===
''<span style="color:red;">No additional information</span>''
'''Parameters'''
:[[Variable Types|BYTE]] ''Channel''
:[[Variable Types|BYTE]] ''Pressure''
'''Return value'''
:''This call does not return a value''
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Initialises the MIDI component and sets up the UART.
'''Parameters'''
:''This macro has no parameters''
'''Return value'''
:''This call does not return a value''
==Simulation macro reference==
''This component does not contain any simulation macros''




==Property reference==
==Property reference==
<span style="font-weight: normal;"><u>Channel</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::CHANNEL''.
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
UART Channel selector
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels.
|-
 
|-
Hardware channels use the selected peripheral on-board the target microcontroller.
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
<span style="font-weight: normal;"><u>Baud Options</u></span>
|-
 
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::BAUD_LIST''.
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Channel
Baud rate option selector
|-
 
| colspan="2" | UART Channel selector Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels. Hardware channels use the selected peripheral on-board the target microcontroller.&nbsp;
<span style="font-weight: normal;"><u>Baud Rate</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_uart::BAUD''.
| width="90%" | Baud Options
 
|-
''<span style="color:red;">No additional information</span>''
| colspan="2" | Baud rate option selector&nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
| width="90%" | Baud Rate
<span style="font-weight: normal;"><u>Use TX</u></span>
|-
 
| colspan="2" | &nbsp;
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::UseTX''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Selects if the Transmit pin is used by the component.  
| width="90%" | Use TX
 
|-
Yes: The TX pin is active and used to transmit data for the UART.
| colspan="2" | Selects if the Transmit pin is used by the component. Yes: The TX pin is active and used to transmit data for the UART. No: The TX pin is disabled and free to be used as general I/O.&nbsp;
 
|-
No: The TX pin is disabled and free to be used as general I/O.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | TX
<span style="font-weight: normal;"><u>TX</u></span>
|-
 
| colspan="2" | Pin to be used for Transmit data&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::TX''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Pin to be used for Transmit data
| width="90%" | Use RX
 
|-
<span style="font-weight: normal;"><u>Use RX</u></span>
| colspan="2" | Selects if the Receive pin is used by the component. Yes: The RX pin is active and used to receive data for the UART. No: The RX pin is disabled and free to be used as general I/O.&nbsp;
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::UseRX''.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | RX
Selects if the Receive pin is used by the component.  
|-
 
| colspan="2" | Pin to be used for Receive data&nbsp;
Yes: The RX pin is active and used to receive data for the UART.
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
No: The RX pin is disabled and free to be used as general I/O.
| width="90%" | Use Flow Control
 
|-
<span style="font-weight: normal;"><u>RX</u></span>
| colspan="2" | Flow Control (Handshake) enable or disable.    On: Two I/O pins are used to control the flow of data in and out of the device.    Off: Flow control is disabled.&nbsp;
 
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RX''.
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
| width="90%" | RTS
Pin to be used for Receive data
|-
 
| colspan="2" | Pin to be used for Request To Send handshake function Output from target micro to inform remote device we are ready to receive data. Low = Ready to receive data High = Not ready to receive data&nbsp;
<span style="font-weight: normal;"><u>Use Flow Control</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::FLOWEN''.
| width="90%" | CTS
 
|-
Flow Control (Handshake) enable or disable.
| colspan="2" | Pin to be used for Clear To Send handshake function. Input to target micro to inform when the remote device is ready to transmit data. Low = Ready to transmit data High = Not ready to transmit data&nbsp;
 
|-
     On: Two I/O pins are used to control the flow of data in and out of the device.
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
     Off: Flow control is disabled.
|-
 
|-
<span style="font-weight: normal;"><u>RTS</u></span>
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 
| width="90%" | Label
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RTS''.
|-
 
| colspan="2" | &nbsp;
Pin to be used for Request To Send handshake function
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Output from target micro to inform remote device we are ready to receive data.
| width="90%" | MIDI Output
 
|-
Low = Ready to receive data
| colspan="2" | Decides if we are using special MIDI output or standard Serial/API Output. Yes: We send the simulation data via a MIDI interface. No: We send the simulation data via the standard COM/API interface.&nbsp;
 
|-
High = Not ready to receive data
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | MIDI Port
<span style="font-weight: normal;"><u>CTS</u></span>
|-
 
| colspan="2" | &nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::CTS''.
|-
 
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Pin to be used for Clear To Send handshake function.
| width="90%" | Scope Traces
 
|-
Input to target micro to inform when the remote device is ready to transmit data.
| colspan="2" | Selects if the scope traces are automatically added to the data recorder window or not.    Simulation - draws an approximation of the UART data onto the scope trace.    ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.&nbsp;
 
|-
Low = Ready to transmit data
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
| width="90%" | Console Data
High = Not ready to transmit data
|-
 
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
<span style="font-weight: normal;"><u>Label</u></span>
|-
 
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
| width="90%" | Console Columns
 
|-
''<span style="color:red;">No additional information</span>''
| colspan="2" | Number of characters that can be displayed on a single line of the console.&nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
| width="90%" | Data Source
<span style="font-weight: normal;"><u>MIDI Output</u></span>
|-
 
| colspan="2" | Simulation data source used to allow the component to connect to various remote devices    Nothing - Simulation data is ignored    COM port - Routes the communication data to and from a physical or virtual COM port     Injector - Routes the communication data via a data injector component on the Panel.&nbsp;
This property is of type ''True or false'' and can be referenced with the variable name ''MIDIOutput''.
|}
 
Decides if we are using special MIDI output or standard Serial/Injector Output.
 
Yes: We send the simulation data via a MIDI interface.
 
No: We send the simulation data via the standard COM/Injector interface.
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ScopeTraces''.
 
Selects if the scope traces are automatically added to the data recorder window or not.
 
     Simulation - draws an approximation of the UART data onto the scope trace.
 
     ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ConsoleData''.
 
Selects if the console data is automatically generated or not
 
<span style="font-weight: normal;"><u>Console Columns</u></span>
 
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''cal_uart::ConsoleColumns''.
 
Number of characters that can be displayed on a single line of the console.
 
<span style="font-weight: normal;"><u>Data Source</u></span>
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DataSource''.
 
Simulation data source used to allow the component to connect to various remote devices
 
     Nothing - Simulation data is ignored
 
     COM port - Routes the communication data to and from a physical or virtual COM port  
 
    Injector - Routes the communication data via a data injector component on the Panel.

Revision as of 20:34, 16 November 2021

Author Matrix Ltd.
Version 2.0
Category Comms: System


MIDI component

Low level routines for controlling or interacting with a standard MIDI interface.

Detailed description

No detailed description exists yet for this component

Examples

Basic example to play a series of notes getting higher in pitch and then going down in pitch. This repeats in a loop and each time the loop repeats the instrument is changed. The current note and instrument are displayed on the LCD. MIDI Test File


The MIDI component during simulation has functionality to allow it to work with MIDI synthesizers installed on your PC.

To select your software or hardware synthesizer select from the property selector.


If you don't have a MIDI interface installed then IP MIDI seems to be a good option that works well.

Once installed the MIDI output should play through your computer speakers.


The console window can be used to view the MIDI data as it is sent out and received.


The MIDI component during embedded operation will communicate using a UART serial channel. An EB021 MIDI E-block is available to allow standard MIDI cables to be connected up to a system.

Downloadable macro reference

SendMIDI
Sends a MIDI packet consisting of up to three bytes of information, 
- BYTE Status
MIDI Status Byte - Used for commands such as NoteOn, NoteOff etc. 
- BYTE Data1
MIDI Data Byte - Used as a parameter specific to the specified command 
- BYTE Data2
MIDI Data Byte - Used as a parameter specific to the specified command 
- VOID Return


SendPitchChange
Sends out a pitch change command on the specified channel. 
- BYTE Channel
Channel to send the pitch change to 
- UINT Pitch_Change
New pitch value to use, Default 0x2000 
- VOID Return


SendNoteOff
Sends a note off command using the channel, note and velocity specified. 
- BYTE Channel
 
- BYTE Note
 
- BYTE Velocity
 
- VOID Return


SendControl
Sends a control command using the channel, controller and value specified. 
- BYTE Channel
 
- BYTE Controller
 
- BYTE Value
 
- VOID Return


SendNoteOn
Sends a note on command using the channel, note and velocity specified. 
- BYTE Channel
 
- BYTE Note
 
- BYTE Velocity
 
- VOID Return


ReceiveMIDI
Waits for the time specified in the timeout parameter for an incoming MIDI message. Returns 0 to indicate a timeout, otherwise returns the first value from the MIDI message.  
- BYTE Timeout
 
- BYTE Return


SendPolyPressure
Sends a note press with an associated polyphonic pressure value. 
- BYTE Channel
 
- BYTE Note
 
- BYTE Pressure
 
- VOID Return


ReadData
 
- BYTE Idx
 
- BYTE Return


SendPatch
 
- BYTE Channel
 
- BYTE Instrument
 
- VOID Return


SendChannelPressure
 
- BYTE Channel
 
- BYTE Pressure
 
- VOID Return


Initialise
Initialises the MIDI component and sets up the UART. 
- VOID Return


CommsBaud
Sets the Baud rate of the alt communications channel 
- BYTE Baud
Range: 0-7 : 0=1200 / 7=115200 
- VOID Return


LCDOptions
Controls some of the LCD options 
- BYTE Foreground
Range: 0-1 
- BYTE Background
Range: 0-1 
- BYTE Transparent
Range: 0-1 
- VOID Return


LCDVerbose
Controls the Verbose mode. When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required. 
- BYTE Mode
Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode 
- VOID Return


ReadDigitalInput
Reads a single digital input. 
- BYTE Channel
 
- BYTE Return


PWMConfig
Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 : 0=1:1 1=1:8 2=1:64 3=1:256 
- BYTE Channel
Range 0-1 
- UINT Period
Range: 0-65535 
- BYTE Scaler
Range: 0-3 
- VOID Return


PWMEnable
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
- BYTE EnableMask
Range 0-63 or 0b00000 to 0b111111 
- VOID Return


PWMDuty
Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535 
- BYTE Channel
Range 0-5 
- UINT Duty
 
- VOID Return


LCDCursor
Sets the cursor position for the MIAC display 
- BYTE X
Range: 0-21 
- BYTE Y
Range: 0-4 
- VOID Return


WriteTran
Allows a single transistor output to be switched on or off. 
- BYTE Channel
Range 1-4 
- BYTE Value
0 = Off, 1 = On 
- VOID Return


Initialise
 
- VOID Return


LCDClear
Clears the MIAC display 
- VOID Return



Property reference

Properties
Connections
Channel
UART Channel selector Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels. Hardware channels use the selected peripheral on-board the target microcontroller. 
Baud Options
Baud rate option selector 
Baud Rate
 
Use TX
Selects if the Transmit pin is used by the component. Yes: The TX pin is active and used to transmit data for the UART. No: The TX pin is disabled and free to be used as general I/O. 
TX
Pin to be used for Transmit data 
Use RX
Selects if the Receive pin is used by the component. Yes: The RX pin is active and used to receive data for the UART. No: The RX pin is disabled and free to be used as general I/O. 
RX
Pin to be used for Receive data 
Use Flow Control
Flow Control (Handshake) enable or disable. On: Two I/O pins are used to control the flow of data in and out of the device. Off: Flow control is disabled. 
RTS
Pin to be used for Request To Send handshake function Output from target micro to inform remote device we are ready to receive data. Low = Ready to receive data High = Not ready to receive data 
CTS
Pin to be used for Clear To Send handshake function. Input to target micro to inform when the remote device is ready to transmit data. Low = Ready to transmit data High = Not ready to transmit data 
Simulations
Label
 
MIDI Output
Decides if we are using special MIDI output or standard Serial/API Output. Yes: We send the simulation data via a MIDI interface. No: We send the simulation data via the standard COM/API interface. 
MIDI Port
 
Scope Traces
Selects if the scope traces are automatically added to the data recorder window or not. Simulation - draws an approximation of the UART data onto the scope trace. ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD. 
Console Data
Selects if the console data is automatically generated or not 
Console Columns
Number of characters that can be displayed on a single line of the console. 
Data Source
Simulation data source used to allow the component to connect to various remote devices Nothing - Simulation data is ignored COM port - Routes the communication data to and from a physical or virtual COM port Injector - Routes the communication data via a data injector component on the Panel.