# Non-silent audio when panning

**URL:** <https://forum.juce.com/t/non-silent-audio-when-panning/25537>\
**Category:** General JUCE discussion\
**Created:** [December 12, 2017, 11:50am UTC](https://forum.juce.com/t/non-silent-audio-when-panning/25537 "2017-12-12T11:50:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffersonBledsoe](https://avatars.discourse-cdn.com/v4/letter/j/bb73d2/32.png) [@JeffersonBledsoe](https://forum.juce.com/u/JeffersonBledsoe)\
**Post date:** [December 12, 2017, 11:50am UTC](https://forum.juce.com/t/non-silent-audio-when-panning/25537/1 "2017-12-12T11:50:40Z")

</div>

Probably a simple answer to this, but I can’t seem to find it. When using the code below to do some super simple panning, when a channel reaches hard left or hard right, there is still a very small audio output on the opposite channel still. Debugging shows that the value for currentSample drifts between 0 and -0. Any suggestions? C

```
 const float currentSample = (float) std::sin (currentAngle);
 buffer->addSample (leftChannel, sampleIndex, currentSample * (1.0f - pan));
 buffer->addSample (rightChannel, sampleIndex, currentSample * pan);;

void AudioEngine::panLeft()
{
    if (pan > 0)
    {
        pan -= 0.1;
    }
    if (pan > 0 && pan < 0.1)
    {
        pan = 0;
    }
}
```

---

<div class="post-metadata">

**Author:** ![Btodoroff](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Btodoroff](https://forum.juce.com/u/Btodoroff)\
**Post date:** [December 13, 2017, 5:26am UTC](https://forum.juce.com/t/non-silent-audio-when-panning/25537/2 "2017-12-13T05:26:52Z")

</div>

Try removing the "pan \> 0 && " from the second if statement. It’s not needed because if pan is negative you still want it set to zero. You may be getting a slightly negative pan value due to floating point precision error.
