# Dsp::oversampling factor

**URL:** <https://forum.juce.com/t/dsp-oversampling-factor/30223>\
**Category:** General JUCE discussion\
**Created:** [November 7, 2018, 1:44pm UTC](https://forum.juce.com/t/dsp-oversampling-factor/30223 "2018-11-07T13:44:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [November 7, 2018, 1:44pm UTC](https://forum.juce.com/t/dsp-oversampling-factor/30223/1 "2018-11-07T13:44:18Z")

</div>

I’m a bit confused with the oversampling factor.  
from the `dsp::Oversampling` constructor doc:

> @param factor the processing will perform 2 ^ factor times oversampling

So I though that a factor of 4 would give me an oversampling factor of 16, but `getOversamplingFactor()` returns 256…  
The following test asserts :

```
int factor = 4;
dsp::Oversampling<float> os (1, factor, dsp::Oversampling<float>::filterHalfBandFIREquiripple, false);
jassert (std::pow (2, factor) == (int) os.getOversamplingFactor());

```

Does _oversampling factor_ have a different meaning in the constructor and in the `getOversamplingFactor()` method?

or it’s just a small bug no?  
oversamplingFactor is multiplied by 2 every time an oversampling stage is added (which is fine), but it’s initialised to 2^factor before that in the constructor. shouldn’t it just be initialised to 1 there ?

> <https://github.com/juce-framework/JUCE/blob/d51a44a58ec686b627d38168e301840288674645/modules/juce_dsp/processors/juce_Oversampling.cpp#L547>

---

<div class="post-metadata">

**Author:** ![IvanC](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ivanc/32/685_2.png) [@IvanC](https://forum.juce.com/u/IvanC)\
**Post date:** [November 7, 2018, 5:07pm UTC](https://forum.juce.com/t/dsp-oversampling-factor/30223/2 "2018-11-07T17:07:46Z")

</div>

Hello ! You are absolutely right, the line 547 is a typo, it should just be initialized to 1u instead.

Could you have a look @tom or @jules ? Thanks !

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [November 9, 2018, 10:25am UTC](https://forum.juce.com/t/dsp-oversampling-factor/30223/3 "2018-11-09T10:25:46Z")

</div>

I’ll get that fixed. Thanks for reporting.
