Russell McMahon wrote: > Given PWM of a high enough frequency (20 kHz plus frame rate) you should > be able to simply gate the audio signal with the PWM OR ground it if the > supplying impedance is high enough. You will need some sot of electronic > switching - quite possibly a single FET would do. If speaker is AC > coupled it will be slightly more complex. Assume for simplicity that > speaker is DC coupled and driven by a signal never below ground. A FET > in the speaker ground lead could be gated by the PWM signal. A flyback > diode would probably be needed across the speaker in series with a diode > to *attempt* not to modify audio response too much. It would be easier > if you could control the signal level at lower level and then amplify it > for the speaker but that wrecks the simplicity. > > See what sense you can make of that and ask more questions. > > RM Actually, the frequencies coming out of the speaker rarely exceed 2Khz, so I could even use a lower PWM freq and add a lowpass filter. But I'm not sure how fast I can push the PWM, since I don't want it taking too much software time. Anyways I *do* want an amplifier in there anyway. "Too complicated" would be DACs and stuff, but I don't mind some transistors in there. Currently I'm using an optocoupler as a substitute for the speaker for input (I don't trust how the computer generates output, common ground, common positive, whatever, so an opto makes sense here), so I can do whatever I want with its output photodiode/transistor. I've amplified it with a simple BC547 transistor and a pot to (manually) control volume and it works quite well (although I need a larger transistor, since at higher volumes the BC547 gets quite warm). Now all I really need to do is replace the pot with another transistor, something like this: +12V --------------------+------------------+------- OPTO | | +------------+ | | _ /| | _|_ |/C +--| | | INPUT /_\ --> | --------|_| | | | |\E |/C \| +--\/\/\/----+ --/\/\/\-+--| | |\E |/C | FILTERED PWM INPUT >-------| | |\E | GND ------------------------------+----+------------ (this would of course be an inverted configuration, where a higher PWM input would mean lower volume, but of course that just means a change in the software) But, of course, I either need a filtered mostly clean voltage, or a very high rate PWM (which I'm not sure I can afford). How clean can you get with some R-C filters? -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/hector.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist