Component: MIDI (Comms: System)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd.
Version 2.0 (Release)
Category Comms: System


Image MIDI component

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

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. FC6 Icon.png MIDI Test File MidiDemoRun.jpg


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.

MidiSim.jpg


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.

MIDI1.jpg


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,

Parameters

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


Return value

This call does not return a value


SendPitchChange

Sends out a pitch change command on the specified channel.

Parameters

BYTE Channel
Channel to send the pitch change to
UINT Pitch_Change
New pitch value to use, Default 0x2000


Return value

This call does not return a value


SendNoteOff

Sends a note off command using the channel, note and velocity specified.

Parameters

BYTE Channel
BYTE Note
BYTE Velocity


Return value

This call does not return a value


SendControl

Sends a control command using the channel, controller and value specified.

Parameters

BYTE Channel
BYTE Controller
BYTE Value


Return value

This call does not return a value


SendNoteOn

Sends a note on command using the channel, note and velocity specified.

Parameters

BYTE Channel
BYTE Note
BYTE Velocity


Return value

This call does not return a value


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.

Parameters

BYTE Timeout


Return value

BYTE


SendPolyPressure

Sends a note press with an associated polyphonic pressure value.

Parameters

BYTE Channel
BYTE Note
BYTE Pressure


Return value

This call does not return a value


ReadData

No additional information


Parameters

BYTE Idx


Return value

BYTE


SendPatch

No additional information


Parameters

BYTE Channel
BYTE Instrument


Return value

This call does not return a value


SendChannelPressure

No additional information


Parameters

BYTE Channel
BYTE Pressure


Return value

This call does not return a value


Initialise

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

Channel

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::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

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::BAUD_LIST.

Baud rate option selector

Baud Rate

This property is of type Signed integer and can be referenced with the variable name cal_uart::BAUD.

No additional information


Use TX

This property is of type True or false and can be referenced with the variable name cal_uart::UseTX.

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

This property is of type Single digital pin and can be referenced with the variable name cal_uart::TX.

Pin to be used for Transmit data

Use RX

This property is of type True or false and can be referenced with the variable name cal_uart::UseRX.

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

This property is of type Single digital pin and can be referenced with the variable name cal_uart::RX.

Pin to be used for Receive data

Use Flow Control

This property is of type Fixed list of ints and can be referenced with the variable name cal_uart::FLOWEN.

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

This property is of type Single digital pin and can be referenced with the variable name cal_uart::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

This property is of type Single digital pin and can be referenced with the variable name cal_uart::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

Label

This property is of type Line of text and can be referenced with the variable name label.

No additional information


MIDI Output

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.

Scope Traces

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.

Console Data

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

Console Columns

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.

Data Source

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.