# MidiFile noteOff pairs get lost \[fix included\]

**URL:** <https://forum.juce.com/t/midifile-noteoff-pairs-get-lost-fix-included/8948>\
**Category:** General JUCE discussion\
**Created:** [July 11, 2012, 9:05am UTC](https://forum.juce.com/t/midifile-noteoff-pairs-get-lost-fix-included/8948 "2012-07-11T09:05:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaBer](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@SaBer](https://forum.juce.com/u/SaBer)\
**Post date:** [July 11, 2012, 9:05am UTC](https://forum.juce.com/t/midifile-noteoff-pairs-get-lost-fix-included/8948/1 "2012-07-11T09:05:36Z")

</div>

Hello all, I’m new to the forums, but will jump right in to reporting a bug and a fix to it 🙂

I did check that this hasn’t been fixed in git.

When a MidiFile get’s read, readNextTrack() does

```auto
result.updateMatchedPairs();
addTrack (result);
```

However, addTrack() takes a copy of result, which doesn’t copy the matching note off pointers, created by updateMatchedPairs().

One possible fix would be to replace the above code with :

```auto
addTrack (result);
tracks.getLast()->updateMatchedPairs();
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 11, 2012, 9:16am UTC](https://forum.juce.com/t/midifile-noteoff-pairs-get-lost-fix-included/8948/2 "2012-07-11T09:16:23Z")

</div>

Ah! Excellent stuff, thanks very much! I’ll get that sorted out right away…
