GSoC 2019: Week 3
My task this week has been to implement automatically changing key for transposing instruments, which in my mind is probably the most important part of the project that I have done so far. I spent a lot of time learning about how key signatures worked, especially with regards to transposing instruments, and key signatures that only applied to a single stave. After doing this, I attempted to implement automatically adding a key change object to each stave that was affected by the instrument change, in the same way that I added new clefs last week. While this took a lot of fiddling to work properly with the correct transpositions, especially going from one transposing instrument to another, this solution worked very well. I was worried that the key changes would continue to show in concert pitch mode, but fortunately these are already automatically hidden.
After doing this, I then attempted to make the instrument change object integrate more with the key changes and clefs, as, with a transposing instrument, there isn't really a situation in which you'd want to have the instrument change without the key signature, with the exception of with an atonal key signature, which is something I would like to handle automatically. To do this, I have added two vectors to the instrument change object, containing pointers to the clefs and key signatures associated with the instrument change (one for each stave). This means that when the instrument change is deleted, the key signatures and clefs that were created by the instrument change are deleted to. This doesn't yet work the other way around, and deleting the key change before deleting the instrument change currently results in a crash.
In this next week I will be looking at further streamlining the relationship between the instrument change and the associated key signatures and clefs, and adding support for atonal key signatures. If I complete this early, I will start looking into having a text object that is placed at the last line of music before the instrument change instructing the player to change to the new instrument, which will automatically move if music is added or deleted.