I'm using the SAM3U for USB audio and I'm planning to use a codec without a control interface. If I wanted to have "internal" controls for automating output gain, how would I do this? Lets say the output from a computer/master is always going to outputting it's max signal (-1 to 1). How would I lower the volume/gain of the USB stream before it hits the DAC? I know in the software world this is pretty easy; you divide the signal by a number to lower the gain.

Now the question is... how do I do this in the microcontroller world? I'm packing my 24 bit USB stream into a 32 bit variable to transfer to the codec right now. Would I be doing the same thing as I do in software; do I just divide this 32 bit variable by my gain variable to lower it?

Thanks for the link/advice. I would use a codec with a control interface but unfortunately I will be using the 2 TWI for a different function and thus cannot use a codec with a control interface/finding a way to do digital control.

The link was very helpful. Fortunately, I'm using a 32 bit DAC and hopefully I can work around this issue.