First simple approach to CC11
first of all thank you for your helpful comments and thanks for all the help and patience from MuseScore people on IRC! You guys rock!
I got a little update on the CC11 (de)crescendo. I thought writing some code would help and will bring me to the actual problems - and so it did. First things first - here is my branch in which I'm working on CC11.
What does CC11 do in SF?
The main "problem" is that CC11 (like CC7 and velocity) are "just" modifying the attenuation generator according to the sf spec. So all we got is attenuation. That makes decrescendos pretty easy (does it? - see more down below) - since CC11, CC7 and Velocity work in the same matter in SF - so they are interchangeable. All we need to do is lower the CC11 in the same fashion as we would do with velocity. That works - at least for a start ;)
But how do we do crescendo if all we can do is make things quieter? I came up with the solution that I simply change the velocity of the chord/note to what is shall be at the end, and then lower it to what it should be at start via CC11 and than pump CC11 all the way up to 127.
Not that simple...
But sadly everything is not that simple. Since attenuation is curved it doesn't add up that nicely. It works for a start but probably there has do be some more exploration if we can do better!
When to go back to normal?
Another thing is when we're going out of CC11 changing and back to what it should be? In my first naive and simple approach we reach CC11 changing end at chord end minus two ticks and change back to value 127 (no attenuation) at chord end minus one tick. That leads up to jumps in CC11 that might not be that nice. I think when I investigate in how to better add up the values I might have a look into that. A simple solution might be just doing CC11 with value 127 on every note that isn't a crescendo at the beginning. But that is stupid - maybe something better comes up! Also I'm assuming that the note is as long as its value - that is very unlikely the case. So gate should be acknowledged in the future.
Currently the code rests in its in its own method and looks for hairpins. A better and more general approach would be to put it inside the same method that puts in midi notes and check whether start and end have a different velocity and put in CC11 according to that.