-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluate MIDI Track overlapping envelope issue, add a "re-trigger" toggle #1820
Comments
I actually did wounder how this case of overlapping notes should be handled, I think adding an advanced option to choose the target behavior is reasonable and can be implemented. |
Great! I might be able to work on this, I've never really done dev in python, but maybe I can stumble through it. A couple questions, is there a rule in animation nodes that values are computed as demanded? If I plug frame number into evaluate midi track, with a retrigger, the only state required is the start and end time of the active note. Without retrigger, the state necessary can be many notes if there are many overlapping envelopes. One solution is to just lazy compute from first frame to current frame as values in a list, index with frame if its already computed, or add to list if not. If the retrigger is animated I guess any state can just be thrown out until retrigger is off again. Does this fit in with how animation nodes functions with state and how the evaluate function is called? |
@fabricatedmath It is okay to do pre-evaluation caching in Animation Nodes, so we may do that. However, I would say that caching might not be worth it if the performance benefit is not significant, which might be the case since MIDI evaluation is already relatively fast. Moreover, note that frame numbers can be floats, which makes caching anything with them as keys less ideal. If you are looking into possible optimizations, then doing a binary search over the notes is probably something that we can look into (We currently do a simple linear search). Anyways, most of the code of interest is in the MIDITrack class. Let me know if you need anything. |
@OmarEmaraDev Oh good to know frame number is a float I didn't realize that. I guess we could cache the note value at each noteoff message seeing as that point should already store the state from all overlapped noteon messages before it, and then interpolate from there. But i'd bet that would be pretty easy to add after the code can evaluate the whole sequence up to frame N anyway. Also, whats the workflow for an add-on like this? Is there an easy way to install the development add-on, change a .py file and try running something again? Thanks! |
@fabricatedmath In the source directory of Animation Nodes, create a
Then execute the build setup script with the
Every time you change a file, you execute the above command and the add-on will be copied to Blender. Though you have to restart Blender for changes to take effect. |
Just as an example, If you have a midi file in 4/4 with 4 consecutive C4 quarter notes and a non-zero attack, the value of the note resets to 0 before again rising in accordance with the interpolation of the attack. This is probably a good behavior to keep. However, if you map this value to a blender midi keyboard for example, the key jumps impossibly fast down before rising again. This behavior can be seen in many different ways when envelopes are overlapping.
In Ableton (as an example im familiar with) there is a parameter to toggle for things like this labelled as a "re-trigger". So if you have an LFO, and you don't retrigger, the lfo is global for all notes, if you do retrigger, the lfo restarts at t=0 for each new note. Maybe a "re-trigger" toggle can be added to this to determine if the interpolation happens with respect to the previous frames note or not? If re-trigger is 'on', that would correspond to the current "Evaluate MIDI Track" envelope behavior.
How does this sound?
The text was updated successfully, but these errors were encountered: