# JUCE synth makes sound in debug but not release

**URL:** https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761
**Category:** General JUCE discussion
**Created:** [June 8, 2024, 8:18pm UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761 "2024-06-08T20:18:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![loveslap](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@loveslap](https://forum.juce.com/u/loveslap)
#### Post date: [June 8, 2024, 8:18pm UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/1 "2024-06-08T20:18:04Z")

</div>

No idea what to look at here but subject says it all.

---

<div class="post-metadata">

### Author: ![rcohen](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@rcohen](https://forum.juce.com/u/rcohen)
#### Post date: [June 9, 2024, 2:26am UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/2 "2024-06-09T02:26:40Z")

</div>

I don’t have the solution to your problem, but I will mention that uninitialized memory is handled differently in debug versus release builds. Is it possible that somewhere in your audio process block you are relying on the state of an uninitialized variable?

Good luck!

---

<div class="post-metadata">

### Author: ![loveslap](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@loveslap](https://forum.juce.com/u/loveslap)
#### Post date: [June 9, 2024, 9:46am UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/3 "2024-06-09T09:46:33Z")

</div>

I will check that thanks.  
Tricky, needing to debug release is awkward.

---

<div class="post-metadata">

### Author: ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)
#### Post date: [June 9, 2024, 2:25pm UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/4 "2024-06-09T14:25:24Z")

</div>

I’ve used a Juce’s logger to check vars for NaN a couple of times. For me It’s sometimes the order of things I mixed up with, which can cause uninitialised vars.

Juce’s file Logger…

```auto
//class member:
std::unique_ptr<FileLogger> logger;

// In constructor...
logger = std::unique_ptr<FileLogger>(FileLogger::createDateStampedLogger(logLocation, "mylog", ".txt", "Plug-in logging"));

// Writing to Logger...
if (isnan(myVar) logger->logMessage("myVar is NaN"); //...any Juce string
// You can log anything you want in Release, which is pretty handy.

```

People coming from higher level languages like JS tend to forget variables are **not** set to zero when declared in C++. They can be anything non float, like 0xFFFFFFFF. NaN’s can cause a cascade of errors, if included in calculations.

---

<div class="post-metadata">

### Author: ![Nitsuj70](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nitsuj70/32/12754_2.png) [@Nitsuj70](https://forum.juce.com/u/Nitsuj70)
#### Post date: [June 10, 2024, 4:50am UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/5 "2024-06-10T04:50:54Z")

</div>

Here’s what I do. I have a function that works on AudioBuffer or AudioBlock that returns true if it detects rogue float values (nan, inf etc). Assert on that at the end of processBlock to catch them in debug.

Then I have a similar function that detects rogue values but zeros them out. Also at the end of processBlock, but makes it into release builds. Just as a safety net.

---

<div class="post-metadata">

### Author: ![Marcusonic](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Marcusonic](https://forum.juce.com/u/Marcusonic)
#### Post date: [June 10, 2024, 8:40am UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/6 "2024-06-10T08:40:01Z")

</div>

generates a continuous sine wave in processblock and ignores everything else. If the wave is heard, the problem is somewhere in your application. Just ignore parts of your application until you hear something, continue doing this until you locate the problem.

---

<div class="post-metadata">

### Author: ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)
#### Post date: [June 10, 2024, 12:16pm UTC](https://forum.juce.com/t/juce-synth-makes-sound-in-debug-but-not-release/61761/7 "2024-06-10T12:16:05Z")

</div>

You could of course, if you can, just comment out various DSP loop function calls until it works! 🙂

But in the end it’s nearly always lack of initialisation that causes issues with debug/release differences.
