emulate class d amp

Help for Audacity 2.x.x on Windows.

ImageThis forum is for Audacity 2.x.x on Windows.

  • Please state which version of Windows you are using, the exact three-section version of Audacity from Help > About Audacity and whether you obtained the .exe installer or the zip.

  • Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
    The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.

emulate class d amp

Permanent link to this post Posted by dnorric` » Sat Aug 12, 2017 6:45 am

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
dnorric`
 
Posts: 5
Joined: Mon Jun 12, 2017 5:50 am
Operating System: Windows 10

Re: emulate class d amp

Permanent link to this post Posted by DVDdoug » Sun Aug 13, 2017 4:13 am

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.
DVDdoug
Forum Crew
 
Posts: 2711
Joined: Fri Sep 10, 2010 11:30 pm
Operating System: Windows 10

Re: emulate class d amp

Permanent link to this post Posted by steve » Sun Aug 13, 2017 10:39 am

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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 44161
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: emulate class d amp

Permanent link to this post Posted by DVDdoug » Sun Aug 13, 2017 3:38 pm

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".
DVDdoug
Forum Crew
 
Posts: 2711
Joined: Fri Sep 10, 2010 11:30 pm
Operating System: Windows 10

Re: emulate class d amp

Permanent link to this post Posted by Trebor » Sun Aug 13, 2017 7:55 pm

Quantize-noise is close, (and doesn't require the overhead of re-sampling to 1MHz) ...

original -Steve's PWM code - Quantized.flac
(442.48 KiB) Downloaded 2 times
Trebor
 
Posts: 3703
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows Vista


Return to Windows



Who is online

Users browsing this forum: No registered users and 19 guests