How to generate tones of different amplitude with Arduino
Arduino doesn't really say which microcontroller specifically, but I think all the Arduinos I'm aware of have a programmable PWM unit, so that you need to spend no CPU on generating the signal at all. 

For details on different ways to use a PWM unit, please refer to this answer, but the gist is:

You can program the period of your PWM, that is, the frequency of the output signal.

To adjust the voltage you're feeding into the speaker, you can take different routes:


use a second PWM unit + low pass filter with low cutoff to generate an adjustable DC voltage with which you operate the transistor you use to amplify the signal before it goes into the speaker
instead of using an audio-frequency PWM, use a PWM that's much faster, and turn that on and off at the desired tone frequency. Add filtering so that the fast PWM is reduced to an offset, but the audio frequencies don't get cut off.


Another, and probably the easiest way, is not concerning your µC with generating an analog signal at all, but using an audio DAC for that. These things take serial data, typically through SPI/I2S, and often even have integrated amplifiers. 

For example, the ST Discovery boards use the CS43L22 IC for that job. You just send in digital audio data – and it generates the sound. In fact, it even has a beep generation unit if you're too lazy to write the beep waveform via the I2S interface!

There's a plethora of other options, like voltage-to-frequency converter ICs, driving a tank/oscillator circuit periodically, etc., but I think these might be the most arduino-friendly approaches.