📡Midi Receiver

Live input from a computer keyboard or MIDI device

Midi Receiver listens for midi input from an external device. This can be used to synchronize visuals with live played music or using a midi controller.

Please be advised that for MIDI device support, this behavior requires one of the 3rd party plugins for Unity, either Minis or MIDI Jack. Timeflow is not affiliated in any way with these plugins other than implementing the input that it provides. Axon Genesis is not responsible for its performance or any issues that may occur while using it.

Live MIDI input varies by platform. Please refer to the documentation for the MIDI plugin you choose to use for a list of supported platforms and devices.

To add a Midi Receiver, select from the main menu:

Tools > Timeflow > Add > Midi Receiver

Or right-click an object in the Timeflow view and select:

Add > Midi > Receiver

If neither MIDI Jack or Minis are installed, Midi Receiver displays a warning in the Inspector.

Setup Instructions

Please refer to the following pages for step-by-step instructions to install and configure either Minis or MidiJack. Minis is the newest and preferred solution, while MidiJack is offered for legacy support.

🎛ī¸Minis Setup (New Input System)đŸšĨMidiJack Setup (Legacy Input)

Midi Receiver Editor

Select the object to view its settings in the Inspector.

For common features, please see Menu Bar and Update Settings.

MIDI Jack only works during runtime so it is necessary to enter play mode to receive any midi input. Click 'Enter play mode for input' to enter play mode in the editor.

Save

Saves the current configuration to the PlayerPrefs.

Load

Loads the configuration from the PlayerPrefs.

If a configuration is saved and then the PlayerPrefs Name is changed, the configuration will need to be saved again under the new name. This also may result in the old settings remaining in PlayerPrefs. This doesn't hurt anything but you may want to clear the settings with the old name first before setting a new name, using Erase Configuration.

Auto

If enabled, the configuration is automatically loaded and saved on Awake and Destroy, respectively. Changes are not saved until unloaded or the Save button is pressed.

If Auto is enabled, new midi mappings assigned at runtime are automatically saved and restored the next session. This option is preferred when custom mappings are allowed.

Map

You must enter play mode to use the Map feature.

Upon entering play mode, the current configuration is loaded and Midi Receiver is awaiting midi input to react to the control it is currently mapped to.

To assign a new midi input, press Map to enter listening mode.

The first input detected from any key, knob, or fader is captured and mapping mode ends.

The last received midi note is displayed in the menu bar, as shown above. This can be useful to see which note is being played currently (regardless of mapping). However, please note that the Inspector window does not always repaint. A simple workaround is to move the mouse over the menu bar to make it update.

Mapping Using Scripts or Events

MIDI mapping can be set at runtime by using a UnityEvent (using a UI Button or other input) as well as controlled by custom script. There are 3 methods in MidiReceiver:

  • StartMapping() : Begins listening for the first MIDI input, which when detected is assigned and automatically stops listening.

  • StopMapping() : Cancels or interrupts the listening process, making no change to the existing/prior mapping.

  • ToggleMapping() : Starts or stops the mapping process. This method is best used with buttons or toggle switches.

Configuration

Input

Select the input channel (1-16) to receive midi signals.

To see data being received via a midi device, select from the main menu:

Window > MIDI Jack

Note

Select whether the input control is a Note (key on a keyboard) or a Knob (a fader or twist knob).

When using a knob or fader as input, it's range is mapped to the output value for full manual control using the device. Using a note for input, on the other hand, plays and holds the note according to the ADSR settings.

All Octaves

This option is available for note types only. When enabled, notes played are treated the same across all octaves. For example, if you map the note C, it will be triggered when C is played in any octave.

Program Button

This is an optional UI button to allow users to map midi input during runtime. When the button is pressed, it puts Midi Receiver into listening mode and captures the first midi note or knob touched.

PlayerPrefs Name

This defines the basename for PlayerPrefs values to store and retrieve the midi input configuration for this Midi Receiver. By default this name matches the game object name but may be changed if desired. This saves several values into the PlayerPrefs starting with the basename.

Erase Configuration

This removes the values from the PlayerPrefs based on the current name entered. Use this to clear out old settings before renaming a setting.

To inspect and edit PlayerPrefs, get the free Unity plugin PlayerPrefs Editor.

QWERTY Input

When this option enabled, standard keyboard input can be used to trigger events in lieu of MIDI.

Key Code

The key code can be selected manually in the inspector by using the dropdown menu, or in play mode you can enter mapping mode (press the Map button) to listen for the first key pressed.

Each mapping can have both MIDI and keyboard input. Mapping mode is automatically stopped with each input detected, but you can run Map twice: once to set a MIDI note, and again to set its keyboard equivalent.

Use Any Key

If enabled, no mapping is required and any key on the keyboard will cause MidiReceiver to trigger.

Using the keyboard as input allows MidiReceiver to be used without any MIDI devices and does not require MidiJack or Minis.

Note Processing (ADSR)

Notes are processed using an ADSR envelope (Attack, Delay, Sustain, Release). Please refer to the glossary for an explanation of ADSR.

Please refer to the documentation for Midi Tween for

of these settings.

Instant

If enabled, the midi note immediately triggers this behavior when pressed.

Unlike Midi Tween which has the ability to anticipate the note attack, with live midi input there is no possibility to predict when a note will be played. To avoid introducing latency (a delay from the note being played to seeing it visually) it is recommended to use Instant mode.

For any effect that comes on gradually, turn off Instant and set the Attack (time in seconds) desired. This could be good for lighting or anything that fades on.

Property Mapping

Map To

Midi input may be mapped directly to a property or to control Midi Tween, Tween

Property

Maps directly to a property.

This works identically to Midi Tween, replicated in Midi Receiver to simplify the setup for basic use. However, either Tween or Midi Tween may be used for additional control.

Tween / Midi Tween

Assign an instance of Tween or Midi Tween to control. Use the Amount slider to blend the influence of the live received midi over the current behavior.

Using Midi Tween, it is possible to combine input from a Midi File with live midi input using Midi Receiver, essentially adding the live signal in with the prerecorded midi. This depends on the Remote Control Pass Thru setting of Midi Tween.

Trigger Only

When this mode is selected, midi input only triggers the Events (registered below) and does not apply directly to any property. Use this mode to pass live midi note values to a custom script.

Events

Unity Events may be used to propagate note on/off events to drive other behaviors. This could be used to trigger particles, animations, or custom scripts. The value passed to these events is the note intensity (velocity), which may be used or ignored by the registered event listeners.

Troubleshooting

Is Midi Supported?

Please be aware that midi support may vary depending on your computer or device.

No Midi Received?

Most often, only 1 program may receive midi messages, blocking other applications from receiving messages. If you are running Unity with MIDI Jack while also running audio software that uses midi, it may block MIDI Jack from receiving signals. This is something that will need to be tested on your setup, however to test midi input it is advised to close other applications that might interfere with receiving midi signals.

Still No Midi Input?

To verify that your device and computer are communicating, you may want to try using a 3rd party application to diagnose midi signals, such as Midi View:

https://hautetechnique.com/midi/midiview/

Be sure to close Unity and all other applications to test midi input.

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.

If you see this error message during play mode, it means you are using the wrong type of Event System for the current input configuration. To fix this please refer to the example scene for the correct setup:

Assets/AxonGenesis/Timeflow/Examples/Scenes/AudioMidi/MidiReceiver_InputSystem

Last updated