About double precision (AudioProcessor, AudioBuffer)

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

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:

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

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

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).

2 Likes

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

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

1 Like

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

1 Like

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

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