This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

mcasp: how to attenuate audio without signal distortion

Other Parts Discussed in Thread: TMS320C6748

Hi,

I work with tms320C6748 lcdk and do audio processing.

I tried to attenuate audio signal on 50% of original volume.

The simple way like:

sample=audioIn;

sample*=0.5

audioOut=sample;

causes the audio distortion.

I thought, that the problem could be in byte sequence, so I modified it in this way:

sample=_swap4(audioIn);

sample*=0.5

audioOut=_swap4(sample);

but it doesn't help.

Do you have any idea how to attenuate audio signal correctly?

Thanks for your answers.

Petr Duga

  • Hi Petr,

    Thanks for your post.

    I believe, to control audio attenuation, it should be hardware controlled by choosing the appropriate resistor/series capacitor values at the input of the circuit  to cause effect in the output impedance may be chosen little high which would result in low-pass filter effect and this would attenuate the audio at the input side, so that, appropriate attenuation would result in output without signal distortion.

     please refer the note mentioned in the below wiki:

    http://processors.wiki.ti.com/index.php/SGI_EVM_Hardware_Manual

    Also, Please refer the below E2E thread which would give you an idea on digital DAC gain & volume control range to reduce analog gain and proportionately, the SNR too.

    http://e2e.ti.com/support/data_converters/audio_converters/f/64/t/171398.aspx#626270

    Probably, if you would have post this question to audio converter forum, i hope, it would be better answerable but still, i think, there are challenges to attenuate output audio without loss in signal quality.

    Hope it helps!

    Thanks & regards,

    Sivaraj K

    ------------------------------------------------------------------------------------------------------- 
    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------
  • Petr,

    Perhaps your *= 0.5 operation is converting to/from floating point.

    Instead, can you try sample /= 2; to see if the operation occurs differently?

    Regards,
    RandyP

  • Thanks for answers,

    the problem was in typecasting. When I overtyped input sample into "short" and output sample into "short" too, the attenuation was started to work. I thought I could use  int x,y instead of "float" and could write y direct into txbuffer without overtyping into "short". This works only for direct write back from rxbuffer to txbuffer without processing. There is a working code.

                int i;
                float x,y;

                for(i=0; i<AUDIO_BUF_SIZE/4; i++){
                    if(i % 2 == 0){
                        x = (short)*((int *)rxBufPtr[lastFullRxBuf] + i);
                        y = 0.5 * x;
                        *((int *)txBufPtr[lastSentTxBuf] + i) = (short) y;
                    }else{
                        x = *((int *)rxBufPtr[lastFullRxBuf] + i);
                        y = x;
                        *((int *)txBufPtr[lastSentTxBuf] + i) = (int) y;
                    }
                }