Skip to content

Commit

Permalink
Merge pull request #1975 from heuchi/57261_fix-tremoloChordType
Browse files Browse the repository at this point in the history
fix #57261: multi-notes tremolo not played back correctly
  • Loading branch information
wschweer committed Jun 10, 2015
2 parents 1e41115 + 3d13932 commit 2508953
Show file tree
Hide file tree
Showing 4 changed files with 881 additions and 9 deletions.
44 changes: 35 additions & 9 deletions libmscore/rendermidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,20 +757,46 @@ void renderTremolo(Chord *chord, QList<NoteEventList> & ell)
seg2 = seg2->next(st);
Chord* c2 = seg2 ? static_cast<Chord*>(seg2->element(track)) : 0;
if (c2 && c2->type() == Element::Type::CHORD) {
int tnotes = qMin(notes, c2->notes().size());
int notes2 = c2->notes().size();
int tnotes = qMax(notes, notes2);
int tticks = chord->actualTicks() * 2; // use twice the size
int n = tticks / t;
n /= 2;
int l = 2000 * t / tticks;
for (int k = 0; k < tnotes; ++k) {
NoteEventList* events = &ell[k];
events->clear();
int p1 = chord->notes()[k]->pitch();
int p2 = c2->notes()[k]->pitch();
int dpitch = p2 - p1;
for (int i = 0; i < n; ++i) {
events->append(NoteEvent(0, l * i * 2, l));
events->append(NoteEvent(dpitch, l * i * 2 + l, l));
NoteEventList* events;
if (k < notes) {
// first chord has note
events = &ell[k];
events->clear();
}
else {
// otherwise reuse note 0
events = &ell[0];
}
if (k < notes && k < notes2) {
// both chords have note
int p1 = chord->notes()[k]->pitch();
int p2 = c2->notes()[k]->pitch();
int dpitch = p2 - p1;
for (int i = 0; i < n; ++i) {
events->append(NoteEvent(0, l * i * 2, l));
events->append(NoteEvent(dpitch, l * i * 2 + l, l));
}
}
else if (k < notes) {
// only first chord has note
for (int i = 0; i < n; ++i)
events->append(NoteEvent(0, l * i * 2, l));
}
else {
// only second chord has note
// reuse note 0 of first chord
int p1 = chord->notes()[0]->pitch();
int p2 = c2->notes()[k]->pitch();
int dpitch = p2-p1;
for (int i = 0; i < n; ++i)
events->append(NoteEvent(dpitch, l * i * 2 + l, l));
}
}
}
Expand Down
Loading

0 comments on commit 2508953

Please sign in to comment.