private void FinishNote(MidiEvent midiEvent, Track track)
        {
            var beats = track.DefaultBarContext.BeatsInBar;

            Duration duration = helper.GetDuration(track.previousNoteAbsoluteTicks, midiEvent.AbsoluteTicks, track.division,
                                                   beats.Item1, beats.Item2, out double percentageOfBar, out int dots);

            // Finish the previous note with the length.
            track.previousNoteAbsoluteTicks = midiEvent.AbsoluteTicks;

            noteBuilder.SetDuration(duration);
            noteBuilder.SetPoints(dots);
            var note = noteBuilder.Build();

            track.CreateNewNote(note);

            percentageOfBarReached += percentageOfBar;
            if (percentageOfBarReached >= 1)
            {
                track.CreateNewBar();
                percentageOfBarReached -= 1;
            }

            startedNoteIsClosed = true;
        }