> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magicfox.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Virtual Patch Change Script

The [Virtual Patch Change script](https://magicfox.co/pages/mainstage-scripts) allows you to trigger a patch change by playing any note on your keyboard. Because the script works on a separate, alias-able channel strip, each patch can have a different trigger note. Unlike assigning a foot switch to a note on the keyboard, the script still allows the trigger note to play. [Click here for instructions](/articles/scripter/scripter-main) on how to install this script.

<Danger>
  If MainStage is not properly configured, your computer can very easily end up in an infinite loop of MIDI messages, and MainStage and/or your computer will freeze. Be <u>very</u> careful to set these settings correctly, and **save your concert** before starting.
</Danger>

## Configuration

<Steps>
  <Step title="Open MIDI Studio">
    1. Open your computer’s **Audio MIDI Setup** app (found in Applications/Utilities, or by clicking the “Setup” button in the MIDI tab of MainStage’s preferences window). (If the **MIDI Studio** window doesn’t immediately appear, choose **Show MIDI Studio** in the Audio MIDI Setup’s Window menu.)
  </Step>

  <Step title="Open the IAC Driver Properties">
    Double-click **IAC Driver** to open the IAC Driver Properties window.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/macos-midi-iac-driver-properties.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=b9613ec687b10f33ef67b3333d709519" alt="Macos Midi Iac Driver Properties Pn" title="Macos Midi Iac Driver Properties Pn" style={{ width:"50%" }} className="mx-auto" width="508" height="545" data-path="images/documentation/macos-midi-iac-driver-properties.png" />
  </Step>

  <Step title="Add port">
    Make sure **Device is online** is enabled. **Add a port** and rename it to “Virtual Patch Change”. Click “Apply” and quit the Audio MIDI Setup app.
  </Step>

  <Step title="Disable sending unused program changes">
    Choose `File > Concert Settings` or click on the concert item in the Patch List to select it. In the **MIDI** tab of the **Concert Settings**, disable the option to send unused program changes to channel strips.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-concert-settings-midi-tab.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=e9f9401a2b3fcff19a7e100a888ca966" alt="Main Stage Concert Settings Midi Tab Pn" className="mx-auto" style={{ width:"60%" }} width="558" height="292" data-path="images/documentation/MainStage-concert-settings-midi-tab.png" />

    Then, switch to the **Assignments & Mappings** tab.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-select-concert-assignments-mappings-tab.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=7d836c7cb3ea2cbe72961021a4eb3c34" alt="Main Stage Select Concert Assignments Mappings Tab Pn" className="mx-auto" style={{ width:"100%" }} width="966" height="193" data-path="images/documentation/MainStage-select-concert-assignments-mappings-tab.png" />
  </Step>

  <Step title="Add new assignment">
    Add a new assignment at the concert level. Click the assignment in the list to open the popover and set the following values:

    | Setting       | Value                           |
    | :------------ | :------------------------------ |
    | Device        | Virtual Patch Change IAC Driver |
    | Channel       | Channel 1                       |
    | Type          | Single Value                    |
    | Number        | *85 (Ctrl 85)*                  |
    | MIDI Thru     | Do not pass through             |
    | Send Value to | None                            |
    | Name          | Virtual Patch Change            |

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-hardware-input-assignment-popover.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=a52a9937b3ceee74db82dcd5bf504d13" alt="Main Stage Hardware Input Assignment Popover Pn" title="Main Stage Hardware Input Assignment Popover Pn" className="mx-auto" style={{ width:"50%" }} width="323" height="327" data-path="images/documentation/MainStage-hardware-input-assignment-popover.png" />

    <Info>
      Of the 128 [MIDI control change numbers](https://midi.org/midi-1-0-control-change-messages), most are associated with specific functions (for example, 64 is used for the sustain pedal). A handful of numbers, such as 85, are left undefined for exactly this sort of purpose. You can set this to another number as long as it matches the number specified in the Scripter window.
    </Info>
  </Step>

  <Step title="Set mapping">
    With the new assignment selected, change the mapping from None to **Actions > Next Patch**.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-control-inspector-mapping-next-patch.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=af2132c1dfeafd88494429f3fdaa1be1" alt="Main Stage Control Inspector Mapping Next Patch Pn" title="Main Stage Control Inspector Mapping Next Patch Pn" className="mx-auto" style={{ width:"80%" }} width="678" height="300" data-path="images/documentation/MainStage-control-inspector-mapping-next-patch.png" />
  </Step>

  <Step title="Add external instrument channel strip">
    Select the patch where you want to use the script. Add an **external instrument channel strip** and name it "VPC".
  </Step>

  <Step title="Set the channel strip's output">
    Set the **MIDI Output** of the VPC channel strip to **None**. (We'll change this again in **Step 11**. Setting it temporarily to None helps to avoid accidental infinite MIDI loops.)

    Set the channel strip's audio output to "No Output".
  </Step>

  <Step title="Set the channel strip's range">
    Using the **Layer Editor**, set the range of note(s) that you want to use to trigger the patch change.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-channel-strip-editor-layer-editor-range.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=d6f03e15f5f29e4970f401115f50a884" alt="Main Stage Channel Strip Editor Layer Editor Range Pn" title="Main Stage Channel Strip Editor Layer Editor Range Pn" className="mx-auto" style={{ width:"60%" }} width="400" height="260" data-path="images/documentation/MainStage-channel-strip-editor-layer-editor-range.png" />
  </Step>

  <Step title="Add the Scripter plug-in">
    Click the **MIDI FX** button on the channel strip and choose the **Scripter** plug-in. The Scripter window will open. Click the drop-down menu ("Factory Default") and select "MFT Virtual Patch Change NC".

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MagicFox-virtual-patch-change-script.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=79687909fb2c748a8d480b066b1741a1" alt="Magic Fox Virtual Patch Change Script Pn" title="Magic Fox Virtual Patch Change Script Pn" className="mx-auto" style={{ width:"60%" }} width="472" height="374" data-path="images/documentation/MagicFox-virtual-patch-change-script.png" />

    <Info>
      The MIDI control number must match the number you set in **Step 5**.
    </Info>
  </Step>

  <Step title="Set the channel strip's MIDI output">
    Change the **MIDI Output** of the VPC channel from None to **Virtual Patch Change IAC Driver** and set the **Channel** to 1.

    <img src="https://mintcdn.com/magicfox/IQdG2at1jThJh_Be/images/documentation/MainStage-channel-strip-midi-output-channel.png?fit=max&auto=format&n=IQdG2at1jThJh_Be&q=85&s=2a12ab87050f782b11327a0c50aa3ce7" alt="Main Stage Channel Strip Midi Output Channel Pn" className="mx-auto" style={{ width:"35%" }} width="258" height="230" data-path="images/documentation/MainStage-channel-strip-midi-output-channel.png" />
  </Step>
</Steps>

Congratulations! If you followed all of the steps above, MainStage should advance patches when you play a key within the range you set in **Step 9**.

<Warning>
  To additionally prevent infinite MIDI loops, make sure to assign all other screen controls (e.g., keyboards, pedals, foot switches, buttons, etc.) to a specific MIDI device.
</Warning>

<Tip>
  You can alias this channel strip and use it in different patches and with a different note range.
</Tip>

## Parameters

`Send After`  Specifies whether the patch change should happen after the note is pressed or released.

`MIDI Control Number`  The [control change number](https://midi.org/midi-1-0-control-change-messages) that should be sent when the script is activated.

`Change Delay`  The delay in milliseconds before the control change is sent.
