Need programmatic volume control of a PWM driven speaker

Sorry if this has been asked before, or there is an obvious answer as I did not find it. I would like programmatic control of the volume of a speaker that is driven from a PWM channel (probably through a simple audio amp chip circuit). It seems like I should be able to control volume through an analog channel as a gain control but I have no clue how I would do it. Please keep in mind that this is a small portable toy application for my grand daughter so I'm trying to keep the cost down. Thanks.

It seems like I should be able to control volume through an analog channel as a gain control but I have no clue how I would do it.

It seems like unless you figure out how to control the volume for sure, there is no point in discussing how to program your arduino to control it.

..."but I have no clue how I would do it" refers to how to create the circuit.

My question wasn't worded very well. I don't want to know how to program it, just how I would connect it up so could write a program to control it.

My answer definitely wasn't worded very well. Without knowing how to control it, it makes no sense to connect them and to write any program to control it.

If I am interpreting your question correctly...

I`ve given a similar answer in the audio section of the forum.
PWM - low pass filter - voltage controlled amplifier.

or
Amp with digital volume control
http://www.ebay.com/itm/170850491058

Perfect! Sorry for the duplicate question.