Skip to content

Commit

Permalink
fix #42121 fix #78536 fix #103921: Slurs lost on exchange voices and …
Browse files Browse the repository at this point in the history
…add test for exchange voices
  • Loading branch information
Rockettwo authored and lasconic committed Jul 12, 2016
1 parent 51a8fb6 commit 1abf27a
Show file tree
Hide file tree
Showing 11 changed files with 1,189 additions and 5 deletions.
29 changes: 27 additions & 2 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2785,11 +2785,36 @@ void Measure::sortStaves(QList<int>& dst)

void Measure::exchangeVoice(int v1, int v2, int staffIdx)
{
int strack = staffIdx * VOICES + v1;
int dtrack = staffIdx * VOICES + v2;

for (Segment* s = first(Segment::Type::ChordRest); s; s = s->next(Segment::Type::ChordRest)) {
int strack = staffIdx * VOICES + v1;
int dtrack = staffIdx * VOICES + v2;
s->swapElements(strack, dtrack);
}

auto spanners = score()->spannerMap().findOverlapping(tick(), endTick()-1);
int start = tick();
int end = start + ticks();
for (auto i = spanners.begin(); i < spanners.end(); i++) {
Spanner* sp = i->value;
int spStart = sp->tick();
int spEnd = spStart + sp->ticks();
qDebug("Start %d End %d Diff %d \n Measure Start %d End %d", spStart, spEnd, spEnd-spStart, start, end);
if (sp->type() == Element::Type::SLUR && (spStart >= start || spEnd < end)) {
if (sp->track() == strack && spStart >= start){
sp->setTrack(dtrack);
}
else if (sp->track() == dtrack && spStart >= start){
sp->setTrack(strack);
}
if (sp->track2() == strack && spEnd < end){
sp->setTrack2(dtrack);
}
else if (sp->track2() == dtrack && spEnd < end){
sp->setTrack2(strack);
}
}
}
// MStaff* ms = mstaff(staffIdx);
// ms->hasVoices = true;
checkMultiVoices(staffIdx); // probably true, but check for invisible notes & rests
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ class Score : public QObject, public ScoreElement {

void cmdInsertClef(ClefType);
void cmdAddGrace(NoteType, int);
void cmdExchangeVoice(int, int);

void removeChordRest(ChordRest* cr, bool clearSegment);
void cmdMoveRest(Rest*, MScore::Direction);
Expand Down Expand Up @@ -1086,6 +1085,7 @@ class Score : public QObject, public ScoreElement {
void cmdSlashFill();
void cmdSlashRhythm();
void cmdResequenceRehearsalMarks();
void cmdExchangeVoice(int, int);

void setAccessibleInfo(QString s) { accInfo = s.remove(":").remove(";"); }
QString accessibleInfo() { return accInfo; }
Expand Down
1 change: 1 addition & 0 deletions libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ void Score::undoExchangeVoice(Measure* measure, int v1, int v2, int staff1, int
{
int tick = measure->tick();
QSet<Staff*> sl;

for (int staffIdx = staff1; staffIdx < staff2; ++staffIdx) {
for (Staff* s : staff(staffIdx)->staffList())
sl.insert(s);
Expand Down
1 change: 0 additions & 1 deletion mtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ add_custom_target(reporthtml

subdirs (libmscore importmidi capella biab musicxml guitarpro scripting testoves)


install(FILES
../share/styles/chords_std.xml
../share/styles/chords_jazz.xml
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

subdirs(
album barline beam breath chordsymbol clef clef_courtesy compat concertpitch copypaste
copypastesymbollist cursor dynamic earlymusic element hairpin instrumentchange join keysig layout links parts measure midi
copypastesymbollist cursor dynamic earlymusic element exchangevoices hairpin instrumentchange join keysig layout links parts measure midi
note plugins repeat selectionfilter selectionrangedelete spanners split splitstaff timesig tools transpose tuplet text
)

Expand Down
17 changes: 17 additions & 0 deletions mtest/libmscore/exchangevoices/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
# $Id:$
#
# Copyright (C) 2011 Werner Schweer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation and appearing in
# the file LICENSE.GPL
#=============================================================================

set(TARGET tst_exchangevoices)

include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)

242 changes: 242 additions & 0 deletions mtest/libmscore/exchangevoices/exchangevoices-gliss-ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<lastSystemFillLimit>0</lastSystemFillLimit>
<page-layout>
<page-height>1683.36</page-height>
<page-width>1190.88</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Rest>
<durationType>half</durationType>
</Rest>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>67</pitch>
<tpc>15</tpc>
<Glissando id="2">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
<endSpanner id="3"/>
</Note>
</Chord>
<Rest>
<durationType>quarter</durationType>
</Rest>
<tick>0</tick>
<Chord>
<track>1</track>
<durationType>quarter</durationType>
<Note>
<track>1</track>
<pitch>60</pitch>
<tpc>14</tpc>
<Glissando id="4">
<text>gliss.</text>
<subtype>0</subtype>
<track>1</track>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
<Chord>
<track>1</track>
<durationType>quarter</durationType>
<Note>
<track>1</track>
<pitch>64</pitch>
<tpc>18</tpc>
<Glissando id="3">
<text>gliss.</text>
<subtype>0</subtype>
<track>1</track>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
<endSpanner id="4"/>
</Note>
</Chord>
<Rest>
<track>1</track>
<durationType>quarter</durationType>
</Rest>
<Chord>
<track>1</track>
<durationType>quarter</durationType>
<Note>
<track>1</track>
<pitch>71</pitch>
<tpc>19</tpc>
<endSpanner id="2"/>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
<Glissando id="5">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
<endSpanner id="6"/>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
<tick>1920</tick>
<Chord>
<track>1</track>
<durationType>quarter</durationType>
<Note>
<track>1</track>
<pitch>72</pitch>
<tpc>14</tpc>
<Glissando id="6">
<text>gliss.</text>
<subtype>1</subtype>
<track>1</track>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
<Chord>
<track>1</track>
<durationType>quarter</durationType>
<Note>
<track>1</track>
<pitch>72</pitch>
<tpc>14</tpc>
<endSpanner id="5"/>
</Note>
</Chord>
<Rest>
<track>1</track>
<durationType>half</durationType>
</Rest>
</Measure>
</Staff>
</Score>
</museScore>
Loading

0 comments on commit 1abf27a

Please sign in to comment.