Jump to content

Component: MIDI (Comms: System)

From Flowcode Help
Revision as of 15:16, 20 January 2023 by Wiki bot (talk | contribs)
Author Matrix Ltd.
Version 2.0
Category Comms: System


MIDI component

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

Component Source Code

Please click here to view the component source code (Beta): FC_Comp_Source_MIDI.fcfx

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.

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



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 
Simulation
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. 

==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



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 
Simulation
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.