Skip to content
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

Add Velocity to Evaluate MIDI Track Node #1811

Closed
ghost opened this issue Dec 9, 2021 · 7 comments
Closed

Add Velocity to Evaluate MIDI Track Node #1811

ghost opened this issue Dec 9, 2021 · 7 comments
Labels
to-do Accepted proposal that needs to be implemented.

Comments

@ghost
Copy link

ghost commented Dec 9, 2021

It would be great to have

@OmarEmaraDev OmarEmaraDev added the to-do Accepted proposal that needs to be implemented. label Dec 9, 2021
@OmarEmaraDev
Copy link
Collaborator

Maybe we should return the index of the note instead for more flexibility.

@ghost
Copy link
Author

ghost commented Dec 9, 2021

That might work better idk, maybe the lookups will be slow?

Maybe something to keep in mind also is the new MIDI MPE standard. Typically, as you might know, pitch bend applies to the entire channel (that wobbly thing on the side of a keyboard piano). MPE has a separate note per channel, so you can get pitch bend, after touch, etc... for each note individually.

Maybe knowing there's eventually going to be more dimensions to each midi note, it might be easier to return a "MIDI Note object" in "Evaluate MIDI Track" instead of a note value?

@ghost
Copy link
Author

ghost commented Mar 12, 2022

Hey, it's been a while, but been pretty busy, finally getting settled to get started on these two features.

What do you think about having an option to have velocity multiplied into the note value? The issue would be that if you only have velocity from the node, then what do you do with velocity output as the note persists? (Edit: My bad, I think this would work just fine (envelope multiplier * note value * velocity) == velocity * (envelope multiplier * note value))

Also might be more friendly to the overlapping envelopes part. You could have a really strong heavy note followed by a light note and the state from the heavy note could still dominate the note value. (Edit: imagine holding piano pedal, slamming a note, then slightly tapping the same note again) If it wasn't multiplied in, then you'd be forced to multiply in a small velocity value to the current note value accumulation. (Edit: the second piano note would force the first to stop ringing out)

What do you think?

@OmarEmaraDev
Copy link
Collaborator

@fabricatedmath Just to clarify:

  • Is the velocity of a note generally associated with the volume at which its sound is played? And consequently associated with the levels of the note's envelope?
  • Regarding Evaluate MIDI Track overlapping envelope issue, add a "re-trigger" toggle #1820, two notes are said to overlap if the release interval of the first overlaps with the attack interval of the second? In this case, we have two options. 1) We can re-trigger by starting from zero as soon as we enter the attack interval of the second note. 2) We can take the maximum of the two intervals such that the release is continued until the attack ramps up to the same level. Is that correct?

If both of those are correct, then yes, I think adding an option to multiply the note values with the attack is reasonable.

@ghost
Copy link
Author

ghost commented Mar 12, 2022

I did a bit more digging realizing its probably more complicated. Apple does a good writeup here: https://support.apple.com/guide/logicpro/use-sampler-envelopes-lgsifc8612a5/mac

Vel slider: Set the sensitivity of amplitude envelope modulation in response to incoming velocity data.
If the Vel slider is set to zero, the envelope outputs its maximum level when you strike the keys at any velocity.

At a Vel slider value of 100%, the entire dynamic range is under velocity control.

To explain, raising the slider value reduces the envelope minimum amplitude, with the difference being dynamically controlled by keyboard velocity. For example, when you set the Vel slider to 25%, the minimum envelope amplitude is reduced to 75%. The remaining 25% is added in response to the velocities of keys you play. So, a key played with a zero velocity results in an envelope amplitude of 75%. A key played with a MIDI velocity value of 127 will result in an envelope amplitude of 100%. When you raise the Vel slider value, the minimum amplitude decreases even further.

So maybe this would be the way to go? Set a slider that modulates the sensitivity of amplitude after attack to the velocity

So I think to number 1, yes, but we can do something like that to make it up to the user

As for number 2. I looked into that also and at least when sound is output, it seems its common to just add the envelopes.

from: https://theproaudiofiles.com/synthesis-101-envelope-parameters-uses/

Second, you can control the triggering behavior in three different ways:

Poly mode — This is typical envelope behavior where each note or event triggers an independent envelope.
Mono mode — “A single envelope generator modulates all voices in the same way. All notes must be released before the envelope can be re-triggered. If you play legato, or any key remains depressed, the envelope does not restart its attack phase”. (from the Logic Pro Manual)
Retrig — Similar to Mono mode, but the envelope gets triggered whenever a new key is pressed

Just adding the envelopes works with sound because of the logarithmic nature of Decibels. But here I don't think adding make sense (trying to keep it all between 0 and 1). Does max make sense to you with that piano example because the weak notes attack should still rise above the sustained hard hit note? If the release isnt aggressive enough for the hard hit note, a following weak note wouldn't show anything

@OmarEmaraDev
Copy link
Collaborator

A velocity slider as described looks good to me.

I am not sure if max would make sense in the case you mentioned indeed. But if you can find a way to make it in the 0-1 range through some kind of weighted sum, that would be better.

@ghost
Copy link
Author

ghost commented Mar 12, 2022

I think max works the best, can I go ahead an implement the whole AHDSR envelope? attack, hold, decay, sustain, release? An overlapping window with a strong key strike from a piano would have a quick attack and a quick decay, so after release it would be interpolating from the sustain level instead of the full height, which would leave room for an overlapping attack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-do Accepted proposal that needs to be implemented.
Projects
None yet
Development

No branches or pull requests

1 participant