Page 2 of 2
Re: Trying to convert regular audio in PWM audio
Posted: Wed Oct 09, 2019 5:23 pm
by steve
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
Re: Trying to convert regular audio in PWM audio
Posted: Sat Oct 26, 2019 5:21 am
by 8bit_coder
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.
Re: Trying to convert regular audio in PWM audio
Posted: Sat Oct 26, 2019 10:45 am
by steve
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: