# Rate Limit questions and Midi question

**URL:** <https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557>\
**Category:** General\
**Created:** [29 September 2018 13:37 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557 "2018-09-29T13:37:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johncohn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johncohn/32/2878_2.png) [@johncohn](https://discourse.nodered.org/u/johncohn)\
**Post date:** [29 September 2018 13:37 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/1 "2018-09-29T13:37:59Z")

</div>

Hi friends.. I'm in need of a quick solution. I'm trying to change the tempo of MIDI music programmatically . The idea is to queue up all the midi notes from a fast playing input midi node and then rate limit them to slow them down. I'm trying to use the 'rate limit' option in the delay node.. but that only goes down to 1 message per second. I need to be able to go down into the milliseconds. Is there a a way to rate limit down into the milliseconds. For extra credit .. i'd like to control the rate programmatically like from a slider.. any ideas ?

while i'm at it .. does anyone have an example of generating polyphonic Midi from Node-red using node-red-contrib midi ? .. I see the opcode is supported.. but cant figure out how to make that work..

thanks

john cohn

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [29 September 2018 14:24 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/2 "2018-09-29T14:24:31Z")

</div>

Hi John,

You can configure the rate limit to be 10 msgs per second (for example) to achieve a faster rate. But it isn't dynamically configurable. I'm not immediately aware of a contrib node that does variable rate limiting.

Nick

---

<div class="post-metadata">

**Author:** ![johncohn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johncohn/32/2878_2.png) [@johncohn](https://discourse.nodered.org/u/johncohn)\
**Post date:** [29 September 2018 14:39 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/3 "2018-09-29T14:39:26Z")

</div>

Hi Nick !.. I've tried that.. but it doesn't seem to distribute them smoothly.. which is important for music tempo.. I'll try again. .. Is it possible for me to fork a version of the delay node that does what I want , rename it .. and put it in contrib ? If so.. where are those sources ? Thanks !  
-jc

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 September 2018 15:37 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/4 "2018-09-29T15:37:23Z")

</div>

Hi John - the core nodes are here - [https://github.com/node-red/node-red/tree/master/nodes/core/core](https://github.com/node-red/node-red/tree/master/nodes/core/core)  
It will try to release them to time - but don't forget linux is not a real time OS and there are other processes running that may put off those timings... and this would be worse at higher frequencies that you may need - and of course the human ear/brain is a wonderful sensor and can tell if something is not quite right to a very high resolution.  
Good luck !

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 September 2018 21:25 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/5 "2018-09-29T21:25:24Z")

</div>

> [@johncohn](#):
>
> but it doesn't seem to distribute them smoothly.

[edit] _IGNORE THIS: If you set it for 10msgs/sec - the 1st 10 msgs will just zip thru without delay but all the ones after that will be delayed by 0.1 sec (within the timing limits of Linux like what @dceejay said)_

_You could maybe workaround by prefixing 10 dummy midi msgs to your stream?_[/EDIT]

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [29 September 2018 21:38 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/6 "2018-09-29T21:38:32Z")

</div>

???? I hope it doesn’t do that. Please share a flow that shows that.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 September 2018 21:53 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/7 "2018-09-29T21:53:52Z")

</div>

Unfortunately, I've just damaged my neopixel ring ☹

But this is the thread that highlights the issue - IIRC - it only happens when you 1st re-deploy and send your 1st sequence of messages - it works OK afterwards

Simon

> [@\[enhancement\]to Rate limiting in Delay node to work in milliseconds](https://discourse.nodered.org/t/enhancement-to-rate-limiting-in-delay-node-to-work-in-milliseconds/2514):
>
> I was wanting to use the Delay node in rate limiting mode to control a string of leds but it has a minimum rate of 1 msg/sec Could it be changed to allow milliseconds as well as secs/minutes/hours/days as it does in standard Delay mode please? Happy to do mods myself and do a pull-request if required Simon

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 September 2018 08:23 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/8 "2018-09-30T08:23:49Z")

</div>

But that wont normally happen. The timeout is a single fixed number that is created from those values. The only way that can happen is if you are using the “per different topic” option.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 September 2018 09:08 UTC](https://discourse.nodered.org/t/rate-limit-questions-and-midi-question/3557/9 "2018-09-30T09:08:19Z")

</div>

> [@dceejay](#):
>
> ???? I hope it doesn’t do that. Please share a flow that shows that.

I can't reproduce the effect I was (literally 🙂 ) seeing - so I withdraw my comment

If I see it again - I'll re-raise it on original thread

Sorry for the thread deviation
