Are you getting any volume like that? 5V thru a 4.7K resistor, that only leaves 1mA to go thru a speaker. If you have an 8 ohm speaker, that's only .008 milliWatts. Not sure that'd even be audible.
Are you actually driving a speaker? Or are you going into an amplifier?
If you were driving an 8 ohm speaker directly, you'd need a 120 ohm resistor in series to keep from blowing the output pin. 40mA & 8 ohm speaker is 12.8mW.
What you could do is filter a PWM output, use that to drive a Voltage Controlled Amplifier, run the tone output thru that to a speaker amplifier.
Let me see if I can look one up.
Thank you for your in-depth replies. I greatly appreciate it. If it isn't abundantly clear yet, I'm a noob, so I apologize for not further narrowing the scope of my parameters.
I've adapted Mitch Altman's ATtiny
brain machine to Arduino UNO
. It's essentially a guided meditation device. I'm using two pins to generate distinct tones, one to each ear using stereo headphones. The separated tones might be 441 Hz in the right ear and 399 Hz in the left ear. The end result is a binaural beat of 2Hz as interpreted by the brain through the efforts of our wonderful corpus callosum.
Without any resistors at all, the sound output is enough to probably damage the earphones with continued use. (I used a very old rugged cheap pair of over-the-head earphones for testing. I suspect a pair of $10 silicone-insert types used for many mp3 players would have been blown on the first try.) The 4.7KOhm resistors step down the volume to the point where the highest amplification is merely annoyingly loud rather than ear-damagingly loud using an audio headset. The 10K dual audio potentiometer does a good job of further reducing sound to a user-preferred level to an audio headset for anyone with a reasonable hearing capacity.
I didn't know what a DAC was, so I looked it up and found a lot of interesting Digital-to-Analog Converters that may be more expensive than the original Arduino UNO itself. I'm probably wrong, but I got the impression that I'd be moving the actual tone generation to a different integrated circuit, out of the realm of the arduino tone library.
Specific tones generated by the arduino are imperative to the project. Given the sound levels on the output pins for the tones, I want to create a 'sound envelope' using (perhaps?) voltage-controlled volume that allows me to ramp the sound up gently to it's normal existing output level at the beginning of a session and ramp the sound back down at the end of a session.
The example you've very kindly posted looks like it's designed to amplify more than dampen what's already there. I'm not exactly sure it's the kind of thing I'm looking for, though it might be adapted.
I have $15 dollars in the form of a gift certificate from Radioshack down the street. If it helps, I already have a popular quad opamp I bought from Radioshack. Taking from what you suggested, I wonder if I could use two pwm pins as voltage controllers that could limit
the volume of the tones generated on two non-pwm pins before it goes out through the user-controlled potentiometer.
I found this example
and wondered if it might be something I could adapt to use with an opamp and some extra components. Do you think it would work, or is this for something else entirely? If I were to use a circuit like this, I imagine the pwm pin would have to be attached either to 8 or 4 in the below diagram. Again, I'd be grateful for feedback and suggestions.