# The big list of JUCE tips and tricks (from n00b to pro)

**URL:** <https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193>\
**Category:** General JUCE discussion\
**Created:** [July 16, 2024, 2:30pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193 "2024-07-16T14:30:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 2:30pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/1 "2024-07-16T14:30:05Z")

</div>

I found this blog post I started years ago when first learning JUCE. I kept procrastinating publishing it. I figure others can help fix / add missing things, so here it is:

> **[The big list of JUCE tips and tricks (from n00b to pro) · Melatonin](https://melatonin.dev/blog/big-list-of-juce-tips-and-tricks/)**
>
> Years of learning things the hard way, lovingly hand-squeezed into a brain melting blog post.

Most of the tips target beginners. But there’s some advanced things in there too.

Anything look sus? What else should I add?

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [July 16, 2024, 2:43pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/2 "2024-07-16T14:43:55Z")

</div>

Few things I would add:

- Sometimes in order to debug, you need to log things to a file. `spdlog` is a nice library for that. Or the JUCE FileLogger class.
- Pluginval is your friend. Run it regularly or better, add it to your CI pipeline
- Regularly run pluginval and your plugin both built with ASAN to catch potential memory related crashes.
- Statically link the Windows runtime to save trouble
- Be careful with dependencies between your processor and your editor. Use Async messaging such as ValueTreePropertyChanged. Don’t use lambda functions owned by the Editor that might be called the Processor!
- Use clang-format and forget about manual formatting
- For accessibility, avoid using `juce::Graphics::drawText` and use Labels instead. Your visually impaired users will thank you.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 16, 2024, 2:45pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/3 "2024-07-16T14:45:30Z")

</div>

> [@adamwilson](#):
>
> For accessibility, avoid using `juce::Graphics::drawText` and use Labels instead. Your visually impaired users will thank you.

I missed that one, thanks for that hint

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 2:46pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/4 "2024-07-16T14:46:39Z")

</div>

> [@adamwilson](#):
>
> For accessibility, avoid using `juce::Graphics::drawText` and use Labels instead.

Ooooh, this one is good, thank you.

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 2:46pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/5 "2024-07-16T14:46:59Z")

</div>

> [@adamwilson](#):
>
> - Statically link the Windows runtime to save trouble

I’ll put this one in too, only recently ran into this!

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [July 16, 2024, 2:49pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/6 "2024-07-16T14:49:13Z")

</div>

This is a good one!

> use `VBlankAttachment` instead of the timer to ensure your component is repainted on the very next frame.

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:37pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/7 "2024-07-16T15:37:24Z")

</div>

For the AU not appearing another good tip is to set your version number to 0 for debug builds and your plugin will be auto scanned every time.

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:38pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/8 "2024-07-16T15:38:42Z")

</div>

Probably need one about AUv3 and needing to build and run the .app, not the .appex

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 3:39pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/9 "2024-07-16T15:39:46Z")

</div>

> [@anthony-nicholls](#):
>
> Probably need one about AUv3 and needing to build and run the .app, not the .appex

Yes please. I’ve never done this, what’s the short story?

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 3:41pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/10 "2024-07-16T15:41:19Z")

</div>

> [@anthony-nicholls](#):
>
> set your version number to 0 for debug builds and your plugin will be auto scanned every time.

🤯 added!

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:41pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/11 "2024-07-16T15:41:55Z")

</div>

Oh and an absolute classic.

Don’t call `setBufferedToImage()` on a component that has children!! Instead make a sibling component that does the drawing and call `setBufferedToImage()` on that component instead.

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:43pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/12 "2024-07-16T15:43:57Z")

</div>

> [@sudara](#):
>
> Yes please. I’ve never done this, what’s the short story?

From memory the first time you try to build/run AUv3 the best solution is to enable the stand alone target and AUv3 target then build both and run the stand alone first. That should install the AUv3 and with any luck it should show up in Logic 🤞

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:45pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/13 "2024-07-16T15:45:39Z")

</div>

> [@sudara](#):
>
> > [@anthony-nicholls](#):
> >
> > set your version number to 0 for debug builds and your plugin will be auto scanned every time.
> 
> 🤯 added!

It’s been a long time since I check this was indeed working but I got it from Apple support many years ago, I assume it still applies, when I do it I don’t notice myself needing to run the kill command much so I think it still works, but I could be kidding myself.

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 3:46pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/14 "2024-07-16T15:46:16Z")

</div>

> [@anthony-nicholls](#):
>
> Don’t call `setBufferedToImage()` on a component that has children!

Is this to avoid also caching the children? So if you want the children to still update, you need to move the “expensive parent painting” elsewhere? Or am I missing something else…

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [July 16, 2024, 3:49pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/15 "2024-07-16T15:49:16Z")

</div>

> [@sudara](#):
>
> Is this to avoid also caching the children? So if you want the children to still update, you need to move the “expensive parent painting” elsewhere? Or am I missing something else…

No there’s an edge case that means every time a child repaints, the parent will be forced to repaint its image even if that image hasn’t changed. If you have exactly the same thing but with a sibling rather than a parent the image won’t be invalidated, so when it’s made to repaint it can use the cached image.

---

<div class="post-metadata">

**Author:** ![sudara](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/sudara/32/8071_2.png) [@sudara](https://forum.juce.com/u/sudara)\
**Post date:** [July 16, 2024, 3:52pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/16 "2024-07-16T15:52:19Z")

</div>

> [@anthony-nicholls](#):
>
> every time a child repaints, the parent will be forced to repaint its image even if that image hasn’t changed

Ah wow, I don’t think I knew that. I’m assuming it’s considered an “unresolvable bug” for Reasons, otherwise it would eventually be fixed?

Thanks Anthony!!

---

<div class="post-metadata">

**Author:** ![kamedin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kamedin/32/11711_2.png) [@kamedin](https://forum.juce.com/u/kamedin)\
**Post date:** [July 16, 2024, 4:46pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/17 "2024-07-16T16:46:00Z")

</div>

> [@anthony-nicholls](#):
>
> Don’t call `setBufferedToImage()` on a component that has children!! Instead make a sibling component that does the drawing

I assume you mean a child, as in a sibling of the children?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 16, 2024, 8:34pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/18 "2024-07-16T20:34:03Z")

</div>

Sibling to the component that has `setBufferedToImage (true);`

```auto
// instead of:
setBufferedToImage (true);
addAndMakeVisible (foreground);

// do this:
background.setBufferedToImage (true);
addAndMakeVisible (background);
addAndMakeVisible (foreground);

```

---

<div class="post-metadata">

**Author:** ![kerfuffle](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kerfuffle/32/11805_2.png) [@kerfuffle](https://forum.juce.com/u/kerfuffle)\
**Post date:** [July 16, 2024, 9:16pm UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/19 "2024-07-16T21:16:27Z")

</div>

I tried it recently and it didn’t work for me (could be something on my end). However, bumping the version does still work.

---

<div class="post-metadata">

**Author:** ![benvining](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/benvining/32/9922_2.png) [@benvining](https://forum.juce.com/u/benvining)\
**Post date:** [July 17, 2024, 12:14am UTC](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193/20 "2024-07-17T00:14:31Z")

</div>

Regarding including the build type as a compile definition, the correct way to do this for multi-config generators is:

```cpp
target_compile_definitions(YourPlugin PRIVATE "BUILD_CONFIG=$<CONFIG>")

```

[Next page](https://forum.juce.com/t/the-big-list-of-juce-tips-and-tricks-from-n00b-to-pro/62193.md?page=2)
