Skip to content

How to receive an event at each bar? #176

Answered by melanchall
garcon33 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

Interesting task. Can't provide an easy way, you need some extra coding here. First, declare these constants and fields:

private const int _checkFrequency = 10;

private static int _ticks = -1;
private static TimeSpan[] _barsStarts;
private static IEnumerator<TimeSpan> _barsStartsEnumerator;
private static bool _barsStartsEnumerated;

static here because I've tested the things within console app with static Main. If you have non-static class, use fields without the keyword.

Well, next:

var tickGenerator = new HighPrecisionTickGenerator();
tickGenerator.TickGenerated += OnTickGenerated;

And next:

var tempoMap = midiFile.GetTempoMap();
_barsStarts = Enumerable
    .Range(0, (int)midiFile.G…

Replies: 1 comment 3 replies

Comment options

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

@melanchall
Comment options

@garcon33
Comment options

Answer selected by garcon33
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