Revision Difference
MIDI_Binding#527790
<cat>Dev.Cinematic</cat>
<title>MIDI Binding</title>
<upload src="739b0/8d833575a78b232.mp4" size="8940887" name="rust_midi_test_1.mp4" />
MIDI binding is a set of **admin-only** commands which can be used to bind MIDI notes to convars in Rust.
These MIDI bind functions can also be used during [Demo playback](https://wiki.facepunch.com/rust/Demos), in particular for cinematic-related commands.
#Getting Started
Before you can start binding MIDI inputs to convars, there are a few initial steps you will need to take.
##Enabling MIDI Convars
Use the command `midiconvar.enabled 1` to enable MIDI convar reading and writing in Rust.
This setting will be saved to your user configuration and recalled on restart.
##Debug Mode
To verify that Rust is listening to messages sent from your MIDI device, use the command `midiconvar.debugmode 1`
Once enabled, start pressing down on keys or moving knobs/sliders on the MIDI device connected to your system. The console will print out the note numbers and knob values from your MIDI device in real-time.
This command is useful for quickly identifying the note/knob number for specific keys and controllers on your MIDI device, as well as the channel number for the note values. You can then use this info to setup your MIDI convar binds.
#Convar Setup
There are two main MIDI functions which can be assigned to convars in Rust:
* Key Presses
* Knobs / Sliders
##Key Press Binds
These are also known as note on/off MIDI behaviours - for example pressing a key on a MIDI keyboard or controller device.
**Note ON** functions are indicated when a MIDI key/button is pressed down.
**Note OFF** functions are indicated when a MIDI key/button is released.
<note>In most cases you may only need to bind a single key press to a command, which is where 'note on' is useful. In other cases, you may want to bind a key release to a command to make a 'hold' key for calling commands, which is where 'note off' comes in handy.</note>
To bind these functions in Rust, use the following commands:
###NOTE ON
```
midiconvar.bindkeyon <note> <channel> <convar>
```
For example: `bindkeyon 12 1 "graphics.dof 1"` will bind Note 12 on Channel 1 to set Depth of Field to true.
This function means that when Note 12 is *pressed* on your MIDI device it will enable Depth of Field.
### NOTE OFF
```
midiconvar.bindkeyoff <note> <channel> <convar>
```
For example: `bindkeyoff 12 1 "graphics.dof 1"` will bind Note 12 on Channel 1 to set Depth of Field to false.
For example: `bindkeyoff 12 1 "graphics.dof 0"` will bind Note 12 on Channel 1 to set Depth of Field to false.
This function means that when Note 12 is *released* on your MIDI device it will disable Depth of Field.
These two *ON* and *OFF* examples together mean that Note 12 will become a 'hold' key - in other words, the Depth of Field effect (specified in the above convar parameter) will only be active whilst the note is being pressed down.
____
##Knob and Slider Binds
These are MIDI behaviours which have a value range between `0` and `1` - for example moving a slider to it's min/max.
```
midiconvar.bindknob <note> <channel> <convar> <min value> <max value>
```
For example: `bindknob 3 1 graphics.dof_focus_dist 0 50` will bind Knob 3 on Channel 1 to set the Depth of Field focus distance to range between a minimum value of 0 and a maximum of 50.
This function means that turning (or sliding) Knob 3 on your MIDI device will adjust the focus point for the Depth of Field within the range specified.
<note>If you have [debug mode](#debugmode) enabled, you can see the command along with the current knob range value printed in the console.</note>
#Additional Commands
Below are some additional commands useful for MIDI convar binding.
##Print Binds
`midiconvar.printbindings` - Prints to console a list of all the MIDI notes and knobs bound to convars.
MIDI binds are stored in the text file **convarbindings.txt** located in the ‘midi’ folder in your root game directory:
```
C:\Program Files (x86)\Steam\steamapps\common\Rust\midi\convarbindings.txt
```
##Clear Binds
`midiconvar.clearallbindings` - Removes all MIDI convar bindings.
#FAQ
##Who can use MIDI binds?
MIDI convars can only be used by admins or during demo playback.
##Will my MIDI hardware work with Rust?
Any MIDI device, such as a keyboard or controller, should work with MIDI convar binding.
If your hardware is not detected by Rust, it's likely the drivers or device itself has not been installed correctly.