Probably the easiest way of controlling volume level by 8051 is to use a digital potentiometer.
Good example on how to do this you can find at MAXIM site:
**broken link removed**
Controlled using a 3-wire interface, Maxim also offers the MAX5400/1/2 devices. These offer 256 taps for those applications needing slightly higher resolution and have a 3-wire protocol available for control.
Thanks stephen_h & IanPfor replying. But stephen_h if i go your way where to give the audio input as the resistors network would be connected to 89c51.
The option with resistors can be realized as per attached drawing.
Lins P0 to P3 control volume in 16 steps, line P4 = Audio OFF.
Selecting values of resistors you have to remember that audio control should be ( as our hearing is), logarythmic ..
U can use CD4067 analog multilplexer for volume controller with 16 steps.
U can drive select lines of that with 89C51 port.
Build a voltage divider as per required steps in db and connect audio signal to the voltage divider and connect ech node of the divider to input channel of 4067. and op of 4067 will be ur volume controlled signal.
Plz find attached drawing scheme......forgive for my bad drawing.
There are also available volume controller ICs from Princeton or u can use digital potentiometers available from Maxim.