Skip to content

Get "rests" with the musical symbol format (e.g., quarter rests) #179

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

You must be logged in to vote

Hi,

First of all, there is no such term as "rest" in MIDI. More than that, there is no "note" term there. MIDI file contains events. Pair of Note On and Note Off events we call a note. Silence between such pairs we call a rest. What you see in a sheet music editor is not what will be stored in a MIDI file. MIDI file is just a set of instructions for a synth.

But your task looks pretty easy to solve:

var tempoMap = midiFile.GetTempoMap();
var notesAndRests = midiFile
    .GetTrackChunks()
    .Select((trackChunk, i) => new
    {
        Index = i,
        Objects = trackChunk
            .GetObjects(
                ObjectType.Note | ObjectType.Rest,
                new ObjectDetectionSett…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by garcon33
Comment options

You must be logged in to vote
0 replies
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