Intermittent distorted Audio play back

Status
Not open for further replies.

philip.porhammer

Well-known member
I am using the Teency 3.6 and the full size Audio Shield. I have loaded .WAV files on the Shields SD card slot. About 10% of the time the audio out is distorted.

I have one ground and +5V lugs with 1.5uFd and a .1uFd decoupling Caps as well as more across the LEDs. I only have 13 LEDs being driven.

I am using a 5V 2 amp phone charger. reducing volume of the Audio out did not seem to help. also, disconnecting the leds did not holp. I am thinking of using 12V to to power the audio and putting in a 5V regulator for the Teency.
Ideas? Binary Clock with Chime.jpg
 
hi philip

if you unplug your amplifier do you still get distortion through the headphones?

other than that difficult to tell without any code (have you given it enough AudioMemory?)

cheers Paul
 
I made a test program. with the volume low it is still distorted about 10% of the time. its a class D amp so current draw should be low, the next step would be to wire the Shield to a head phones jack and retest.
also I thought that the NeoPixel would continue to update with this LED driver


#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playWav1;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14





#include <WS2812Serial.h>

const int numled = 20;
const int pin = 26;



byte drawingMemory[numled*4]; // 4 bytes per LED for RGBW
DMAMEM byte displayMemory[numled*16]; // 16 bytes per LED for RGBW

WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRBW);

#define RED 0x00FF0000
#define GREEN 0x0000FF00
#define BLUE 0x000000FF
#define YELLOW 0x00FFD000
#define PINK 0x44F00080
#define ORANGE 0x00FF4200
#define WHITE 0xAA000000

void setup() {

AudioMemory(512);// was8
sgtl5000_1.enable();
sgtl5000_1.volume(1.0);

SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}

leds.begin();
leds.setBrightness(200); // 0=off, 255=brightest
}


void playFile(const char *BOOT)
{
Serial.print("Playing file: ");
Serial.println(BOOT);

// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(BOOT);

// A brief delay for the library read WAV info
delay(5);

// Simply wait for the file to finish playing.
while (playWav1.isPlaying()) {
// uncomment these lines if you audio shield
// has the optional volume pot soldered
//float vol = analogRead(15);
//vol = vol / 1024;
// sgtl5000_1.volume(vol);
}
}



void loop() {
// change all the LEDs in 1.5 seconds
int microsec = 500000 / leds.numPixels();

colorWipe(RED, microsec);
colorWipe(GREEN, microsec);
colorWipe(BLUE, microsec);
//colorWipe(YELLOW, microsec);
//colorWipe(PINK, microsec);
// colorWipe(ORANGE, microsec);
// colorWipe(WHITE, microsec);

playFile("BOOT.WAV");
}

void colorWipe(int color, int wait_us) {
for (int i=0; i < leds.numPixels(); i++) {
leds.setPixel(i, color);
leds.show();
delayMicroseconds(wait_us);
}
}
 
I ran it here, but using SDTEST2.WAV since I don't have your BOOT.WAV file.

Indeed it sounds horribly distorted. This line is the problem:

sgtl5000_1.volume(1.0);

For files with full amplitude data, around 0.8 is the max usable volume before the output distorts.

I tried with nothing connected and with 8 RGBW LEDs on pin 26. Both ways sound fine with the volume changed to 0.8.

test.jpg
 
Status
Not open for further replies.
Back
Top