Hi JUCE,

I am trying to implement a band limited / anti aliasing pulse width modulated square wav.

I have been hacking into this code

The source is here:

I thought if I implemented this method I might be able to make a bandlimited PWM from 2 SAWs put together :

“Take an upramping sawtooth and its inverse, a downramping sawtooth. Adding these two waves

with a well defined delay between 0 and period (1/f)

results in a square wave with a duty cycle ranging from 0 to 100%.”

https://www.musicdsp.org/en/latest/Synthesis/8-pulsewidth-modulation.html

The SAW looks like this :

m_sharp is a sweepable value between zero and one acting as a sort of low pass filter from the sounds of it .

```
m_srOverFour = m_sampleRate / 4.f;
// SAW
maxHarms = m_srOverFour / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
pos = m_pointer_pos + 0.5f;
if (pos >= 1.f)
pos -= 1.f;
pos = pos * 2.f - 1.f;
value = -(pos - tanhf(numh * pos) / tanhf(numh));
```

Naively I tried this with no luck :

```
{maxHarms = m_srOverFour / m_freq;
numh = m_sharp * 46.f + 4.f;
if (numh > maxHarms)
numh = maxHarms;
pos = m_pointer_pos + 0.5f;
if (pos >= 1.f)
pos -= 1.f;
pos = pos * 2.f - 1.f;
double valueOne = -(pos - tanhf(numh * pos) / tanhf(numh));
pos = pos + 0.5f;
if (pos >= 1.f)
pos -= 1.f;
pos = pos * 2.f - 1.f;
double valueTwo = 1/(-(pos - tanhf(numh * pos) / tanhf(numh)));
value = valueOne + valueTwo;
break;}
```

Can anyone help me here?

Where should I go for help ??

Sean