# Latency reporting for beginners

**URL:** <https://forum.juce.com/t/latency-reporting-for-beginners/23076>\
**Category:** General JUCE discussion\
**Created:** [June 27, 2017, 1:53pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076 "2017-06-27T13:53:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MIA-LABORATORIES](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MIA-LABORATORIES](https://forum.juce.com/u/MIA-LABORATORIES)\
**Post date:** [June 27, 2017, 1:53pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/1 "2017-06-27T13:53:06Z")

</div>

Hello fellow Jucers 🙂  
Is there a simple way for a newbie like me to do latency reporting to the host (cubase/logic)?

do i just include in the pluginprocessor.cpp in the processblock something like :

void AudioProcessor::setLatencySamples ( int newLatency )

am i way out of course?

Many thanks

---

<div class="post-metadata">

**Author:** ![ckhf](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@ckhf](https://forum.juce.com/u/ckhf)\
**Post date:** [June 27, 2017, 2:22pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/2 "2017-06-27T14:22:12Z")

</div>

That’s generally correct. You don’t need the `AudioProcessor::` part as your processor will be inherited from AudioProcessor.

It’s best practice to call `setLatencySamples()` from the constructor or `prepareToPlay()`. Calling it after the plugin has been initialized (e.g `prepareToPlay()`) makes some DAWs sad and can result in unexpected behavior or even crashes.

---

<div class="post-metadata">

**Author:** ![MIA-LABORATORIES](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MIA-LABORATORIES](https://forum.juce.com/u/MIA-LABORATORIES)\
**Post date:** [June 27, 2017, 2:51pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/3 "2017-06-27T14:51:52Z")

</div>

Excellent, many thanks for that,  
do i have to define the number of samples ?  
eg. setLatencySamples(225) ?  
is there any example project?  
apologies for my ignorance 🙂

---

<div class="post-metadata">

**Author:** ![MIA-LABORATORIES](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MIA-LABORATORIES](https://forum.juce.com/u/MIA-LABORATORIES)\
**Post date:** [June 27, 2017, 4:39pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/4 "2017-06-27T16:39:09Z")

</div>

just adding  
void setLatencySamples ();  
is not enough… i still get the same delay…  
am i missing something ?

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [June 27, 2017, 4:50pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/5 "2017-06-27T16:50:24Z")

</div>

You just need to make the setLatency call in a suitable place in your code (the constructor or prepareToPlay), you should not add a new function named setLatency.

---

<div class="post-metadata">

**Author:** ![MIA-LABORATORIES](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MIA-LABORATORIES](https://forum.juce.com/u/MIA-LABORATORIES)\
**Post date:** [June 27, 2017, 5:30pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/6 "2017-06-27T17:30:02Z")

</div>

Worked like a charm 🙂

setLatencySamples(226.015);

is that correct though?

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [June 27, 2017, 5:31pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/7 "2017-06-27T17:31:57Z")

</div>

The setLatencySamples call takes an integer, so your floating point value is not preserved. (Where are you getting that number from?)

---

<div class="post-metadata">

**Author:** ![MIA-LABORATORIES](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MIA-LABORATORIES](https://forum.juce.com/u/MIA-LABORATORIES)\
**Post date:** [June 27, 2017, 6:55pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/8 "2017-06-27T18:55:50Z")

</div>

thanks Xenakios,

I am geting the number from Smaart  
I take as a reference a track without the plugin and I measure it against the track with the plugin and I get 5.12 ms  
then i do 44100\*0.00512 = 225.792 to convert ms to samples  
so it is 225.792 I want to use and not 226.015 I wrote earlier but still is the same problem with the floating point number…  
should I just ignore the . part and round up to 226 ?  
is this the way to go about it anyway?

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [June 27, 2017, 7:02pm UTC](https://forum.juce.com/t/latency-reporting-for-beginners/23076/9 "2017-06-27T19:02:59Z")

</div>

Set your DAW to Samples and bounce to a new track with different presets and check the difference between the source and destination… and that will give you your latency in samples. Some algorithms have variable latency – so you need to check if yours is constant or not.

Rail
