Skip to content

Blender plugin to generate animation keyframes from MIDI files

Notifications You must be signed in to change notification settings

whoisryosuke/blender-midi-keyframes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIDI.to.Keyframe.-.Process.-.Creating.Keyframes.V2.Shorter.Zoom.webm

MIDI to Keyframes Blender addon

This is a free Blender addon to import MIDI files and generate animation keyframes. It assigns the keyframes to objects you assign as piano keys.

⬇️ Installation

  1. Download the plugin zip from the releases page or Blender extension marketplace
  2. Open Blender
  3. Go to Edit > Preferences and go to the Addons tab on left.
  4. Click install button.
  5. Select the zip you downloaded.
  6. You can confirm it's installed by searching for "MIDI to Keyframes" and seeing if it's checked off

🔰 How to use

The plugin panel inside Blender

  1. Open up the side panel labeled "MIDI Importer", it's available in the 3D viewport in the n-panel (the right side panel that's usually collapsed).
  2. Select a MIDI file you'd like to import.
  3. Assign 3D objects to piano keys.
  4. Click the button labeled "Generate Keyframes"

Not happy with the animation? You can undo the keyframes (CTRL/CMD + Z). Can't undo? Try the "Delete All Keyframes" button, it will delete all keyframes on any selected note object.

Tips

Auto Assigning Keys

The plugin can automatically assign piano keys if you create a collection with objects with the note letter appended to the end.

For example, you'd name your objects something like:

  • ObjectName.C maps to the C piano key
  • yourobject.F# maps to the F# piano key

Then you can select the collection and press the "Auto-Assign Keys" button.

Visualizing the MIDI Track

I'd recommend downloading Audacity to visualize the MIDI tracks and see what the note charts look like before you import them into Blender.

FPS and Music Timing

When creating the animation keyframes, we use the current scene's frame rate to calculate the music time. If you change the frame rate after generating keyframes, you should re-generate keyframes to ensure the timing is correct.

⚙️ How it works

I did a full breakdown on my blog here that covers the creation of the plugin and tips and tricks for working with MIDI in Python.

Development

  1. Clone the repo: git clone
  2. Zip up the folder.
  3. Install in Blender.
  4. Open the plugin code inside your Blender plugin folder.
  5. Edit, Save, Repeat.

Publish

  1. Bump version in __init__.py
  2. Bump version in blender_manifest.toml
  3. blender --command extension build --output-dir dist
  4. Upload the new .zip file generated inside /dist folder to Blender addon marketplace and GitHub Releases page.

On Windows? You can add blender to your command line by going to Start annd searching for "Edit Environment Variables for your account". Find the Variable "PATH" and edit it. Add the full path to where your blender.exe is located (e.g. C:/Program Files/Blender/4.2/).

Dependencies

We basically have Python PIP "wheel" files that contain dependencies we need for this addon. The manifest installs them for us. Running the build command just zips up the folder with the version name attached - nothing fancy.

If you want to update the dependencies, run these commands and then update the blender_manifest.toml with any new .whl filenames:

pip download mido --dest ./wheels --only-binary=:all: --python-version=3.11 --platform=macosx_11_0_arm64
pip download mido --dest ./wheels --only-binary=:all: --python-version=3.11 --platform=manylinux_2_28_x86_64
pip download mido --dest ./wheels --only-binary=:all: --python-version=3.11 --platform=win_amd64

Read more about the extension setup here and build process here.

💪 Credits

About

Blender plugin to generate animation keyframes from MIDI files

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages