Quantcast
Channel: Data converters
Viewing all articles
Browse latest Browse all 88727

Forum Post: RE: Dynamic DAC_ATTEN value change of audio codec

$
0
0

Hi,

My main idea is to make this:

#include "L138_LCDK_aic3106_init.h" // codec AIC3106.
#include <math.h>
#include <stdio.h>
#define BUFLENGTH 10

//int16_t mic;
int inbuf_ptr;
//float mic, cancel = 0;
float micbuffer[BUFLENGTH];
float atten = 0.5;

int main (void)
{
    L138_initialise_poll(FS_19200_HZ,ADC_GAIN_6DB,DAC_ATTEN_0DB,LCDK_MIC_INPUT);
    float mic, cancel = 0;
    while(1)
    {
        for(inbuf_ptr=0; inbuf_ptr<BUFLENGTH; inbuf_ptr++)
        {
        mic = (float)(input_sample());
        micbuffer[inbuf_ptr] = mic;
        cancel=(-1)*atten*micbuffer[inbuf_ptr];
        output_sample((uint32_t)(cancel));
        }

    }
}

But when the value of atten is different from 1 I get a lot of noise through the speakers. Why this is happening? How could I do it?

Thanks,

Miguel.


Viewing all articles
Browse latest Browse all 88727

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>