Skip to content
Discussion options

You must be logged in to vote

Hi,

Can you please clarify what you exactly need? You want to get times in milliseconds (or in another format) of all bar lines in a MIDI file?

Use this code please:

var barBeatTicksDuration = midiFile.GetDuration<BarBeatTicksTimeSpan>();
var bars = barBeatTicksDuration.Bars;

var tempoMap = midiFile.GetTempoMap();
var barLinesMilliseconds = Enumerable
    .Range(0, (int)bars + 1)
    .Select(bar => TimeConverter
        .ConvertTo<MetricTimeSpan>(new BarBeatTicksTimeSpan(bar), tempoMap)
        .TotalMilliseconds)
    .ToArray();

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@cad12345
Comment options

@melanchall
Comment options

@cad12345
Comment options

Answer selected by cad12345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Just question about the library
2 participants