"Plop" while using PULSE or SQUARE waveforms with envelope

Status
Not open for further replies.

lg87783

Member
Hi fellows,

I am quite a newbee with Teensy and I am experimenting the wonderful audio library... as many of you, I am building a mono synth with this lib and it sounds great (specially with the new ladder filter!!!).

I am facing a curious behaviour with both envelope and waveform generator(s). When using square and pulse waveforms, when attack/decay/relase times are short enough (5-10ms), a "plop" can be heard on each note-on/note off. This "plop" is louder if the pulse width is short. This does not happen with other waveforms (sine, sawtooth, reverse sawtooth).

It is not a "click" which has been described in some earlier thread.
I tried some different parameters such as releaseNoteOn , along with band limited waveforms which didn't change anything.

The problem may be reproduced with the code below using Teensy 4.0 and audio board.
(Sorry the result is awfull for your ears... the settings of both envelope and waveform are "optimized" to point out the problem...)

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=210,188
AudioEffectEnvelope      envelope1;      //xy=385,189
AudioOutputI2S           i2s1;           //xy=571,187
AudioConnection          patchCord1(waveform1, envelope1);
AudioConnection          patchCord2(envelope1, 0, i2s1, 0);
AudioConnection          patchCord3(envelope1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=483,73
// GUItool: end automatically generated code


void setup() {
  AudioMemory(20);
  sgtl5000_1.enable();
  sgtl5000_1.lineOutLevel(13);
  
  // put your setup code here, to run once:
  waveform1.begin(0.75f,880.f,WAVEFORM_BANDLIMIT_PULSE);
  waveform1.pulseWidth(0.01f);
  waveform1.offset(0.);
  waveform1.phase(0);

  envelope1.delay(0.0f);
  envelope1.attack(0.0f);
  envelope1.hold(0.0f);
  envelope1.decay(5.0f);
  envelope1.sustain(0.75f);
  envelope1.release(1.0f);
  envelope1.releaseNoteOn(5.0f);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  envelope1.noteOn();
  delay(50);
  envelope1.noteOff();
  delay(50);
  
}

After some investigations, it appeared that adjusting the offset of the waveform to a value around (0.1) didn't solved the problem, but diminished the impact of it.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=210,188
AudioEffectEnvelope      envelope1;      //xy=385,189
AudioOutputI2S           i2s1;           //xy=571,187
AudioConnection          patchCord1(waveform1, envelope1);
AudioConnection          patchCord2(envelope1, 0, i2s1, 0);
AudioConnection          patchCord3(envelope1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=483,73
// GUItool: end automatically generated code


void setup() {
  AudioMemory(20);
  sgtl5000_1.enable();
  sgtl5000_1.lineOutLevel(13);
  
  // put your setup code here, to run once:
  waveform1.begin(0.75f,880.f,WAVEFORM_BANDLIMIT_PULSE);
  waveform1.pulseWidth(0.5f);
  waveform1.offset(0.095);
  waveform1.phase(0);

  envelope1.delay(0.0f);
  envelope1.attack(0.0f);
  envelope1.hold(0.0f);
  envelope1.decay(5.0f);
  envelope1.sustain(0.75f);
  envelope1.release(1.0f);
  envelope1.releaseNoteOn(5.0f);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  envelope1.noteOn();
  delay(50);
  envelope1.noteOff();
  delay(50);
  
}

Is there something I missed ? Do you guys have seen this issue before?
 
You will always get that "plop" or "click" when you turn a sound on or off very suddenly. You need to ramp the sound up and then down to avoid this.
Try these settings, as a start:
Code:
  envelope1.delay(0.0f);
  envelope1.attack(20.0f);
  envelope1.hold(5.0f);
  envelope1.decay(5.0f);
  envelope1.sustain(5.0f);
  envelope1.release(15.0f);
  envelope1.releaseNoteOn(5.0f);

Pete
 
Thank you Pete, for the quick response...
However, with your settings, a quite significant "burden" can still be heard, while 20ms for attack/release is quite smooth...
 
I suspect the "pop" is mainly the low frequency component of a discontinuity - as I remember it the standard pulse waveform
has DC offset unless at 50% duty cycle - the bandlimited implementation of mine fixed that (at least to first order) IIRC

Anyway that may explain why other waveforms only display a "click" as the low frequecy energy is much smaller.
 
I suspect the "pop" is mainly the low frequency component of a discontinuity - as I remember it the standard pulse waveform
has DC offset unless at 50% duty cycle - the bandlimited implementation of mine fixed that (at least to first order) IIRC

Anyway that may explain why other waveforms only display a "click" as the low frequecy energy is much smaller.

Thanks Mark,

The DC offset of pulse and square waveforms is probably one part of the explanation. However as you can see (hear) in the examples provided, this issue occurs with either the BAND_LIMIT waveforms or the "classic" pulse and square waveforms.

Lionel
 
Last edited:
Hopefully I'll get round to looking at this - perhaps I misremembered what the bandlimited stuff does for DC offset.
 
Hopefully I'll get round to looking at this - perhaps I misremembered what the bandlimited stuff does for DC offset.

Many thanks! I'll stay in touch for your findings...
These low frequency "plops" make me think of an aliasing issue (I think you used the term "component discontinuity") which might (?) happen during the envelope processing because of this DC offset more likely when using short attack, decay or release times...
 
Status
Not open for further replies.
Back
Top