Selecting an object: (not sure if correct. This selects the object in the scene, not sure about if it's for applying modifiers to) we want “Browse object to be linked”
After Parsing csv file, determine the channels and allow for selection
Listen To:
code
In each Channel, allow for selection of one specific note/percussion instrument
Apply To:
code
Select object or armature to use, whichever was entered
Use Animation:
code
Select action from the selected object's Action Editor
Actions can be Object location/rotation/scale, Armature animation, or shader nodetrees (useful for lasers)
Offset frames:
code
In the action editor, apply the entered amount as a translation in frames, for example: if -38 was entered, shift the selected object’s animation 38 frames backwards.
Alternate:
code
By numbering each note chronologically, 1,2,3... select two blender channels, one for the odds and one for the evens. This could be expanded to alternate between more than two.
Extra note:
If a note is hit again before its animation is finished, duplicate the object, clear its animations and put the second animation there, to prevent overlap. Possibly use that object multiple times instead of duplicating each time. This issue could probably be solved if we used alternation between two objects per channel. This is especially noticeable with the drums, seeing as they will most likely be hit more than once per animation cycle.
Functionality: read action lengths of each object. Attach framecount variable to each object. Whenever the note is played, check that many frames and under to determine if duplicates exist. For example, Bass4 has a framecount of 72, so when it’s played in the csv, check between frame +0 and frame +72, if there is another of the same note, trigger the duplication/alternation.
Resting:
code
For example, an armature (bones but acts the same way as objects do in the action editor) would be used, let’s take the robot from starship groove. Each unique note it hits would be a separate animation (13 actions total), which is implemented, however the transition between them is not. User will create an action for resting (1 frame. Do a check to make sure that it is 1 frame). If resting is checked, there’ll be a resting threshold that determines to amount of frames in between the played animation and the resting frame. Let’s say we hit two notes right after each other and we give it a resting threshold of 10 frames.
Apply a transition strip during the threshold (https://docs.blender.org/manual/en/dev/editors/nla/strips.html#transition-strips)
||||||||||||..........|...............|..........|||||||||
Note Animation Resting Threshold Resting Action Empty Frame
If the resting threshold exceeds the amount of frames available (threshold*2 +1), take an average of the first and last frames of each animation use that frame, round up if not a whole number.
||||||||||......|......|||||||||
Resting is applied after the initial application of animations to avoid overlap.
Apply:
code
Bake all notes to actions, use progress bar at the top for added debug
Refresh:
code
Delete all actions and rebake
Workflow:
Setup
Select midi files
If first note is not at tick 0, subtract that number from all ticks.
Do tick to frame conversion and round to the nearest whole #
Parse midi files to allow selection of channels and notes (record which channel #s are active and what note #s are active)
Convert Active Numbers to Letter Notes, 36 = C
Select channels, notes.
Allow for renaming of active Channels to instrument names
Select objects to apply them to.
Select NLA actions to apply to objects.
Set offset for each one.
Start at frame 0 in midi
Start at frame 0 in blender bpy.context.scene.frame_set(0)
Attach note variable and animation variable to each object
Each channel in blender contains:
Csv instrument identifier
Csv Note identifier
Main Loop:
Go to next frame that has midi action
Set that frame in blender bpy.context.scene.frame_set(whatever that number is)
Find what channel it’s on
Find What note it is
Based on the note and what was entered in setup, select the object that corresponds to the note using bpy.data.objects['ENTEREDOBJECTNAME'].select = True
Whatever the offset entered in setup was, take the current frame and add the offset to it using bpy.context.scene.frame_set(whatever that number is)
Using the Action entered in setup, apply the action to the selected object bpy.ops.nla.actionclip_add(whatever the user selected in setup)
Resume to non-offset frame
Move to next active frame in Midi
Move to same frame in blender bpy.context.scene.frame_set(whatever that number is)
Repeat until last Midi frame has been completed
CLEANUP:
If we want NLA animations to interpolate, we need to bake them to frames (NLA: Bake Action)
Here comes the cleanup part:
run through all animations that interpolate, and delete the keyframes on the frame before each action. For example if an animation plays from frame 6 to 10 and another plays from 12 to 14, delete keyframes 5 and 11.
Rendering:
code
Cycles Filmic with denoise. 64 or 128 samples
Local rendering: ~5 Days for 7777 frames
Sheep-it rendering: 2.5 days and under, reported up to 40x speedup meaning a 3 hour render
import csv
with open('eggs.csv', 'rb') as csvfile:
... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
... for row in spamreader:
... print ', '.join(row)
Top of file: @ tick (time to trigger), channel (channel to look in), note (note in that channel to hit
Ex.: 32, 0, 36
Esse texto e código descrevem um sistema/ferramenta para converter dados de arquivos MIDI em animações no Blender usando a funcionalidade NLA (Non-Linear Animation). Em outras palavras, o objetivo é sincronizar animações dentro do Blender com eventos musicais baseados em notas MIDI.
O que isso faz no geral?
Lê um arquivo MIDI, convertendo-o em CSV para facilitar o processamento
Interpreta os eventos musicais (notas, canais, tempo)
Permite mapear cada nota/instrumento MIDI para uma animação específica (Action) dentro do Blender, associada a objetos ou armaturas
Aplica essas animações nos objetos/alvos selecionados em determinados quadros (frames) do Blender, de acordo com o momento da música (tempo das notas no MIDI)
Permite realizar offsets nos frames para ajustar temporização
Evita sobreposição de animações para a mesma nota duplicando objetos, ou alternando entre múltiplos objetos para uma mesma nota repetida rapidamente (exemplo: baterias que repetem a batida)
Suporta animações de "repouso" entre notas para suavizar transições usando strips de transição no NLA
Realiza limpeza e bake das animações no Blender para produzir uma animação final interpolada e pronta para renderização
Possui interface para seleção de canais, notas, objetos, ações, e configurações diversas
Para que serve isso?
Essa ferramenta serve para criar animações sincronizadas com música, onde cada evento sonoro (nota MIDI) controla uma animação ou um comportamento específico no Blender. Por exemplo:
Animações faciais sincronizadas com uma melodia
Movimentos de robôs ou personagens ativados por batidas ou notas
Animação procedural de objetos sincronizados com percussão, melodia, ou qualquer dado MIDI
Animações de efeitos visuais como lasers controlados por notas ou ritmo
Facilita processos para vídeos musicais, visualizações de áudio, performances digitais etc.
Como funciona (Workflow simplificado):
Importar arquivo MIDI (convertido em CSV)
Interpretar eventos: encontrar canais, notas e tempos
Associar canais/notas a objetos no Blender e suas animações (ação NLA)
Definir offsets, transições e formatos especiais (duplicação para notas repetidas)
Executar um loop que avança quadro a quadro, aplicando a animação no objeto certo conforme a nota toca
Após terminar, fazer bake e limpeza para animação fluida
Renderizar animação final sincronizada com música
Recursos citados:
APIs do Blender para automação da NLA
Vídeos tutoriais demonstrando o processo
Scripts e componentes para abrir arquivos CSV por interface python no Blender
Exemplos para seleção de objetos, aplicação de modificadores, manipulação de ações NLA
Em resumo
É uma ferramenta automatizada que transforma eventos de música MIDI em animações sincronizadas dentro do Blender usando seu sistema NLA.
Se você tem uma melodia ou base MIDI, você pode associar cada nota para disparar uma animação diferente num objeto/armatura, que pode ser expressão, movimento ou até efeitos especiais, e criar uma animação integrada com a música automaticamente.
Se quiser, posso ajudar a entender alguma parte específica, como o código python para importar, adicionar ações no NLA, ou configurar a sincronização. Quer?
Claro! Atualmente, no GitHub existem alguns projetos que fazem integração ou conversão de MIDI para animação no Blender, ou que ajudam a controlar animação com música/MIDI. Vou listar alguns repositórios ou ferramentas similares que podem ser úteis, com uma breve descrição:
Projetos no GitHub que fazem algo parecido (MIDI → Blender Animation):
Descrição: Controla propriedades e armatures no Blender em tempo real usando teclado MIDI. Não exatamente para conversão batch, mas útil para controle interativo midi → animação.
midi2frame-converter (em Python, para converter ticks MIDI → frames Blender):
Não é um repositório específico, mas vários scripts Python abrem o midi com mido e convertem ticks em frames.
Dicas para procurar no GitHub:
Buscar por palavras-chave: blender midi animation, midi blender addon, midi to nla, blender music animation
Filtros de linguagem: Python (porque Blender addons são feitos em python)
Buscar na Blender Artists (fórum) por scripts links para addons/midi/blender
Conclusão
Para um pipeline como o que você mostrou, o projeto pyblend-animidi é provavelmente o mais próximo do que você busca no GitHub, e pode ser expandido para suas necessidades.
Se precisar posso ajudar indicando exemplos de código Python para importar CSV MIDI ao Blender, aplicar ações na NLA, fazer duplicações etc., ou ajudar a integrar algum desses repositórios ao seu projeto.