Skip to content

Commit

Permalink
Merge pull request #2066 from jimka2001/trill-lower-limit
Browse files Browse the repository at this point in the history
update trill speed to work well for very slow tempo.
  • Loading branch information
lasconic committed Jun 23, 2015
2 parents 61d33c7 + a95b2f7 commit 2f3e807
Show file tree
Hide file tree
Showing 6 changed files with 5,133 additions and 281 deletions.
16 changes: 12 additions & 4 deletions libmscore/rendermidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,8 @@ int articulationExcursion(Note *noteL, Note *noteR, int deltastep)

void renderNoteArticulation(NoteEventList* events, Note * note, bool chromatic, int tickspernote,
const vector<int> & prefix, const vector<int> & body,
bool repeatp, bool sustainp, const vector<int> & suffix)
bool repeatp, bool sustainp, const vector<int> & suffix,
int minticksperquarter=16, int maxticksperquarter=12)
{
events->clear();
Chord *chord = note->chord();
Expand All @@ -979,14 +980,20 @@ void renderNoteArticulation(NoteEventList* events, Note * note, bool chromatic,
return;

qreal ticksPerSecond = chord->score()->tempo(chord->tick()) * MScore::division;

// I am heuristically declaring that the fastest possible trill is a 32nd note of a 120 bpm metronome.
// This corresponds to 16 notes per second. 16 = 32 / (120 / 60).
// Thus minduration = ticksPerSecond / 16.
int mintickspernote = int(ticksPerSecond / 16); // minimum number of ticks for the shortest note in a trill or other articulation

int mintickspernote = int(ticksPerSecond / minticksperquarter); // minimum number of ticks for the shortest note in a trill or other articulation
// is the requested duration smaller than the minimum, if so, increase it to the minimum.
tickspernote = max(tickspernote, mintickspernote);

if (maxticksperquarter > 0) {
// for tempos which are very slow, such as adagio, we may need to speed up the trill, to make it sound reasonable.
int maxtickspernote = int(ticksPerSecond / maxticksperquarter);
tickspernote = min(tickspernote, maxtickspernote);
}

// calculate whether to shorten the duration value.
if ( tickspernote*(p + b + s) <= maxticks )
; // plenty of space to play the notes without changing the requested trill note duration
Expand Down Expand Up @@ -1047,6 +1054,7 @@ void renderNoteArticulation(NoteEventList* events, Note * note, bool chromatic,
ontime = makeEvent(suffix[j], ontime, tieForward(j,suffix));
}


//---------------------------------------------------------
// noteHasGlissando
// true if note is the end of a glissando
Expand Down Expand Up @@ -1123,7 +1131,7 @@ void renderGlissando(NoteEventList* events, Note *notestart)
body.push_back(p - pitchstart);
}
}
renderNoteArticulation(events, notestart, true, MScore::division, empty, body, false, true, empty);
renderNoteArticulation(events, notestart, true, MScore::division, empty, body, false, true, empty, 16, 0);
}
}
}
Expand Down
Loading

0 comments on commit 2f3e807

Please sign in to comment.