Removing duplicates when reading a file #222
-
Hey, how have you been? I wonder what's the simplest and fastest way to remove duplicate "DamperPedal" events when reading a random MIDI file? Is there any way to simply achieve this at a low-performance cost? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
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
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 mean. You can also send me a sample file pointing where you see duplicated events (and where sustain on and off ones). But I'll be able to look into the file a week later, I'm on vacation right now without access to my computer. |
Beta Was this translation helpful? Give feedback.
I think something like that should work:
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
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…