I’m trying to generate a track with a wave defined by this Fourier series:
with this code:
(defvar frequency 440)
(defvar amplitude 1)
(defvar return (s-rest 0))
(
dotimes (i 5)
(* frequency 2)
(/ amplitude 2)
(sum return (snd-scale amplitude (hzosc frequency)))
)
No errors are thrown, but no tracks are generated either.
Trebor
2
Surely that needs an exponent.
Oh, I forgot to set the doubling and halving to their respective variables, so the code is updated to this:
;nyquist plug-in
;version 1
;type generate
;name "Timbre whose Overtones are only Octaves"
;action "Creating a timbre whose overtones are only octaves"
;info "Timbre whose Overtones are only Octaves\nwritten by HDGL"
;control fundamental "Fundamental" real "Hz" 440 8 12544
;control n "# of Octaves" int "" 5 1 100
;control duration "Duration" real "seconds" 1 1 100
(defun tone (frequency duration amplitude) (mult amplitude (stretch duration (hzosc frequency))))
(defun calc (fundamental duration n)
(setf frequency fundamental)
(setf amplitude 1.0)
(setf accumulator (stretch duration (hzosc 0)))
(
dotimes (i n accumulator)
(
progn
(setf frequency (* frequency 2))
(setf amplitude (/ amplitude 2))
(sum accumulator (tone frequency duration amplitude))
)
)
)
(setf return (calc fundamental duration n))
return