Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public void GraceNotes()
RunVisualTest(settings, new[] { 0 }, "TestFiles/Docs/Features/GraceNotes.gp5", "TestFiles/VisualTests/Features/SpecialNotes/GraceNotes.png");
}

[TestMethod, AsyncTestMethod]
public void GraceNotesAdvanced()
{
var settings = new Settings();
RunVisualTest(settings, new[] { 0, 1 }, "TestFiles/VisualTests/Features/SpecialNotes/GraceNotesAdvanced.gp", "TestFiles/VisualTests/Features/SpecialNotes/GraceNotesAdvanced.png");
}

[TestMethod, AsyncTestMethod]
public void DeadNotes()
{
Expand Down
6 changes: 4 additions & 2 deletions Source/AlphaTab/Audio/MidiTickLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ public MidiTickLookupFindBeatResult FindBeat(Track[] tracks, int tick)
for (var b = index + 1; b < beats.Count; b++)
{
var currentBeat = beats[b];
if (currentBeat.Start > beat.Start &&
if (currentBeat.Beat.GraceType == GraceType.None &&
currentBeat.Start > beat.Start &&
trackLookup.ContainsKey(currentBeat.Beat.Voice.Bar.Staff.Track.Index))
{
nextBeat = currentBeat;
Expand All @@ -237,7 +238,8 @@ public MidiTickLookupFindBeatResult FindBeat(Track[] tracks, int tick)
for (var b = 0; b < beats.Count; b++)
{
var currentBeat = beats[b];
if (trackLookup.ContainsKey(currentBeat.Beat.Voice.Bar.Staff.Track.Index))
if (currentBeat.Beat.GraceType == GraceType.None &&
trackLookup.ContainsKey(currentBeat.Beat.Voice.Bar.Staff.Track.Index))
{
nextBeat = currentBeat;
break;
Expand Down
12 changes: 6 additions & 6 deletions Source/AlphaTab/Model/Voice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,21 @@ internal void Finish(Settings settings)
nonGrace.UpdateDurations();
}

// grace beats have 1/4 size of the non grace beat following them
var perGraceDuration = nonGrace == null
// grace beats have 1/4 size of the non grace beat preceeding them
var perGraceDisplayDuration = beat.PreviousBeat == null
? Duration.ThirtySecond.ToTicks()
: nonGrace.DisplayDuration / 4 / numberOfGraceBeats;
: beat.PreviousBeat.DisplayDuration / 4 / numberOfGraceBeats;

// move all grace beats
// move all grace beats
var graceBeat = Beats[i];
for (var j = 0; j < numberOfGraceBeats && graceBeat != null; j++)
{
graceBeat.Duration = graceDuration;
graceBeat.UpdateDurations();

graceBeat.DisplayStart =
currentDisplayTick - (numberOfGraceBeats - j + 1) * perGraceDuration;
graceBeat.DisplayDuration = perGraceDuration;
currentDisplayTick - (numberOfGraceBeats - j + 1) * perGraceDisplayDuration;
graceBeat.DisplayDuration = perGraceDisplayDuration;

stolenDuration += graceBeat.PlaybackDuration;

Expand Down
Binary file modified TestData/VisualTests/Features/SpecialNotes/GraceNotes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.