Trying to convert regular audio in PWM audio

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


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.
steve
Site Admin
Posts: 80679
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Trying to convert regular audio in PWM audio

Post by steve » Wed Oct 09, 2019 5:23 pm

8bit_coder wrote:
Wed Oct 09, 2019 4:53 pm
error: bad argument type - #(#<Sound: #5ace328> #<Sound: #5ace568>)
You're using a stereo track (an array of two sounds).
The SND-AVG function requires a mono sound.

The easy workaround is to split the stereo track to mono (https://manual.audacityteam.org/man/spl ... racks.html)
A better solution is to develop the code to handle stereo tracks. Some hints here: https://wiki.audacityteam.org/wiki/Nyqu ... k_Tutorial
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

8bit_coder
Posts: 32
Joined: Sun Dec 03, 2017 4:31 am
Operating System: Windows 8 or 8.1

Re: Trying to convert regular audio in PWM audio

Post by 8bit_coder » Sat Oct 26, 2019 5:21 am

Ah, that makes more sense. Well, I've decided to make a nyquist plugin out of it and this is my code so far:

Code: Select all

;nyquist plug-in
;version 3
;type process
;preview linear
;name "aPWM"
;action "Applying PWM"
;author "me"
;copyright "No copyright"

;control smp "Sample Bias" int "1-1000" 1 1 1000
;control htz "Carrier Frequency" int "1-20480000" 1 1 20480000

(setf bias (snd-avg *track* smp smp op-average))
(osc-pulse htz bias)
however, whatever I set in smp just ends up being the output, and debug doesn't do any help either. I'm planning on making it automatically calculate a reasonable carrier frequency and sample bias.

steve
Site Admin
Posts: 80679
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Trying to convert regular audio in PWM audio

Post by steve » Sat Oct 26, 2019 10:45 am

It needs to be a "version 4" plug-in.
There were some important changes between versions 3 and 4. The biggest one being that in version 3 and earlier, the selected sound was passed from Audacity to Nyquist as the variable "S". In version 4, the sound is passed from Audacity to Nyquist as the variable *track*.

Change the second line to:

Code: Select all

;version 4
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply