> Hi all,
> I've been toying with Audacity sources for a while. For effects, C is
> fast (good) but needs to be compiled and linked in Audacity (bad, not
> distributable). Ok, let's do it in Nyquist - I'm a total newbie in
> Lisp but beginning to grasp a few concepts. What I want will be slow,
> in fact I'm pretty sure it will take a looooong time to execute, but
> this is not a real issue to me.
> I'm looking for a way to alter individual samples based on a given
> algorithm. In fact, I'd like to know if there's a canonical way to do
> it, something like a standard loop where I could insert whatever math
> function(s) I need. I suppose snd-fetch could be involved, as well as
> snd-from-array, all within the loop. Is it the right direction? Am I
> missing something?
> Thanks in advance for your feedback and suggestions.
Because I know that the DSP example in the Nyquist manual is not-so-easy
to understand, I have written a basic sceleton of an Audacity Nyquist
DSP effect plugin. In the middle of the code there is a line:
(* 0.5 current-sample)
which ist the [rather simple] DSP function executed. So the plugin will
return the Audacity track with half of the original volume. Just simply
replace this line from above with your own functions.
The plugin code is mainly based on the DSP example in the Nyquist manual.
Maybe also important to know: Nyquist handles samples as floats, where
in Nyquist the range is not limited to -1.0 to 1.0, but only by the float
format of your machine and/or OS. But nevertheless be careful, when the
Nyquist sound gets returned to Audacity, all samples will get clipped to
a range of -1.0 to 1.0 again [by Audacity, not by Nyquist].
If your mailbox scrambles the indentation of the code [like mine does],
look at the file in the attachment.
Links to all other Nyquist docs can be found in the Audacity Users Wiki:
;name "DSP Effect..."
;action "Performing DSP Effect..."
;control dummy "" int "" 0 0 0
;; the dummy slider above is only to open a effect window
;; where you can press the "Debug" button in case of trouble.
;; Just write TWO semicolons at the beginning of the "control"
;; line if you want to disable the effect window temporarily.
;; define a dsp class
(setf dsp-class (send class :new '(copy-of-sound)))
;; initial function of dsp class
(send dsp-class :answer :isnew '(sound)
'((setf copy-of-sound (snd-copy sound))))
;; method to be executed with every call to dsp-class
(send dsp-class :answer :next '()
'((let ((current-sample (snd-fetch copy-of-sound)))
;; "cond" checks for end-of-samples condition
;; replace the following line with your own function(s)
(* 0.5 current-sample)
;; define a dsp function for mono signals
(defun dsp (sound)
(setf obj (send dsp-class :new sound))
(snd-fromobject (snd-t0 sound) (snd-srate sound) obj)))
;; add automatic handling of mono/stereo tracks. Processes both stereo
;; channels one after the other. To process both channels simultaneously
;; or whole blocks of samples the object code above needs to be rewritten.
(if (arrayp s)
(dsp (aref s 0))
(dsp (aref s 1)))
The author of this email does not necessarily endorse the
following advertisements, which are the sole responsibility
of the advertiser:
Bis 50 MB Dateianhänge? Kein Problem!