# Merge notes that overlap

**URL:** <https://forum.juce.com/t/merge-notes-that-overlap/55312>\
**Category:** Tracktion Engine\
**Created:** [March 9, 2023, 6:17pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312 "2023-03-09T18:17:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [March 9, 2023, 6:17pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/1 "2023-03-09T18:17:42Z")

</div>

Hey,

I’d like to avoid overlapping notes when recording.

What would be the best approach to do so ? I’m thinking of calling a post-processing function that is fired when recording stops.

Thanks in advance,

Best,

E.

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [March 14, 2023, 11:28am UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/2 "2023-03-14T11:28:49Z")

</div>

Yes, a post-processing step when recording finishes is probably best.  
We have `MidiClip::legatoNote` which is similar but will stretch note-offs to meet the next note-on which you probably don’t want.

---

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [March 14, 2023, 3:33pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/3 "2023-03-14T15:33:29Z")

</div>

Perfect, thanks @dave96 !

---

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [March 30, 2023, 2:07pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/4 "2023-03-30T14:07:07Z")

</div>

OK so I’m finally implementing this.

So far I am using a `TransportControl::Listener` that fires up this method :

```c++
recordingFinished(te::InputDeviceInstance& dev,
                  const juce::ReferenceCountedArray<te::Clip>& clips)

```

However, this only works for new clips that have been created during the process. Clips that were modified are not included.

Is there any way to get notified for all clips (new or existing one) that were affected by the recording process ?

Any help appreciated !

Cheers,

E.

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [March 31, 2023, 4:20pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/5 "2023-03-31T16:20:36Z")

</div>

So you’re using the merge mode?  
I’m not sure about that… I guess we’d have to add a “modified clips” parameter to the callback.

---

<div class="post-metadata">

**Author:** ![eggnog](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eggnog/32/12211_2.png) [@eggnog](https://forum.juce.com/u/eggnog)\
**Post date:** [March 31, 2023, 4:57pm UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/6 "2023-03-31T16:57:01Z")

</div>

Yeah, merge mode is enabled by default and that’s the most convenient behavior imo.

If you think that would be good addition then I could look into it and send a pull request if you’d like ?

Let me know.

Thanks for your help,

Cheers.

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [April 13, 2023, 10:12am UTC](https://forum.juce.com/t/merge-notes-that-overlap/55312/7 "2023-04-13T10:12:12Z")

</div>

If you want to do a PR, that would certainly help expedite it.
