# About double precision (AudioProcessor, AudioBuffer)

**URL:** <https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648>\
**Category:** General JUCE discussion\
**Created:** [March 28, 2024, 2:17am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648 "2024-03-28T02:17:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 28, 2024, 2:17am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/1 "2024-03-28T02:17:12Z")

</div>

Hello,  
in AudioProcessor and AudioBuffer  
it looks it can use double precision instead of float

```
enum ProcessingPrecision
{
    singlePrecision,
    doublePrecision
};

```

If it’s better, I want to use double precision

So, my questions are

1. Is it better to use double precision in audio processing ?  
I have sufficient memories and HDD spaces  
My audio interface is Audient ID22 and I have RME Converter, native instruments, Dorico, Ableton Live etc

2. If yes, I will really appreciate if you can advise me how to do this in C++ programming

Thank you

---

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [March 28, 2024, 2:58am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/2 "2024-03-28T02:58:24Z")

</div>

> Is it better to use double precision in audio processing

Not always. Although the calculation almost takes the same time, double number requires a larger bandwidth and you cannot hear the difference. But there are cases where double precision is a must, e.g., a low pass/shelf at 10Hz.

> If yes, I will really appreciate if you can advise me how to do this in C++ programming

Suppose we have `juce::AudioBuffer<float> &buffer` from `processBlock()` and pre-allocated `juce::AudioBuffer<double> doubleBuffer`, you can copy data as follows:

```cpp
doubleBuffer.makeCopyOf(buffer, true); // copy data to double precision buffer
// process doubleBuffer;
buffer.makeCopyOf(doubleBuffer, true); // copy data back to buffer

```

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 28, 2024, 3:34am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/3 "2024-03-28T03:34:17Z")

</div>

Hello, Zishu.  
Thank you for your help

Is the source code you showed me about using AudioBuffer (float) in processBlock ?

Then, isn’t it possible use only AudioBuffer (double) in process processBlock  
without copying or converting data from double to float ?

The link below talks about double version of processBlock

> [@processBlock with float vs double?](https://forum.juce.com/t/processblock-with-float-vs-double/43595?page=2):
>
> Hi friends, I’m looking through the AudioProcessor base class, and I see that there are two versions of the virtual void processBlock(): one that takes an AudioBuffer\<float\>, and one that takes an AudioBuffer\<double\>. If I want my plugin to work with either 32-bit or 64-bit systems, should I implement both of these methods? Does everything have to be written twice, with two versions of any internal buffers…? or is there some way of doing a function template…? Thanks in advance for help!

---

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [March 28, 2024, 3:45am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/4 "2024-03-28T03:45:23Z")

</div>

Yes it is OK if your host support that (I am not sure whether all hosts support double precision buffer input, maybe someone else can confirm this for you).

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 28, 2024, 3:57am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/5 "2024-03-28T03:57:40Z")

</div>

Thank you, I will search this forum about this issue.  
So have a nice day and see you again, Zishu.  
Take care

---

<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:** [March 28, 2024, 1:53pm UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/6 "2024-03-28T13:53:47Z")

</div>

i use double precision a lot because bugs that are introduced due to float being too small can be really sneaky, so unless i need some performance optimisations i just keep things double

---

<div class="post-metadata">

**Author:** ![Toddler-Boy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/toddler-boy/32/2007_2.png) [@Toddler-Boy](https://forum.juce.com/u/Toddler-Boy)\
**Post date:** [March 28, 2024, 4:31pm UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/7 "2024-03-28T16:31:27Z")

</div>

Doubles are mostly useful for phasors and alike, but not for the audio signal itself. A simple float is just fine there.

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 29, 2024, 12:55am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/8 "2024-03-29T00:55:55Z")

</div>

Hello, Florian  
As you mentioned, I also like double precision.  
I will consider double in my coding  
Thank you and have a nice day, Florian

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 29, 2024, 1:01am UTC](https://forum.juce.com/t/about-double-precision-audioprocessor-audiobuffer/60648/9 "2024-03-29T01:01:55Z")

</div>

Hello, Michael  
Thank you for your valuable information  
You helped me a lot !  
See you again, Michael
