# Varying MIDI playback speed?

**URL:** <https://forum.juce.com/t/varying-midi-playback-speed/16351>\
**Category:** General JUCE discussion\
**Created:** [January 7, 2016, 7:30pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351 "2016-01-07T19:30:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![a303](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@a303](https://forum.juce.com/u/a303)\
**Post date:** [January 7, 2016, 7:30pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/1 "2016-01-07T19:30:49Z")

</div>

Any ideas here? Is the simplest thing to adjust the timing of each and every message in the sequence? I'm after a 'slow-down' effect so the note durations get shortened/lengthened as the tempo speeds/slows.&nbsp;

&nbsp;

Thanks.

---

<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:** [January 7, 2016, 8:16pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/2 "2016-01-07T20:16:27Z")

</div>

Well yes, slowing things down is just a case of changing the timings of the events. Not sure what other info you're looking for?

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [January 7, 2016, 8:21pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/3 "2016-01-07T20:21:17Z")

</div>

https://github.com/julianstorer/JUCE/blob/master/modules/juce\_audio\_basics/midi/juce\_MidiMessage.h

look for Meta Tempo events to insert into the MidiSequence object.&nbsp;

---

<div class="post-metadata">

**Author:** ![a303](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@a303](https://forum.juce.com/u/a303)\
**Post date:** [January 8, 2016, 1:42pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/4 "2016-01-08T13:42:30Z")

</div>

I was also looking at&nbsp;MidiMessageSequence.addTimeToMessages(). Slightly unclear as to the meaning of deltaTime argument. Does&nbsp;addTimeToMessages(2.0) effectively halve the tempo?

---

<div class="post-metadata">

**Author:** ![timur](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timur/32/541_2.png) [@timur](https://forum.juce.com/u/timur)\
**Post date:** [January 8, 2016, 2:46pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/5 "2016-01-08T14:46:45Z")

</div>

No, it doesn't. As the documentation for&nbsp;MidiMessageSequence.addTimeToMessages() says, it just adds an offset to the messages' timestamp.

---

<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:** [January 8, 2016, 2:48pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/6 "2016-01-08T14:48:10Z")

</div>

No.. like the name suggests, that would _add_ 2.0, not _multiply_ it by 2.0!

But you can iterate all the message objects and&nbsp;perform whatever operation you want directly on their timestamp values.

---

<div class="post-metadata">

**Author:** ![a303](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@a303](https://forum.juce.com/u/a303)\
**Post date:** [January 8, 2016, 3:16pm UTC](https://forum.juce.com/t/varying-midi-playback-speed/16351/7 "2016-01-08T15:16:10Z")

</div>

Yes, of course. I will have to take some more modinafil before proceeding! Thanks again.
