For pure tones it sounds fine, but when I play sampled music or speech there's a lot of high frequency noise present so I'd like to add a simple RC low pass filter to get rid of it. However with this particular circuit arrangement where the transistor sinks current to energize the speaker coil, I'm not exactly sure where the resistor and capacitor should go.

The output was inaudible when I tested it. I used Rf=10K, Cf=680pF for a cut-off frequency of around 24 KHz, but I think the problem here is that the resistor appears as part of the load (going from 51+8 ohms to 51+8+10K ohms), so I don't think it should be in series with R1. But then, where?

What sample rate? What's "high frequency noise"? If it's audible, it's probably not modulation noise, but sampling instead (aliasing or quantization?). Pulses at typical audio sample rates (assuming the resolution of said pulses is good enough) should sound about as good as proper DAC-rendered audio.

For sure, you don't want to add resistance, to an already quiet (maybe?) speaker. Resistors in series are equivalent, so you can just use that first resistor for the job. In which case your capacitor needs to be a lot bigger (~0.1uF?). But actually it needs to be bigger still, because the capacitor is working against the resistance of the speaker (~8 ohms?), not the series resistor -- the series resistor is just there to limit current so the speaker is a manageable volume and doesn't burn out the transistor.

On the upside, the diode is probably unnecessary: the capacitor will shunt away whatever inductance the speaker has.

Tim

--------------------

Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.

15.6kHz suggests a maximum output frequency of just shy of 8kHz, which means your filter needs to be at least 7.something kHz, if it's an ideal brick wall! An RC filter is embarrassingly soft, so that to get any useful attenuation at 8kHz, you need a cutoff below 1kHz -- which is going to poop on a lot of your intended audio.

So expect to need more like, uh, speaker resistance might be 6 ohms, so 3.3uF is the minimum to do anything useful here.

If it's too unpleasant, you'll probably want to consider kicking up the sample rate, if you can. Even if you don't have the samples to do it (e.g., if it's stored on a microcontroller, you'll be limited on data storage), there are ways to resample the data so it's smoother (typical example being 192k DACs working on 44kHz audio -- it's upsampled and digitally filtered, saving on analog filter requirements).

Tim

--------------------

Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.