Audio High pitch buzzing

Cosford

Well-known member
Hi,

Recently been working with the Audio library (which is excellent). I set up a configuration as follows:

AudioPlaySdWav => AudioMixer => AudioOutputAnalog (DAC)
AudioPlaySdWav

This is working excellently and I'm pleased with the results. However, even with a single track playing, I notice a (rather quiet) high pitch buzzing. This buzzing is only present whilst actually playing a track and stops immediately once the track has finished (or been stopped). I've attempted to use a DC block cap of 10uF in series with the DAC output, but this doesn't appear to solve the issue. The output of the cap is fed into an active amplifier.
I've added an additional 10uF cap to stabilise the 3.3v line, again to no effect.
I don't believe it is the samples themselves; I've tried samples made up by myself as-well as the recommended samples linked from JPRC's site. (None of which have this buzzing when played from a PC).

Is this normal? Or what can be done to clean that up?

Thanks in advance.
 
Last edited:
Usually these types of problems are due to ground loops. Without knowing what you're connecting to listen to the signal, and more specifically, how it's grounded, it's difficult to say what to try.

But here's some blind and very general suggestions anyway...

If Teensy doesn't need the computer, try running with a 5V power supply without any connection to your grounded PC. Use a "wall wart" that's isolated from ground.

Try using amplified computer speakers for listening, which are powered from a non-grounded wall wart.

As a last resort, perhaps try an audio isolation transformer.
 
Hiya, sounds like could be balanced / unbalanced ground issue. You using polarised cap in series with ground yeah?
Good way to test is run amplifier from totally separate dc supply (battery, not mains adaptor or usb from same PC etc) and that should eliminate it... Then you'll know it's the shared ground that causing the noise.

You using mono or stereo output?

Cheers

Andy.
 
Thanks for the replies,
The DAC output is connected to the anode of the electrolytic cap. The cathode is then connected to an input to a 100W stereo Karaoke amplifier (powered from mains), driving 2 4 Ohm speakers in series (for a total of 8 Ohms impedance as per the amplifier specs). The amplifier and teensy have their ground lines tied together via the amplifier input.

I am using mono output.


Thanks again.
 
Hey Cosford, the item Paul linked to is a neat little unit, not tried one of those before.

I've got same issue but mine was fixed for time being by using little AA battery operated MP3 speakers just while i'm testing.. But ultimately I'll be using one of these chaps:
http://uk.farnell.com/oep-oxford-el...nsformer-audio-1-1-1-1/dp/1689033?ost=A262A6E

Which is a 1:1 transformer, it'll do 2 channels despite you're only using one for mono. Essentially it's the tied ground between the teensy and the pre-amp / amp that's causing the noise / hum etc.

without too much time searching around, this is all you're really trying to achieve is to not have them be on same ground connection, see this page, it's for video but same principle using the transformer I linked above:
http://www.epanorama.net/newepa/2009/09/15/build-video-isolator/

I hope it helps :) I'll try to remember to come back here once i actually buy one myself once i'm ready to stripboard my circuit up so I can confirm or debunk ;)

Cheers

Andy
 
Thanks for the replies again.

So what you're saying, is that it's the teensy being grounded to the amp which is causing the issue? Why is it that this causes an issue? And why is it only apparent when playing a track and not otherwise?
 
Why is it that this causes an issue?

Ground loops are tricky, but usually the problem is ground currents related to non-audio signals flow through the audio ground wire. Being wire, it has small resistance and inductance, causing tiny voltage changes. The input to an audio amp (and your ear) are extremely sensitive, so those tiny changes in ground voltage are seen as a signal and amplified into sounds you can hear.

That's the why....

Since the Teensy and SD card need power, usually the only solution is running from an isolated power supply, or isolating the signals somehow.

An isolated audio board, like we discussed on that 24 bit audio board thread, would be the ultimate best sound (but expensive) solution.
 
Okay, thanks very much. It's not really an issue for me (given the environment that the application is designed for, no-one is realistically going to notice it), but I figured before I start looking at committing a PCB design, I'd see if it was something that could be cleaned up. =)
 
Hi again,

I've put together an audio amplifier circuit using the LM386, with just a gain of 20. This drives an 8 ohm speaker.
The entire thing is powered by a single 12v supply, with a LD33CV 3.3v linear regulator for the teensy and other circuitry. Now, if my understanding of ground loops is correct; should this not have alleviated the issue, as it has not.

I have put a 220uF electrolytic capacitor in series with the DAC output, and captured the following screenshots of what I believe may be the noise:

In this first image, you can see the track being played, but also the noise affecting it at regular intervals.
vG2hWKD.jpg


Expanding the scale by a factor of 0.1:
L18EaK2.jpg


and finally:
InTSp8L.jpg


This is the sketch I used to capture these waveforms:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

AudioPlaySdWav      player1;
AudioOutputAnalog   dac;
AudioMixer4         mixer;
AudioConnection     player1_line(player1, 0, mixer, 0);
AudioConnection     mixer_line(mixer, dac);

void setup()
{
  delay(500);
  Serial.begin(9600);
  AudioMemory(15);
  SPI.setSCK(14);
  if(!(SD.begin(15)))
  {
    while(1)
    {
      Serial.println("Failed access...");
      delay(500);
    }
  }
  else
    Serial.println("SD access success...");
  
  mixer.gain(0, 1.0);
  
  player1.play("SDTEST1.WAV");
}

void loop()
{}

Thanks in advance.
 
Last edited:
Hmm.. a guess: You're using 1.20?
if yes, can you please try 1.21test2 ?

Maybe one of the buffers crosses the ram-boundary, located exactly at the half of ram..
121 adresses this issue
 
Last edited:
Hmm.. a guess: You're using 1.20?
if yes, can you please try 1.21test2 ?

Maybe one of the buffers crosses the ram-boundary, located exactly at the half of ram..
121 adresses this issue

Thanks for the reply.
This was with 1.21 test 1 I believe. (It was whichever was the one that was initially available when the 1.21 forum thread went up). I hadn't realised there was a test 2 although I can try this too if it may make a difference.
 
Whatever's happening, I'm pretty sure it's not a memory fault due to a 16 or 32 bit access across the 1FFFFFFF to 2000000 barrier. Such a fault would cause all audio updates to stop, because the default fault handler is merely an infinite loop that completes USB and serial output, and responds to the auto-reboot request.

I'll take a look soon. Just cleared another project off my (tiny) workbench. Going to also look into that WAV distorted issue recently reported while I have the audio stuff set up....
 
Correction; it was with 1.21 test 2 that this is an issue.

I've used 2 different SD cards, one is a generic class 10 card from china; the other a class 4 samsung card. Both produce the same issue.

I've also tried with teensyduino 1.20 and the issue is present there too.

It seems it's present with any mono 44.1khz wav file (or at least in the half dozen ones from different sources I've used). I prepared a 1KHz sine wave as a .wav and whilst it outputs nicely, the distortion is present on the output waveform too. What's interesting, is the period between the noise segments is different; in this sin wave, the period is approximately 5.8ms as opposed to the ~2.9ms period in the SDTEST1 file. These periods are consistent on every play of each file.
It may also be worth noting the 2:1 scale of the period in the sine wave sample compared to the SDTEST1 sample. The periods seem to be independant of the version of teensyduino used.

I've no idea if any of these observations are helpful at all, but here they are anyway.


Thanks for looking into this.
 
Last edited:
Was this ever resolved? I'm having the same problem. I get a high pitched buzzing through DAC whenever audio files are played from SD on the audio board. It doesn't appear to happen when played from memory, only SD. I'm running the DAC signal through a 10uf cap into a powered amp. I have the amp on a dedicated battery, and another battery powering the teensy 3.1. I can provide a recording of the buzzing, but it sounds like EMI.

I would love to resolve this as I'm trying to use the L/R audio board channels in conjunction with a third DAC channel.
 
No, it wasn't. It's quiet enough that it's not a real issue for my application, although it would be nice to solve it. The issue was still present on the PCBs I designed and had made up, leading me to believe that it is a software issue, although at this time I don't have the time to investigate further (at least for now).
 
From the scope images I cannot see the horizontal scaling, but I'd say a ground loop has a more sinusoidal(ish) effect... Could it be due to the execution of some periodic task, such as reading from the SD card?
If so, maybe some aditional decoupling capacitors on the power supply could help? (i see you have a 10uF cap already in place)
 
Last edited:
Could it be due to the execution of some periodic task, such as reading from the SD card?

true, weird that it happens every 2.9ms ( it does, right ?). but in that case it should be noticeable when using a/the codec, too, no? jerware seems to say though the audio board plays fine; i haven't noticed anything either (different board). that said, a/the codec will have its own supply though, not sure about how/if DAC and SD cards might interact if both were run off the teensy regulated 3v3?

is it SD in general? ie both raw and wav, or just wav? i'm guessing the former?
 
true, weird that it happens every 2.9ms ( it does, right ?). but in that case it should be noticeable when using a/the codec, too, no? jerware seems to say though the audio board plays fine; i haven't noticed anything either (different board). that said, a/the codec will have its own supply though, not sure about how/if DAC and SD cards might interact if both were run off the teensy regulated 3v3?

is it SD in general? ie both raw and wav, or just wav? i'm guessing the former?

I'm using RAW files and Cosford is using WAV, so it looks like both. And yes -- it is only when SD is accessed. It will buzz when sound is played through the audio board outputs OR the DAC, as long as the source file is on SD. Interestingly, if you stream two sound files off SD simultaneously the buzz appears to double in pitch. If the sound is stored in flash memory the buzzing does not occur at all. Could this be related to the different SPI pins that the audio board employs?

Edit: To be clear, the buzz only comes through the DAC output. If sound is played through the audio board outputs, that output is clean but the DAC buzzes until the audio stops playing.
 
Last edited:
From the scope images I cannot see the horizontal scaling, but I'd say a ground loop has a more sinusoidal(ish) effect... Could it be due to the execution of some periodic task, such as reading from the SD card?
If so, maybe some aditional decoupling capacitors on the power supply could help? (i see you have a 10uF cap already in place)

Horizontal scaling is in the top left. 3.3v supply is rock solid.

I haven't personally tested with RAW, only WAV.
 
Edit: To be clear, the buzz only comes through the DAC output. If sound is played through the audio board outputs, that output is clean but the DAC buzzes until the audio stops playing.

ah, ok. no clue what might be going on, i'm afraid. i would have speculated the 3v3 rail might take a plunge every 128 samples or so, but Cosford says it's rock solid.

flash memory = W25Q128FV, i assume? can you hear the DAC buzzing just by reading stuff from the SD card?
 
Last edited:
ah, ok. no clue what might be going on, i'm afraid. flash memory = W25Q128FV, i assume?

I mean Teensy flash, such as the instruments in the "SamplePlayer" example that get stored along with the sketch on compile.

Here is a recording of the buzz from the DAC pin when playing two "silent" stereo 16bit 44.1Khz WAV files. First I start playing the first one through the DAC channel, then I overlay the second one playing through the audio board. Then the first sound ends, and last the second sound ends. I've increased the gain on the recording so you can clearly hear it without adjusting your volume.

http://www.ledseq.com/downloads/buzz.wav (1MB)
 
Last edited:
I mean Teensy flash, such as the instruments in the "SamplePlayer" example that get stored along with the sketch on compile.

Here is a recording of the buzz from the DAC pin when playing two "silent" stereo 16bit 44.1Khz WAV files. First I start playing the first one through the DAC channel, then I overlay the second one playing through the audio board. Then the first sound ends, and last the second sound ends. I've increased the gain on the recording so you can clearly hear it without adjusting your volume.

http://www.ledseq.com/downloads/buzz.wav (1MB)

There is a peak at ~344 Hz. The update() freq. is ~2.9 ms so this fits perfectly.
Sometimes i noticed the same noise when i wrote my mp3 player, but this was with the audioboard.
 
Last edited:
Back
Top