phjanderson
Member
I'm working on a polyphonic synthesizer project using a Teensy 4.1 and a PCM5102a DAC (the small cheap purple boards from AliExpress). I noticed a slight tick / pop at the beginning of each note when using a slow attack / release. The volume of the each oscillator is relatively low because it's a polyphonic multi-oscillator synthesizer, which makes the tick / pop more audible.
After digging through the datasheet I figured that it is probably the DAC entering / exiting power save mode. Using an oscilloscope I see that BCK and LCK on the DAC board keep their constant frequency but DIN gets a constant 0 volt when audio turns off. If I understand the datasheet correctly, this shouldn't trigger the DAC to go into power saving, but I hear a tick / pop nonetheless.
I made a sketch to reproduce the issue (see below).
The workaround I found is to add a -1 integer (=-1.0f / 32768.0f in float) offset to the audio stream (using a mixer and DC). This can be reproduced by un-commenting the following line in the sketch:
The offset is so minute that it shouldn't have an impact on the audio output. This makes the tick / pop disappear completely.
I hope this workaround is of use to anyone else experiencing the same problem...
Does anyone perhaps know what exactly is going on here and if a better solution exists?
Code to reproduce the issue (volume is quite low on purpose, please remember to turn the volume of your headphones or speakers down again after testing this sketch):
After digging through the datasheet I figured that it is probably the DAC entering / exiting power save mode. Using an oscilloscope I see that BCK and LCK on the DAC board keep their constant frequency but DIN gets a constant 0 volt when audio turns off. If I understand the datasheet correctly, this shouldn't trigger the DAC to go into power saving, but I hear a tick / pop nonetheless.
I made a sketch to reproduce the issue (see below).
The workaround I found is to add a -1 integer (=-1.0f / 32768.0f in float) offset to the audio stream (using a mixer and DC). This can be reproduced by un-commenting the following line in the sketch:
C:
//dc1.amplitude(-1.0f/32768.0f);
I hope this workaround is of use to anyone else experiencing the same problem...
Does anyone perhaps know what exactly is going on here and if a better solution exists?
Code to reproduce the issue (volume is quite low on purpose, please remember to turn the volume of your headphones or speakers down again after testing this sketch):
C:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=219,160
AudioEffectEnvelope envelope1; //xy=421,160
AudioSynthWaveformDc dc1; //xy=430,260
AudioMixer4 mixer1; //xy=650,220
AudioOutputI2S i2s1; //xy=850,220
AudioConnection patchCord1(waveform1, envelope1);
AudioConnection patchCord2(envelope1, 0, mixer1, 0);
AudioConnection patchCord3(dc1, 0, mixer1, 1);
AudioConnection patchCord4(mixer1, 0, i2s1, 0);
AudioConnection patchCord5(mixer1, 0, i2s1, 1);
// GUItool: end automatically generated code
void setup() {
AudioMemory(10);
envelope1.attack(1000.0f);
envelope1.decay(2000.0f);
envelope1.sustain(1.0f);
envelope1.release(1000.0f);
waveform1.begin(0.001f, 880.0f, WAVEFORM_SINE);
// add a 1 bit DC offset to prevent a pop / tick sound whenever the envelope becomes silent, probably due to the DAC switching to power-saving mode
//dc1.amplitude(-1.0f/32768.0f);
}
void loop() {
envelope1.noteOn();
delay(1000);
envelope1.noteOff();
delay(3000);
}