Page 1 of 1
emulate class d amp
Posted: Sat Aug 12, 2017 6:45 am
by dnorric`
Is it possible to emulate class d amp. That is have audio file and pulse modulate as is done in class d amp
https://en.wikipedia.org/wiki/Class-D_amplifier
Cheer
Dmian
Re: emulate class d amp
Posted: Sun Aug 13, 2017 4:13 am
by DVDdoug
That would be
PWM (Pulse Width Modulation).
You can do almost anything
Nyquist, so that might be worth a try. You'll probably want to use the highest sample rate that Audacity supports (I don't know what that is, but it can support 192kHz) and assuming you're going to play the sound through your soundcard (which is "normal" PCM) or save it as a regular sound file, you'll probably want to make a low-pass filter in Nyquist too.
Re: emulate class d amp
Posted: Sun Aug 13, 2017 10:39 am
by steve
DVDdoug wrote:You'll probably want to use the highest sample rate that Audacity supports (I don't know what that is, but it can support 192kHz)
The highest sample rate supported by Audacity is 1000000 Hz (1 MHz).
As no sound cards support such a high sample rate you need to use "Tracks menu > Resample"
This code run in the Nyquist Prompt effect (
http://manual.audacityteam.org/man/nyquist_prompt.html) is a simple way to create PWM:
Code: Select all
;version 4
(if (and (soundp *track*)(= *sound-srate* 1000000))
(osc-pulse 25000 *track*)
"Error.\nInput must be a mono track\nwith 1,000,000 Hz sample rate.")
To play the encoded audio requires a low pass filter. This is very easy: just leave the "Project Rate" (lower left corner of the main Audacity window) at 44100, and the track will be resampled back down to 44100 Hz for playback, and the resampling automatically applies a low-pass filter to remove everything above 22050 Hz (half the sample rate).
Note that the sound quality will be very poor, but it demonstrates the principle.
Re: emulate class d amp
Posted: Sun Aug 13, 2017 3:38 pm
by DVDdoug
And, thinking a bit more about this... if you low-pass filter digitally, you've no longer got PWM, you're back to PCM. But, that should also "demonstrate the principal".
Re: emulate class d amp
Posted: Sun Aug 13, 2017 7:55 pm
by Trebor
Quantize-noise is close, (and doesn't require the overhead of re-sampling to 1MHz) ...