Skip to content

Commit

Permalink
Merge pull request #4847 from changhc/284080-beats-not-listed-correctly
Browse files Browse the repository at this point in the history
Fix #284080: incorrectly listed beats
  • Loading branch information
dmitrio95 committed Apr 18, 2019
2 parents 4fbb221 + 29cd62d commit a7cff20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libmscore/sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Ms {
// ticks_beat
//---------------------------------------------------------

static int ticks_beat(int n)
int ticks_beat(int n)
{
int m = (MScore::division * 4) / n;
if ((MScore::division * 4) % n) {
Expand Down
2 changes: 2 additions & 0 deletions libmscore/sig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace Ms {
class XmlWriter;
class XmlReader;

int ticks_beat(int n);

//-------------------------------------------------------------------
// BeatType
//-------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion mscore/scoreaccessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "libmscore/score.h"
#include "libmscore/measure.h"
#include "libmscore/spanner.h"
#include "libmscore/sig.h"
#include "inspector/inspector.h"
#include "selectionwindow.h"
#include "playpanel.h"
Expand Down Expand Up @@ -228,6 +229,7 @@ std::pair<int, float> ScoreAccessibility::barbeat(Element *e)
int ticks = 0;
TimeSigMap* tsm = e->score()->sigmap();
Element* p = e;
int ticksB = ticks_beat(tsm->timesig(0).timesig().denominator());
while(p && p->type() != ElementType::SEGMENT && p->type() != ElementType::MEASURE)
p = p->parent();

Expand All @@ -237,13 +239,14 @@ std::pair<int, float> ScoreAccessibility::barbeat(Element *e)
else if (p->type() == ElementType::SEGMENT) {
Segment* seg = static_cast<Segment*>(p);
tsm->tickValues(seg->tick().ticks(), &bar, &beat, &ticks);
ticksB = ticks_beat(tsm->timesig(seg->tick().ticks()).timesig().denominator());
}
else if (p->type() == ElementType::MEASURE) {
Measure* m = static_cast<Measure*>(p);
bar = m->no();
beat = -1;
ticks = 0;
}
return pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(MScore::division));
return pair<int,float>(bar + 1, beat + 1 + ticks / static_cast<float>(ticksB));
}
}

0 comments on commit a7cff20

Please sign in to comment.