Forum Rule: Always post complete source code & details to reproduce any issue!

Thread: Audible clicks when switching waveforms

1. Audible clicks when switching waveforms

Hi, so I'm working on a wavetable synth and the biggest issue I'm having is audible clicks when switching between waveforms. This is happening in the waveform example sketch with the included waveforms (most noticeable with the sine, triangle, and variable triangle i.e. the ones with less harmonics) as well as my arbitrary waveforms, which are all vaguely sineish.

I looked at this up close in my DAW and it appears the clicking is caused by the waveforms switching at any particular point in their phase. So at any point in the phase when it switches, if the first waveform is at a higher or lower value than the second it's creating that sound from the abrupt transition.

So my question is how can I get the waveform to wait till the phase is 360.0 (when the waveform values are ~0) to switch? Something like this:
Code:
```    if  (button0.fallingEdge ())
count = count + 1;

if  (count == 1)
if (waveform1.phase (360.0))

waveform1.arbitraryWaveform(wave1, 1000);

if  (count == 2)
if (waveform1.phase (360.0))

waveform1.arbitraryWaveform(wave2, 1000);

//etc```
Now obviously if I do this the void function won't return a Boolean and I'm not savvy enough to go about it another way, so does anyone have any ideas?

Thanks

2. One way would be to use AudioEffectEnvelope to shape the start and end of each wave so that it ramps up from, and down to, zero. Depending on the length of the ramp, it should at least soften the click.
The only problem with this is if the switch from one wave to another must occur at a specific time. If the ramp down at the end of the signal is, for example 3ms, the signal will play for 3ms after you've told it to stop. You then have to take this into account when switching to another waveform.

An alternative would be to use AudioRecordQueue to monitor the generated audio. Normally you would just throw these away but when the waveform is to be switched, you will know the value of the last sample. From that value you can determine what the phase of the new waveform should be and use that to set waveform1.phase(angle); just before you start the new signal. I haven't tried this but I think it should work and would give you more control than using AudioEffectEnvelope.

Pete

3. Thanks I will try these. I have tried various combinations of lowering the cutoff frequency and fade ins and outs when switching but none were totally successful.

4. So I've been trying these suggestions, which I greatly appreciate, and it's still not working. The envelope is acting about the same as the fade object. And the audiorecordqueue method requires way too much calculation for my feeble mind, seeing as I have multiple arbitrary waveforms.
I think that using the phase function as a Boolean would work well. Does anyone have any other methods/suggestions?
Thanks

5. It's probably simpler to fade quickly out the old waveform and to fade the new one in afterwards or simultaneously. IIRC there is an ADSR object in the audio lib for that.

6. Thanks I'll try that again. Actually I've got good results with fade ins and fade outs with a low pass filter set at 500 hertz. Just cant have high frequency fun.

7. But how you cou want to produce audio then with a LPF at 500Hz? Typically wavetables are faded the smoothed way anyway so, there should be only a little demand for cross fading to avoid such issues. Hwo many WTs are you using? With how many frequency partitions?

8. Not sure what you mean by 'faded the smoothed way' if you could elaborate. I've got 6 right now, I plan on adding more. If by frequency partitions you mean band- limited no they're not, the waveforms are all sine-like so I haven't had any aliasing issues yet, even without the filter.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•