Audio amplifier controlling volume with Arduino?
You can probably use a second PWM to generate a voltage and then send that into a VCA, or get an external digital potentiometer (DPOT) and use that to change the gain of an op-amp if you are willing to add additional ICs. However, if you don't need that many volume levels and you have a bunch of hardware PWMs already on your Arduino, you can just wire them together through some series resistors to create a summer circuit. Assuming your computer speaker has an amplifier built in with high input resistance, you should be able to add several (e.g. 4) PWM outputs together through 1K resistors.

As long as the PWMs were synchronized which they should be, you should get 1/4, 2/4, 3/4, and full amplitude using 4 channels (for example). Just make them all generate the same thing and turn some of the PWMs off (by setting it to be a digital 0) if you want to reduce the volume.

[EDIT] Actually, thinking about the problem some more, you can do it with even less hardware if you use the digital outputs as attenuation. Consider the following circuit: 







simulate this circuit &ndash; Schematic created using CircuitLab

Each digital I/O basically gives you one bit of volume control, and you can get as many bits as you have extra I/Os. Your highest volume would be with all the digital I/Os set to "high-Z" or input, since your amplifier would just see the PWM. Setting any of the digital I/Os to output with a value of '0' would attenuate the signal, (e.g. if digital 0 was outputting a '0', your audio signal would be 50% attenuated due to voltage division). in the above case, you would have 8 volume levels, but you can easily extend the circuit if you need more bits. You can also make it a logarithmic taper by carefully picking resistor values.