TMRh20 / AutoAnalogAudio

Create a wide range of sampling and audio related applications with simple API for onboard DAC (or PWM), ADC, DMA & Timers on Arduino devices (AVR & SAM)
http://tmrh20.github.io/AutoAnalogAudio
114 stars 31 forks source link

Low / Distorted Input and Output #26

Closed beankonducta closed 3 years ago

beankonducta commented 3 years ago

Hi!

Using an Arduino Nano clone with the library. Reading in audio from a keyboard (Casio Sk-1) at line level. Inputting to A0 and outputting to 9 as per docs.

Audio is successfully being read in and output through DAC to a 4ohm speaker and a rca output, but the audio is extremely distorted. Here's the wave being read in:

Untitled

I tried using a PAM8403 breakout for amplification in but it didn't output anything useful. Still getting relatively low levels in.

When I plug into a power amp via rca it's EXTREMELY loud and distorted.

Thanks for help & for the wonderful library!

and simple code to recreate:



AutoAnalog aaAudio;
void DACC_Handler(void) {
  aaAudio.dacHandler();
}

void setup() {

  pinMode(A3, OUTPUT);
  digitalWrite(A3, HIGH);

  Serial.begin(115200);

  aaAudio.begin(1, 1);
  aaAudio.autoAdjust = 1;
  aaAudio.dacBitsPerSample = 8;

  aaAudio.getADC(32);
}

void loop() {

  aaAudio.feedDAC(0, 32);
  aaAudio.getADC(32);

  for (int i = 0; i < 32; i++) {
    aaAudio.dacBuffer[i] = aaAudio.adcBuffer[i] << 2;
    Serial.println(aaAudio.dacBuffer[i]);
  }
}
TMRh20 commented 3 years ago

It might just be a matter of lowering the level of the input signal, but you could also try adjusting the MAX_BUFFER_SIZE in AutoAnalog_config.h then using the new value (say 96 or so) in your calls to feedDac and getAdc.

On Sep 8, 2021, at 10:44 AM, Patrick Andrews @.***> wrote:

 Hi!

Using an Arduino Nano clone with the library. Reading in audio from a keyboard (Casio Sk-1) at line level. Inputting to A0 and outputting to 9 as per docs.

Audio is successfully being read in and output through DAC to a 4ohm speaker and a rca output, but the audio is extremely distorted. Here's the wave being read in:

and simple code to recreate:

`#include

AutoAnalog aaAudio; void DACC_Handler(void) { aaAudio.dacHandler(); }

void setup() {

pinMode(A3, OUTPUT); digitalWrite(A3, HIGH);

Serial.begin(115200);

aaAudio.begin(1, 1); aaAudio.autoAdjust = 1; aaAudio.dacBitsPerSample = 8;

aaAudio.getADC(32); }

void loop() {

aaAudio.feedDAC(0, 32); aaAudio.getADC(32);

for (int i = 0; i < 32; i++) { aaAudio.dacBuffer[i] = aaAudio.adcBuffer[i] << 2; Serial.println(aaAudio.dacBuffer[i]); } }`

I tried using a PAM8403 breakout for amplification in but it didn't output anything useful. Still getting relatively low levels in.

When I plug into a power amp via rca it's EXTREMELY loud and distorted.

Thanks for help & for the wonderful library!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.