Skip to content

Commit

Permalink
fix #256021: Add buzz roll tremolo stem
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed May 18, 2018
1 parent f9f6856 commit ed57e09
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 6 additions & 3 deletions libmscore/rendermidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,16 @@ void renderTremolo(Chord* chord, QList<NoteEventList>& ell)
Drumset* ds = chord->staff()->part()->instrument(chord->tick())->drumset();
for (Note* n : chord->notes()) {
DrumInstrumentVariant div = ds->findVariant(n->pitch(), chord->articulations(), chord->tremolo());
if (div.pitch !=INVALID_PITCH && div.tremolo == tremolo->tremoloType())
if (div.pitch != INVALID_PITCH && div.tremolo == tremolo->tremoloType())
return; // already rendered
}
}

//int n = 1 << tremolo->lines();
//int l = 1000 / n;
// we cannot render buzz roll with MIDI events only
if (tremolo->tremoloType() == TremoloType::BUZZ_ROLL)
return;

// render tremolo with multiple events
if (chord->tremoloChordType() == TremoloChordType::TremoloFirstNote) {
int t = MScore::division / (1 << (tremolo->lines() + chord->durationType().hooks()));
Segment::Type st = Segment::Type::ChordRest;
Expand Down
10 changes: 9 additions & 1 deletion libmscore/tremolo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "measure.h"
#include "segment.h"
#include "stem.h"
#include "sym.h"
#include "xml.h"

namespace Ms {
Expand All @@ -30,6 +31,7 @@ static const char* tremoloName[] = {
QT_TRANSLATE_NOOP("Tremolo", "16th through stem"),
QT_TRANSLATE_NOOP("Tremolo", "32nd through stem"),
QT_TRANSLATE_NOOP("Tremolo", "64th through stem"),
QT_TRANSLATE_NOOP("Tremolo", "Buzz roll"),
QT_TRANSLATE_NOOP("Tremolo", "Eighth between notes"),
QT_TRANSLATE_NOOP("Tremolo", "16th between notes"),
QT_TRANSLATE_NOOP("Tremolo", "32nd between notes"),
Expand Down Expand Up @@ -71,7 +73,10 @@ void Tremolo::draw(QPainter* painter) const
{
painter->setBrush(QBrush(curColor()));
painter->setPen(Qt::NoPen);
painter->drawPath(path);
if (tremoloType() == TremoloType::BUZZ_ROLL)
drawSymbol(SymId::buzzRoll, painter);
else
painter->drawPath(path);
if ((parent() == 0) && !twoNotes()) {
qreal x = 0.0; // bbox().width() * .25;
QPen pen(curColor(), point(score()->styleS(StyleIdx::stemWidth)));
Expand Down Expand Up @@ -400,6 +405,7 @@ QString Tremolo::type2name(TremoloType t)
case TremoloType::R16: return QString("r16");
case TremoloType::R32: return QString("r32");
case TremoloType::R64: return QString("r64");
case TremoloType::BUZZ_ROLL: return QString("buzzroll");
case TremoloType::C8: return QString("c8");
case TremoloType::C16: return QString("c16");
case TremoloType::C32: return QString("c32");
Expand Down Expand Up @@ -433,6 +439,8 @@ TremoloType Tremolo::name2Type(const QString& s)
t = TremoloType::C32;
else if (s == "c64")
t = TremoloType::C64;
else if (s == "buzzroll")
t = TremoloType::BUZZ_ROLL;
else
t = TremoloType(s.toInt()); // for compatibility with old tremolo type
return t;
Expand Down
4 changes: 2 additions & 2 deletions libmscore/tremolo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum class TremoloType : char {
OLD_C16,
OLD_C32,

R8=6, R16, R32, R64, // one note tremolo (repeat)
R8=6, R16, R32, R64, BUZZ_ROLL, // one note tremolo (repeat)
C8, C16, C32, C64 // two note tremolo (change)
};

Expand Down Expand Up @@ -80,7 +80,7 @@ class Tremolo : public Element {
_chord2 = c2;
}
Fraction tremoloLen() const;
bool twoNotes() const { return tremoloType() > TremoloType::R64; } // is it a two note tremolo?
bool twoNotes() const { return tremoloType() >= TremoloType::C8; } // is it a two note tremolo?
int lines() const { return _lines; }

virtual QString accessibleInfo() override;
Expand Down

0 comments on commit ed57e09

Please sign in to comment.