15 June 2014

In the past week I have added more element filters. I have also tried to add filtering for voices, but it has proven a bit more difficult than I thought.

Element filters

This is a list of element filters that should be available to the user. I have created this list with Marc Sabatella’s help. If you have any suggestions regarding adding or removing a filter feel free to message me on IRC or mail.

Legend:

  • Finished and tested
  • Currently working on
  • Probably will not implement
  • Not implemented
  • Clefs
  • Key Signatures
  • Time Signatures (?)
  • Barlines
  • Dynamics
  • Lyrics
  • Chord Symbols
  • Figured Bass
  • Fret Diagrams
  • Text
  • Slurs
  • Hairpins
  • Ottava
  • Trills
  • Pedal Lines
  • Other Lines
  • Articulations
  • Arpeggios
  • Glissandi
  • Breaths
  • Fingering
  • Tremolo
  • Breaks
  • Bagpipe Embellishments

I have been implementing elements of different types, so later adding a filter for a similar type will be straightforward. Still waiting for my PR to be merged into master, so I will be able to add a filter for figured bass.

The case of clefs, time signatures, key signatures and barlines is still open for discussion.

Currently these elements are not copied, so the first thing to fix would be to create the copy code that will later check the filter for existence. The biggest decision to make is to choose the behavior of surrounding elements after paste of a time/key signature.

One possibility would be to paste the clipboard contents along with the time/key signature. A new time/key would be created after the selection that would return the signature to the previous one. There is a problem with this approach though. What if the paste destination is not the beginning of a measure?

I would leave this as is, since most of the time a user wants to copy only the notes. For now I will implement the other element filters that do not involve changing of the current functionality.

Slurs

There is a bit of an issue here. When creating a mime data xml of a staff, the slurs along with other spanners are searched for in the spannerMap. If a spanner exists in the range of the selection, it is inserted into the xml. This means that the clone segments and remove elements approach that I used for other element types will not work here. I do not see any easy way to do this. The only thing that comes to mind, is to change this xml generation code to search the chords first to insert the spanner. I haven’t looked into it that much, I plan to fix this at the beginning of next week.

Voice filtering

Feature requests:

Currently there is a problem with copy-pasting measures which have more than one voice. The issue is described here: Voice 2 not copied if destination has content there; undo then produces incorrect results

Upon inspection, the paste code that creates the new elements, removes the first segment. When applying undo, only the first chordrest in the segment is restored. The makeGap function removes segments, so that the newly pasted chordrests will not overwrite the old ones. This also allows us to call undo, which will create the old chordrests again.

It looks like the makeGap function does not clear chordrests in other voices.

There are more issues having to do with pasting multiple voices.

So far I have found out that the paste works as follows:

We create a mime xml of the staves that roughly look like this:

<Staff id="0">
    <tick>0</tick> <!-- start tick of first voice -->
    <Chord>
      <track>0</track>
      <durationType>quarter</durationType>
      </Chord>
    <Chord>
      <track>0</track>
      <durationType>quarter</durationType>
      </Chord>
    <tick>0</tick> <!-- start tick second voice -->
    <Chord>
      <track>1</track>
      <durationType>quarter</durationType>
      </Chord>
    <Chord>
      <track>1</track>
      <durationType>quarter</durationType>
      </Chord>
    </Staff>

For each tick tag create a gap that will allow us to paste the chordrests. This removes all segments that are between the start tick, and the end tick of the selection. We then create and place the new elements in their places advancing the ticks based on elements duration.

The removal of segments is a bit problematic from filters point of view, because this does not leave behind the previous chordrests.

The default behavior should be to insert chordrests without removing segments. This would allow us to paste a voice into a measure without altering the other voices. For this I have moved the current paste behavior to a new paste command: paste-replace. The default shortcut is Ctrl+Shift+P. This command overwrites the whole selection with the clipboard contents.

The new behavior of paste does not call makeGap. It works correctly, but adding and overwriting the chordrests that are on the same voice. Unfortunately, undo does not work as intended. I will look into this at the end of next week.

Paste-test PR

I have noticed that some of the code in paste tests is copied from musescore. I have decided to factor out a paste function that will be available to be called on a score object. In this PR I added a new cmdPaste, that contains the repeated code.

I also noticed, that pasteStaff takes a chord rest as a parameter. This proved to be a problem, when pasting into a measure with a voice filter on. Sometimes a destination does not have a chordrest in the selection. I have changed the method to take a segment as a parameter. I have also written a method that returns the first chord rest segment. This way the behavior stays the same, and is more intuitive.

Tasks in the upcoming week

My plan is too find a way to remove spanners from a selection mime data. I will also add the remaining element filters that I have not yet implemented. If there will be time left at the end of the week, I will look into fixing the voice paste issue.