update Palm Mute; fix for grace notes in drum staff

This commit is contained in:
Werner Schweer 2017-11-28 17:31:14 +01:00
parent b7d51c8d92
commit 2210363047
13 changed files with 90 additions and 66 deletions

View file

@ -1587,6 +1587,32 @@ void Chord::layout2()
}
//---------------------------------------------------------
// updatePercussionNotes
//---------------------------------------------------------
static void updatePercussionNotes(Chord* c, const Drumset* drumset)
{
for (Chord* ch : c->graceNotes())
updatePercussionNotes(ch, drumset);
std::vector<Note*> lnotes(c->notes()); // we need a copy!
for (Note* note : lnotes) {
if (!drumset)
note->setLine(0);
else {
int pitch = note->pitch();
if (!drumset->isValid(pitch)) {
note->setLine(0);
qWarning("unmapped drum note %d", pitch);
}
else if (!note->fixed()) {
note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch)));
note->setLine(drumset->line(pitch));
}
}
}
}
//---------------------------------------------------------
// cmdUpdateNotes
//---------------------------------------------------------
@ -1607,17 +1633,13 @@ void Chord::cmdUpdateNotes(AccidentalState* as)
// PITCHED_ and PERCUSSION_STAFF can go note by note
for (Chord* ch : graceNotesBefore()) {
if (staffGroup != StaffGroup::PERCUSSION) {
if (staffGroup == StaffGroup::STANDARD) {
for (Chord* ch : graceNotesBefore()) {
std::vector<Note*> notes(ch->notes()); // we need a copy!
for (Note* note : notes)
note->updateAccidental(as);
ch->sortNotes();
}
ch->sortNotes();
}
if (staffGroup == StaffGroup::STANDARD) {
std::vector<Note*> lnotes(notes()); // we need a copy!
for (Note* note : lnotes) {
if (note->tieBack() && note->tpc() == note->tieBack()->startNote()->tpc()) {
@ -1631,39 +1653,21 @@ void Chord::cmdUpdateNotes(AccidentalState* as)
}
note->updateAccidental(as);
}
for (Chord* ch : graceNotesAfter()) {
std::vector<Note*> notes(ch->notes()); // we need a copy!
for (Note* note : notes)
note->updateAccidental(as);
ch->sortNotes();
}
}
else if (staffGroup == StaffGroup::PERCUSSION) {
const Instrument* instrument = part()->instrument();
const Drumset* drumset = instrument->drumset();
if (!drumset)
qWarning("no drumset");
std::vector<Note*> lnotes(notes()); // we need a copy!
for (Note* note : lnotes) {
if (!drumset)
note->setLine(0);
else {
int pitch = note->pitch();
if (!drumset->isValid(pitch)) {
note->setLine(0);
qWarning("unmapped drum note %d", pitch);
}
else if (!note->fixed()) {
note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch)));
// note->setHeadGroup(drumset->noteHead(pitch));
note->setLine(drumset->line(pitch));
}
}
}
updatePercussionNotes(this, drumset);
}
for (Chord* ch : graceNotesAfter()) {
if (staffGroup != StaffGroup::PERCUSSION) {
std::vector<Note*> notes(ch->notes()); // we need a copy!
for (Note* note : notes)
note->updateAccidental(as);
}
ch->sortNotes();
}
sortNotes();
}
@ -3067,13 +3071,16 @@ QVector<Chord*> Chord::graceNotesBefore() const
{
QVector<Chord*> cl;
for (Chord* c : _graceNotes) {
if (c->noteType() & (NoteType::ACCIACCATURA
| NoteType::APPOGGIATURA
| NoteType::GRACE4
| NoteType::GRACE16
| NoteType::GRACE32))
Q_ASSERT(c->noteType() != NoteType::NORMAL && c->noteType() != NoteType::INVALID);
if (c->noteType() & (
NoteType::ACCIACCATURA
| NoteType::APPOGGIATURA
| NoteType::GRACE4
| NoteType::GRACE16
| NoteType::GRACE32)) {
cl.push_back(c);
}
}
}
return cl;
}
@ -3086,6 +3093,7 @@ QVector<Chord*> Chord::graceNotesAfter() const
QVector<Chord*> cl;
for (int i = _graceNotes.size() - 1; i >= 0; i--) {
Chord* c = _graceNotes[i];
Q_ASSERT(c->noteType() != NoteType::NORMAL && c->noteType() != NoteType::INVALID);
if (c->noteType() & (NoteType::GRACE8_AFTER | NoteType::GRACE16_AFTER | NoteType::GRACE32_AFTER))
cl.push_back(c);
}

View file

@ -1973,6 +1973,7 @@ void Measure::read(XmlReader& e, int staffIdx)
|| tag == "TextLine"
|| tag == "LetRing"
|| tag == "Vibrato"
|| tag == "PalmMute"
|| tag == "Volta") {
Spanner* sp = static_cast<Spanner*>(Element::name2Element(tag, score()));
sp->setTrack(e.track());

View file

@ -1289,7 +1289,7 @@ bool Note::readProperties(XmlReader& e)
else if (tag == "veloType")
setProperty(P_ID::VELO_TYPE, Ms::getProperty(P_ID::VELO_TYPE, e));
else if (tag == "line")
_line = e.readInt();
setLine(e.readInt());
else if (tag == "Fingering") {
Fingering* f = new Fingering(score());
f->read(e);
@ -2082,8 +2082,10 @@ void Note::updateAccidental(AccidentalState* as)
AccidentalVal accVal = tpc2alter(tpc());
bool error = false;
AccidentalVal relLineAccVal = as->accidentalVal(relLine, error);
if (error)
if (error) {
qDebug("error accidetalVal");
return;
}
if ((accVal != relLineAccVal) || hidden() || as->tieContext(relLine)) {
as->setAccidentalVal(relLine, accVal, _tieBack != 0);
acci = Accidental::value2subtype(accVal);

View file

@ -1280,6 +1280,7 @@ void Score::addElement(Element* element)
case ElementType::HAIRPIN:
case ElementType::LET_RING:
case ElementType::VIBRATO:
case ElementType::PALM_MUTE:
{
Spanner* spanner = static_cast<Spanner*>(element);
if (et == ElementType::TEXTLINE && spanner->anchor() == Spanner::Anchor::NOTE)
@ -1421,6 +1422,7 @@ void Score::removeElement(Element* element)
case ElementType::PEDAL:
case ElementType::LET_RING:
case ElementType::VIBRATO:
case ElementType::PALM_MUTE:
case ElementType::TEXTLINE:
case ElementType::HAIRPIN:
{

View file

@ -398,12 +398,12 @@ void SlurSegment::layoutSegment(const QPointF& p1, const QPointF& p2)
if (dist > 0.0) {
if (pt.x() - x1 < nearDistance) {
// collision near beginning of slur
printf("collision near beginning of slur (up)\n");
// printf("collision near beginning of slur (up)\n");
_ups[int(Grip::START)].off.ry() -= dist * .8;
recomputeBezier = true;
}
else if (x2 - pt.x() < nearDistance) {
printf("collision near end of slur (up)\n");
// printf("collision near end of slur (up)\n");
_ups[int(Grip::END)].off.ry() -= dist * .8;
recomputeBezier = true;
}
@ -416,12 +416,12 @@ void SlurSegment::layoutSegment(const QPointF& p1, const QPointF& p2)
if (pt.x() - x1 < nearDistance) {
// collision near beginning of slur
printf("collision near beginning of slur (down)\n");
// printf("collision near beginning of slur (down)\n");
_ups[int(Grip::START)].off.ry() += dist * .8;
recomputeBezier = true;
}
else if (x2 - pt.x() < nearDistance) {
printf("collision near end of slur (down)\n");
// printf("collision near end of slur (down)\n");
_ups[int(Grip::END)].off.ry() += dist * .8;
recomputeBezier = true;
}
@ -1150,7 +1150,7 @@ SpannerSegment* Slur::layoutSystem(System* system)
void Slur::layout()
{
printf("Slur::layout %p\n", this);
// printf("Slur::layout %p\n", this);
if (track2() == -1)
setTrack2(track());

View file

@ -720,7 +720,7 @@ static const StyleType styleTypes[] {
{ StyleIdx::palmMuteFontBold, "palmMuteFontBold", false },
{ StyleIdx::palmMuteFontItalic, "palmMuteFontItalic", true },
{ StyleIdx::palmMuteFontUnderline, "palmMuteFontUnderline", false },
{ StyleIdx::palmMuteTextAlign, "palmMuteTextAlign", QVariant::fromValue(Align::LEFT | Align::BASELINE) },
{ StyleIdx::palmMuteTextAlign, "palmMuteTextAlign", QVariant::fromValue(Align::LEFT | Align::VCENTER) },
{ StyleIdx::palmMuteHookHeight, "palmMuteHookHeight", Spatium(0.6) },
{ StyleIdx::palmMutePlacement, "palmMutePlacement", int(Element::Placement::BELOW) },
{ StyleIdx::palmMutePosAbove, "palmMutePosAbove", Spatium(-4.0) },

View file

@ -698,6 +698,7 @@ void System::add(Element* el)
case ElementType::GLISSANDO_SEGMENT:
case ElementType::LET_RING_SEGMENT:
case ElementType::VIBRATO_SEGMENT:
case ElementType::PALM_MUTE_SEGMENT:
{
SpannerSegment* ss = static_cast<SpannerSegment*>(el);
#ifndef NDEBUG

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>807</width>
<height>325</height>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
@ -157,7 +157,7 @@
<bool>true</bool>
</property>
<property name="minimum">
<number>-9999</number>
<number>-99999</number>
</property>
</widget>
</item>

View file

@ -319,6 +319,7 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
case ElementType::PEDAL:
case ElementType::LET_RING:
case ElementType::VIBRATO:
case ElementType::PALM_MUTE:
case ElementType::DYNAMIC:
case ElementType::OTTAVA:
case ElementType::TRILL:
@ -477,6 +478,7 @@ void ScoreView::dropEvent(QDropEvent* event)
case ElementType::PEDAL:
case ElementType::LET_RING:
case ElementType::VIBRATO:
case ElementType::PALM_MUTE:
case ElementType::HAIRPIN:
case ElementType::TEXTLINE:
{

View file

@ -161,14 +161,14 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
//
// noteBits:
// 7 - Right hand or left hand fingering;
// 6 - Accentuated note
// 5 - Note type (rest, empty note, normal note);
// 4 - note dynamic;
// 3 - Presence of effects linked to the note;
// 2 - Ghost note;
// 1 - Dotted note; ?
// 0 - Time-independent duration
// 80 - Right hand or left hand fingering;
// 40 - Accentuated note
// 20 - Note type (rest, empty note, normal note);
// 10 - note dynamic;
// 8 - Presence of effects linked to the note;
// 4 - Ghost note;
// 2 - Dotted note; ?
// 1 - Time-independent duration
if (noteBits & BEAT_TREMOLO) {
//note->setHeadGroup(NoteHead::Group::HEAD_CROSS);
@ -177,7 +177,7 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
bool tieNote = false;
uchar variant = 1;
if (noteBits & BEAT_EFFECT) {
if (noteBits & BEAT_EFFECT) { // 0x20
variant = readUChar();
if (variant == 1) { // normal note
}
@ -205,11 +205,11 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
}
// set dynamic information on note if different from previous note
if (noteBits & NOTE_DYNAMIC) {
if (noteBits & NOTE_DYNAMIC) { // 0x10
int d = readChar();
if (previousDynamic != d) {
previousDynamic = d;
// addDynamic(note, d); // TODO-ws ??
// addDynamic(note, d); // velocity? TODO-ws ??
}
}
else if (previousDynamic) {
@ -218,21 +218,23 @@ bool GuitarPro4::readNote(int string, int staffIdx, Note* note)
}
int fretNumber = -1;
if (noteBits & NOTE_FRET)
if (noteBits & NOTE_FRET) { // 0x20
// TODO: special case if note is tied
fretNumber = readUChar();
}
// check if a note is supposed to be accented, and give it the sforzato type
if (noteBits & NOTE_SFORZATO) {
if (noteBits & NOTE_SFORZATO) { // 0x40
Articulation* art = new Articulation(note->score());
art->setSymId(SymId::articAccentAbove);
if (!note->score()->addArticulation(note, art))
delete art;
}
if (noteBits & NOTE_FINGERING) {
int leftFinger = readUChar();
if (noteBits & NOTE_FINGERING) { // 0x80
int leftFinger = readUChar();
int rightFinger = readUChar();
Text* f = new Fingering(score);
Text* f = new Fingering(score);
QString finger;
// if there is a valid left hand fingering
if (leftFinger < 5) {

View file

@ -1416,7 +1416,7 @@ bool GuitarPro5::readNote(int string, Note* note)
art->setSymId(SymId::articMarcatoAbove);
if (!note->score()->addArticulation(note, art))
delete art;
}
}
// check if a note is supposed to be accented, and give it the sforzato type
if (noteBits & NOTE_SFORZATO) {

View file

@ -367,6 +367,7 @@ void GuitarPro::initGuitarProDrumset()
void GuitarPro::addPalmMute(Note* note)
{
printf("addPalmMute===\n");
int track = note->track();
while (int(_palmMutes.size()) < track + 1)
_palmMutes.push_back(0);
@ -2861,7 +2862,7 @@ Score::FileError importGTP(MasterScore* score, const QString& name)
pscore->setPlaylistDirty();
pscore->setLayoutAll();
pscore->addLayoutFlags(LayoutFlag::FIX_PITCH_VELO);
pscore->doLayout();
// pscore->doLayout();
}
for (auto p : infoParts) {

View file

@ -82,6 +82,7 @@
#include "libmscore/stafftypechange.h"
#include "libmscore/letring.h"
#include "libmscore/vibrato.h"
#include "libmscore/palmmute.h"
namespace Ms {
@ -1270,6 +1271,10 @@ Palette* MuseScore::newLinesPalette(PaletteType t)
Vibrato* vibrato = new Vibrato(gscore);
vibrato->setLen(w);
sp->append(vibrato, QT_TRANSLATE_NOOP("Palette", "Vibrato"));
PalmMute* pm = new PalmMute(gscore);
pm->setLen(w);
sp->append(pm, QT_TRANSLATE_NOOP("Palette", "Palm Mute"));
}
else {
sp->setMoreElements(true);