Skip to content

Can I get TrackChunks from NotesPlaybackStarted event? #174

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

You must be logged in to vote

Hi,

First of all, you have a big problem in your code:

     Playback playback = midifile.GetPlayback(outputdevice);
     playback.NotesPlaybackStarted += OnNotesStarted;
     playback.Start();
}

What do you think will happen when the program leaves the method? Yes, all local variables will be cleaned up by the garbage collector. And thus playback won't work (or will work some small time). You need to define playback field and use Playback via class field and not via local variable. The same problem with outputDevice.

Well, as for knowing of track chunk – there is no simple way. But there is a workaround. First, create this class:

private sealed class TimedEventWithTrackChunkIndex : TimedE…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@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