MCPcopy Index your code
hub / github.com/Cornerback24/Blender-NLA-Midi-Copier

github.com/Cornerback24/Blender-NLA-Midi-Copier @v1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.0 ↗ · + Follow
681 symbols 1,643 edges 39 files 84 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Blender NLA Midi Copier

Blender extension for creating midi-driven animations from the Nonlinear Animation view. Adds a panel to the Nonlinear Animation view that allows for copying an action to each instance of a note in a midi file. For example, actions strips for a selected action could be generated to line up with all the C4 notes played by a piano. To access the panel, expand the right-side panel in the Nonlinear Action View and select the Midi tab.
This extension also adds a panel in the Graph Editor to generate keyframes on existing F-Curves based on midi file data.

This extension is written for Blender 5.0 and is compatible back to Blender 4.2. An add-on version compatible with Blender versions from 2.80 to 4.2 can be found here. Extension Version 1.2.0. Changelog here.

Midi Panel

Midi Panel controls:

Midi Panel

  • Choose midi file:
    • Select a midi file.
  • Midi File:
    • Displays the selected midi file.
  • Track:
    • Choose a track from the midi file. (Tracks with no notes will not be shown.)
  • Note:
    • Choose a note from the selected track. (Only notes played in the selected track will be shown.) A note can also be selected by typing a note name or midi note number in the box next to the drop-down.
  • Type:
    • The type of object to animate. Select "Object" to animate objects in the scene. Change this value to animate something other than an object. For example, select "Light" to animate the brightness of a light.
  • Object:
    • The object to animate. This field will change depending on the value of Type. If Type is Object, this field will allow selecting an object, if Type is Light, this field will allow selecting a Light, ect.
  • Action:
    • The action to generate NLA Strips from. Only actions valid for the selected Type will be shown.
  • Copy Action to Selected Objects:
    • If this option is selected, then the selected objects will be animated instead of the Object in the Object control. This option is only valid for Type Object, Type Material, or any type that can be object data (such as Mesh and Curve). If the type is Material, the action wll be copied to the active materials of the selected objects.
  • Sync Length with Notes
    • If selected, the length of the copied action will be scaled to match the length of the note it is copied to multiplied by the scale factor.
    • Action Timing
      • Scale Action Length
      • Stretch or compress the action to fit the scaled NLA strip.
      • Repeat
      • Repeat the action to fill the scaled NLA strip. Truncates the action if the action is longer than the NLA strip.
    • Scale Factor
      • Affects the length of actions when "Sync Length with Notes" is selected. The copied action length will be equal to the length of the note multiplied by this scale factor. (Scale factor of 1 will match the note length exactly.)
  • Copy to Note End
    • Copies the action to the end of the note instead of the beginning.
  • Add filters:
    • Adds filters. If selected, any defined filters will be applied when copying actions. No filters will be applied if this option is not selected. See the Filters section for more information about filters.
  • Overlap
    • Options for how to handle overlapping action strips.
    • Skip
      • Skip overlapping actions.
    • Blend
      • Place overlapping actions on a new track above the existing action.
    • Duplicate Object
      • Place overlapping action strips on new objects that are duplicates of the original object being animated. This option is only valid for Type Object or any type that can be object data (such as Mesh and Curve). If the type is not Object, then all objects using the data will be duplicated. For example if the action is defined on a Curve, all objects using the Curve will be duplicated.
  • Blending
    • Sets blending type for action strips placed on additional nla tracks if the first nla track does not have room for the action. Only used when Overlap is set to Blend.
  • Action Length (Frames):
    • The length of the action. Used to determine if the action overlaps another action when duplicating objects. Defaults to the true length of the action. As an example, if this is set to 50 frames, and two notes are only 30 frames apart, then the action for the second note will be considered to overlap the action. The second note's action will be copied to a duplicate object if Duplicate Object on Overlap is selected. If this value is set to less than the true length of the action, it will be replaced by the true length of the action. Only used when Overlap is set to Duplicate Object.
  • Nla Track:
    • The name of the NLA track to place action strips on. If a track with this name exists, actions will be placed on it, otherwise a new track with this name will be created. A name wil be automatically generated if this field is blank.
  • First Frame:
    • The frame that the midi file starts on.
  • Frame Offset:
    • Offset in frames to use when generating action strips (can be negative). For example, if the frame offset is -5, then the generated action strips will be placed starting 5 frames before the instances of the selected note.
  • Copy Action to Notes:
    • Generates action strips from the selected action that line up with all instances of the selected note.

Midi Instrument Panel

An instrument can be defined as a collection of notes and actions. The instrument is independent of any specific midi file, allowing for defining a set of actions for each note and later syncing them up to a midi file. To define an instrument, expand the right-side panel in the Nonlinear Action View and select the Midi Instruments tab.

Midi Instrument Panel Controls

Midi Instrument Panel

  • Instrument
    • The selected instrument.

Properties Box

  • Name
    • The name of the instrument.
  • Instrument Frame Offset:
    • The frame offset used when animating the instrument. This is added to the frame offset for each action.
  • Delete \<instrument name>
    • Delete the instrument

Notes Box

Notes Box

  • Note:
    • The selected note. If there are actions associated to the note, the number of actions will be displayed in parentheses. For example, C5 (2) indicates that there are two actions associated to the note C5. An astrix indicates than there are actions that may be copied to other notes due to pitch filters. An exclamation mark indicates there are actions that are missing an object or action, so they will not be copied.
  • Add Action
    • Adds an action for the selected note.
  • Action Boxes
    • Each action for the selected note is displayed in its own box. See the "Midi Panel Controls" section above for explanations of the controls in the action boxes.

Transpose Box

Transpose Box

  • Transpose: The transpose buttons transpose the instrument. Transpose buttons are disabled if the transposition would result in notes outside the 0-127 midi pitch range.
    • - octave: shift all actions down an octave
    • - step: shift all actions down a step
    • + step: shift all actions up a step
    • + octave: shift all actions up an octave
  • Transpose filters: Sets how the pitch filters are transposed
    • Do not transpose: Does not transpose the pitch filters.
    • Transpose if possible except all-inclusive: Transposes all pitch filters except pitch filters that include every midi pitch (pitch >= 0 or pitch <= 127). Pitch filters that would be transposed to a pitch outside the 0-127 midi pitch range are not transposed.
    • Transpose if possible: Transposes pitch filters. Pitch filters that would be transposed to a pitch outside the 0-127 midi pitch range are not transposed.
    • Transpose all except all-inclusive: Transposes all pitch filters except pitch filters that include every midi pitch (pitch >= 0 or pitch <= 127). Transpose buttons are disabled if any pitch filters would be transposed to a range outside the 0-127 midi pitch range.
    • Transpose all: Transposes all pitch filters. Transpose buttons are disabled if any pitch filters would be transposed to a range outside the 0-127 midi pitch range.

Animate Box

Animate Box

The animate instrument box is not available if there is no selected midi file. Select a midi file in the Midi Panel.

  • Track
    • The track from the midi file to use when animating the instrument.
  • Copy to single track
    • If selected, all actions for the instrument will be copied to a single NLA track (this is overwritten for any actions within that define their own NLA track). If this is not selected, a new track will be created for each note.
  • Nla Track:
    • The name of the NLA track to copy actions to if "Copy to single track" is selected. A name will be generated if this field is blank.
  • Animate \<instrument name>

    • Animate the instrument. The instrument's actions will be copied to notes from the selected track from the selected midi file. The midi file is selected in the Midi Panel, and the selected track is selected in the Track field directly above this button. The First Frame field in the Midi Panel will be used as the frame the midi file starts on.
  • Create New Instrument

    • Creates a new instrument.

Filters

Filters

Filter

Filters can be used to filter notes when copying actions. Filters are defined within a filter group. Actions are copied to notes that match any of the filter groups. For a note to match a filter group, it must match all filters within the group. For example, if group 1 has filters A and B, and group 2 has filters C and D, actions will be copied to notes that match either both filters A and B, or both filters C and D (this includes actions matching all filters A, B, C, and D).

Filter Controls

Click "Add Filter Group" to add a new filter group. Click the x in the top right of the filter group to remove it.

Click "Add Filter" to add a filter within the group. Click the x next to the filter to remove it.

If more than one filter is defined in a group, the arrows can be used to move the filters up and down. The filters are applied from top to bottom.

If "All Pitches" is selected in a filter group, the group will act on all pitches (ignoring the note selected in the midi panel or ignoring the instrument note if part of an instrument). It is always selected if any of the filters in the list are a Pitch filter.

Filter Descriptions

  • Every
    • Includes every nth note starting with a specified index. For example, "Every 2 notes, starting with note 1" will include every other note, starting with the first note.
  • Note Length
    • Filters notes by length. For example, "Note Length < 10 frames" will include only notes that have a length less than 10 frames.
  • Overlap
  • Filters notes by overlaps. Overlaps are calculated by action length in the nla editor. Overlaps are calculated by note length in the graph editor and dope sheet. If "By frames" is selected, then overlaps are calculated based on a set number of frames instead of note or action length.

    Overlap visual

  • Pitch

    • Filters notes by pitch. For example, "Pitch > B3" will include all pitches above B3 (so C3 and higher). If the pitch is "Selected" it will match the selected pitch in the midi panel, or the pitch of the instrument note if the filter is part of an instrument.
  • Relative Start Time
    • Filters notes by their start time (time is based on the beginning of the midi file). For example, "Relative Start Time > 5 Seconds" will include only notes that start after 5 seconds into the midi file.
  • Start Time
  • Filters notes by their start time in the scene.
  • Velocity
    • Filters notes by their midi velocity. For example, "Velocity = 127" will include only notes with a velocity of 127.

Filter Presets

Filter presets

Filters can be stored to presets. Saved presets can be access from the Nonlinear Animation view, Graph editor, or Dope Sheet. * Preset: Select a preset. Preset will be loaded on selection. * New: Create a new preset from the current filter. * Name: Rename the preset here. * Save: Save the preset. Presets are not saved automatically when changes are made. * Delete: Delete the selected preset.

Quick Copy Tools

Quick Copy Tools

Copy to Instrument

The Quick Copy Tools panel contains tools for copying to multiple notes at once when different objects are animated to different notes. The action defined in the NLA Midi panel can be copied to multiple objects, with a different note for each object, by ordering the selected objects along a path. The action can also be copied to an instrument (with or without copying along a path).

Copy by object name

The Copy by object name tool copies actions to objects based on the name of the object. It matches notes based on the Copy by option.

  • Copy by
  • Copy by note name
    • Copy to objects with names that either start or end with the note. For example, if one of the selected objects is A3_Cube or Cube_A3, the action will be copied to that object for all A3 notes.
  • Copy by track and note name
    • Copy to objects with names

Core symbols most depended-on inside this repo

Shape

Method 414
Class 146
Function 121

Languages

Python100%

Modules by API surface

midi_analysis/MidiEvents.py128 symbols
midi_data.py45 symbols
NLAMidiCopierModule.py45 symbols
MidiPropertiesModule.py44 symbols
GraphEditorKeyframeGeneratorModule.py36 symbols
NoteFilterImplementations.py35 symbols
MidiPanelModule.py29 symbols
PanelUtils.py25 symbols
NoteFilterModule.py25 symbols
NoteCollectionModule.py19 symbols
ActionUtils.py19 symbols
NoteCollectionUtils.py18 symbols

For agents

$ claude mcp add Blender-NLA-Midi-Copier \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page