> For the complete documentation index, see [llms.txt](https://axongenesis.gitbook.io/timeflow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axongenesis.gitbook.io/timeflow/reference/behaviors/midi/midi-receiver.md).

# Midi Receiver

{% embed url="<https://youtu.be/wAU7kTtX_so>" %}

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.&#x20;

{% hint style="success" %}
Please be advised that for MIDI device support, this behavior requires one of the 3rd party plugins for Unity, either [Minis](https://github.com/keijiro/Minis) or [MIDI Jack](https://github.com/keijiro/MidiJack). 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.
{% endhint %}

{% hint style="warning" %}
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.
{% endhint %}

{% hint style="success" %}
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

{% endhint %}

If neither [MIDI Jack](https://github.com/keijiro/MidiJack) or [Minis ](https://github.com/keijiro/Minis)are installed, Midi Receiver displays a warning in the Inspector.&#x20;

<figure><img src="/files/RtCP4PkwfZgUtrBkqE2N" alt=""><figcaption></figcaption></figure>

## 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.&#x20;

{% content-ref url="/pages/bWIER6pzDpRvC59XEKGp" %}
[Minis Setup (New Input System)](/timeflow/reference/behaviors/midi/midi-receiver/minis-setup-new-input-system.md)
{% endcontent-ref %}

{% content-ref url="/pages/dTIr2Vs3E3wHMmgKv00j" %}
[MidiJack Setup (Legacy Input)](/timeflow/reference/behaviors/midi/midi-receiver/midijack-setup-legacy-input.md)
{% endcontent-ref %}

## Midi Receiver Editor

Select the object to view its settings in the Inspector.

<figure><img src="/files/srCNXfMSSAdvu2nLXDll" alt=""><figcaption></figcaption></figure>

For common features, please see [Menu Bar](/timeflow/user-guide/timeflow-editor/menu-bar.md) and [Update Settings](/timeflow/user-guide/timeflow-editor/update-settings.md).

## Menu Bar

<figure><img src="/files/Rl3qPw6oPmsYMIDX3jop" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
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.&#x20;
{% endhint %}

### Save

Saves the current configuration to the PlayerPrefs.

### Load

Loads the configuration from the PlayerPrefs.

{% hint style="info" %}
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](#erase-configuration).
{% endhint %}

### 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.&#x20;

{% hint style="success" %}
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. &#x20;
{% endhint %}

### Map

{% hint style="warning" %}
You must enter play mode to use the Map feature.
{% endhint %}

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.&#x20;

<figure><img src="/files/7h3ubGFNnSgjiEewzhY1" alt=""><figcaption></figcaption></figure>

To assign a new midi input, press Map to enter listening mode.&#x20;

<figure><img src="/files/YPAd6AZiiUHaaEMXVlUS" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/UuRK6OMY8Hy761wxLnkX" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
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. &#x20;
{% endhint %}

{% hint style="success" %}

### 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.
  {% endhint %}

## Configuration

<figure><img src="/files/8AttX2ASIWfjaNaPsrRD" alt=""><figcaption></figcaption></figure>

### Input

Select the input channel (1-16) to receive midi signals.&#x20;

{% hint style="info" %}
To see data being received via a midi device, select from the main menu:&#x20;

#### Window > MIDI Jack

{% endhint %}

### Note

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

{% hint style="info" %}
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.
{% endhint %}

### 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. &#x20;

### 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.&#x20;

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

<figure><img src="/files/eUnTLrnvVVkc91pWo2vj" alt=""><figcaption><p>As displayed in the PlayerPrefs Editor</p></figcaption></figure>

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

{% hint style="success" %}
To inspect and edit PlayerPrefs, get the free Unity plugin [PlayerPrefs Editor](https://assetstore.unity.com/packages/tools/utilities/playerprefs-editor-167903).
{% endhint %}

### QWERTY Input

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

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

{% hint style="info" %}
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.
{% endhint %}

#### Use Any Key

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

{% hint style="info" %}
Using the keyboard as input allows MidiReceiver to be used without any MIDI devices and does not require MidiJack or Minis.
{% endhint %}

## Note Processing (ADSR)

Notes are processed using an ADSR envelope (Attack, Delay, Sustain, Release). Please refer to the glossary for an explanation of [ADSR](/timeflow/reference/glossary.md#adsr).

<figure><img src="/files/3dKEr8JSGzykyBpOb1mJ" alt=""><figcaption></figcaption></figure>

Please refer to the documentation for [Midi Tween](/timeflow/reference/behaviors/midi/midi-tween.md#velocity) for&#x20;

of these settings.

### Instant

If enabled, the midi note immediately triggers this behavior when pressed.&#x20;

{% hint style="warning" %}
Unlike Midi Tween which has the ability to [anticipate ](/timeflow/reference/behaviors/midi/midi-tween.md#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.&#x20;
{% endhint %}

{% hint style="success" %}
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.
{% endhint %}

## Property Mapping

<figure><img src="/files/N6US9fSoX9T5FOsXVaPc" alt=""><figcaption></figcaption></figure>

### Map To

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

### Property

Maps directly to a property.&#x20;

{% hint style="info" %}
This works identically to [Midi Tween](/timeflow/reference/behaviors/midi/midi-tween.md), replicated in Midi Receiver to simplify the setup for basic use. However, either Tween or Midi Tween may be used for additional control.
{% endhint %}

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

{% hint style="info" %}
Using [Midi Tween](/timeflow/reference/behaviors/midi/midi-tween.md), it is possible to combine input from a [Midi File](/timeflow/reference/behaviors/midi/midi-file.md) 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](/timeflow/reference/behaviors/midi/midi-tween.md#pass-thru) setting of Midi Tween.
{% endhint %}

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

<figure><img src="/files/p0hBK3p9tFvtpNJg9SSa" alt=""><figcaption></figcaption></figure>

## Troubleshooting

{% hint style="warning" %}

### Is Midi Supported?

Please be aware that midi support may vary depending on your computer or device.
{% endhint %}

{% hint style="warning" %}

### 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.
{% endhint %}

{% hint style="warning" %}

### 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.&#x20;
{% endhint %}

{% hint style="danger" %}
**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
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://axongenesis.gitbook.io/timeflow/reference/behaviors/midi/midi-receiver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
