# Harsh noise on plugin start

**URL:** <https://forum.juce.com/t/harsh-noise-on-plugin-start/49684>\
**Category:** Audio Plugins\
**Created:** [January 15, 2022, 10:21am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684 "2022-01-15T10:21:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucretio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lucretio/32/10718_2.png) [@Lucretio](https://forum.juce.com/u/Lucretio)\
**Post date:** [January 15, 2022, 10:21am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/1 "2022-01-15T10:21:28Z")

</div>

My audio plugin emits an harsh high frequency noise when it starts once every 6/7 times. It is a simple wavetable synthesiser with an exponential decay envelope. The wavetable is generated by reading a .wav file, and there should be no dangling pointers as I am using only unique\_pointers.  
My wavetable class is modelled on the juce tutorial and the envelope is modelled on the Audio Programming Book examples  
Apart from that noise on start-up the plugin works smoothly.  
I know it is like searching a needle into a haystack but which other things should I keep in mind while searching for my bug?  
In the plugin editor I have many images that I get as ImageCache from binary data. Could that be the problem?  
P.s. I am not making the #1 beginner mistake

Thanks for any tip.

---

<div class="post-metadata">

**Author:** ![Fandusss](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@Fandusss](https://forum.juce.com/u/Fandusss)\
**Post date:** [January 15, 2022, 11:12am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/2 "2022-01-15T11:12:36Z")

</div>

You can opt to return a GenericAudioProcessorEditor to remove your editor from the equation and quickly rule that out.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [January 15, 2022, 3:49pm UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/3 "2022-01-15T15:49:01Z")

</div>

my initial guess would be that you resized some buffer (probably in prepareToPlay or so), but didn’t give it a default value of 0. if you use std::vector as audio buffer, always use the 2nd optional arg of resize to make sure that it’s not garbage values, but 0.

buffer.resize(blockSize, 0.f);

when resizing juce::AudioBuffer there’s also an option to clear it on setSize

---

<div class="post-metadata">

**Author:** ![Lucretio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lucretio/32/10718_2.png) [@Lucretio](https://forum.juce.com/u/Lucretio)\
**Post date:** [January 17, 2022, 9:21am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/4 "2022-01-17T09:21:48Z")

</div>

it was a good idea to try it, but noise is till there ;(

---

<div class="post-metadata">

**Author:** ![bayu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bayu/32/10757_2.png) [@bayu](https://forum.juce.com/u/bayu)\
**Post date:** [January 17, 2022, 9:39am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/5 "2022-01-17T09:39:37Z")

</div>

Sometimes it’s caused by uninitialized variables.

---

<div class="post-metadata">

**Author:** ![Lucretio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lucretio/32/10718_2.png) [@Lucretio](https://forum.juce.com/u/Lucretio)\
**Post date:** [January 17, 2022, 10:33am UTC](https://forum.juce.com/t/harsh-noise-on-plugin-start/49684/6 "2022-01-17T10:33:28Z")

</div>

it was indeed a resized buffer and clearing the extra space with setSize solved the problem. thank you very much.
