Send audio from ADC to i2s output using queue play and dac UDA1334A.
I don't know if it even is able to work, I tried couple of methods and Im disappointed, the sound is distorted or no sound. Im pretty sure that is my fault somewhere. Maybe someone could help me get it work?
The UDA1334A module is working, i tested it with another example Simple Drum and quality of sound is amazing. Why queue doesn't work?
Here is my simple initial code
I don't know if it even is able to work, I tried couple of methods and Im disappointed, the sound is distorted or no sound. Im pretty sure that is my fault somewhere. Maybe someone could help me get it work?
The UDA1334A module is working, i tested it with another example Simple Drum and quality of sound is amazing. Why queue doesn't work?
Here is my simple initial code
Code:
IntervalTimer timer;
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <ADC.h>
#include <ADC_util.h>
ADC *adc = new ADC();
// GUItool: begin automatically generated code
AudioPlayQueue play; //xy=1137,316
AudioOutputI2S i2s2Output; //xy=1344,317
AudioConnection patchCord1(play, 0, i2s2Output, 0);
AudioConnection patchCord2(play, 0, i2s2Output, 1);
// GUItool: end automatically generated code
int16_t output = 0;
void setup() {
AudioMemory(20);
pinMode(16, INPUT_DISABLE);
play.setBehaviour(AudioPlayQueue::NON_STALLING);
play.setMaxBuffers(16);
timer.begin(effect, 80);
timer.priority(128);
//ADC0
adc->adc0->setAveraging(16);
adc->adc0->setResolution(12); //resolution
adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED);
adc->adc0->setReference(ADC_REFERENCE::REF_3V3);
//ADC1
adc->adc0->setAveraging(16);
adc->adc1->setResolution(10); //resolution
adc->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED); // change the conversion speed
adc->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED); // change the sampling speed
adc->adc1->setReference(ADC_REFERENCE::REF_3V3);
}
void dac() { //i2S output
int16_t *dacBuffer = play.getBuffer();
//memcpy(dacBuffer, output, 256);
//queue1.playBuffer();
for (int i = 0; i < 128; i++) {
dacBuffer[i] = output;
play.playBuffer();
}
}
void loop() {
dac();
}
void effect() {
output = adc->adc1->analogRead(A2);
}