I'm coding a plugin in Nyquist. The idea is very simple, but actually I'm newbie in the LISP language and Nyquist at all...
The idea is to add some harmonics to the audio, on each time sample. Based on the current pitch of the sample. Have anyone ever coded it yet and released? I'm stuck...
There are two questions I'd like to ask:
1) I'm assuming I could use the returned snd-fetch value as the pitch... Is it a mistake? If so, can I retrieve the pitch of the sound samples, somehow?
2) Why Nyquist returns 44100? It must be the sample rate, and not a SOUND that is returning from the code....
Finally, here's the code (still not documented yet, but it's very small):
Code: Select all
;nyquist plug-in
;version 1
;type process
;name "APedrodx"
;action "TODO..."
;info "TODO..."
(defun mkwave ()
(setf *table* (sim (scale 0.5 (build-harmonic 1.0 2048))
(scale 0.25 (build-harmonic 2.0 2048))
(scale 0.125 (build-harmonic 3.0 2048))
(scale 0.062 (build-harmonic 4.0 2048))))
(setf *table* (list *table* (hz-to-step 1) T))
)
(defun note (time pitch dur)
(at time (osc pitch dur *table*))
)
(cond ((not (boundp '*mkwave*))
(mkwave)
(setf *mkwave* t))
)
(setf my-srate (snd-srate s))
(setf my-ret
(do ((n 1 (+ n 1)) (v (snd-fetch s) (setf v (snd-fetch s))) (my-s (snd-copy s) (sim (cue my-s) (note (/ n my-srate) v 0.1))))
((not v) my-s)
)
)
my-ret