Skip to content

Removing duplicates when reading a file #222

Answered by melanchall
Jenix-Park asked this question in Q&A
Discussion options

You must be logged in to vote

I think something like that should work:

var flag = false;
midiFile.RemoveTimedEvents(e =>
{
    var midiEvent = e.Event;
    if (/* midiEvent is sustain on */)
    {
        if (flag)
            return true; // event should be removed

        flag = true;
        return false; // we're on a first sustain on
    }

    flag = false;
    return false;    
});

This code will remove all subsequent sustain on events. But I in fact don't know what "sustain on" event is. I see there is controller type

DamperPedal 	Damper Pedal On/Off (Sustain).

But it means both on and off states. So please implement condition here

/* midiEvent is sustain on */

by yourself. Or clarify what event types do you…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Jenix-Park
Comment options

@melanchall
Comment options

@Jenix-Park
Comment options

@melanchall
Comment options

@Jenix-Park
Comment options

Answer selected by Jenix-Park
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