So, I’m a programmer, but just beginning to grapple with the concepts in nyquist (using SAL), and ran into this:
I’m generating waves of fixed lengths, and have a calculated waveform in a variable of say 3 seconds in length. I then wish to do something with that wave, for instance frequency modulate it
But:
hzosc(2000) * myWave
will give a 1 second wave (assuming no selection, and I think because warp of the hzosc() call is 1 second.
Whereas:
hzosc(2000) ~~ 20 * myWave
will give the required 3 second waveform, but is wasteful in resources, hardcoded, and breaks when myWave exceeds 20seconds…
So… how to set the warp of the hzsoc() call to be the length of warp in myWave? Or am I not understanding the concepts correctly?
I may go to LISP, I can translate, but I write SAL at the moment, as I come from a C heritage.
I understand this differences you mention, but they don’t answer my question: I’ve programmatically created a wave of arbitary length - I don’t know the length (in absolute time) that I want to use.
;type generate
(abs-env (osc 72 x))
I’m trying to derive the “x” to use in this, given a waveform passed to a procedure in a variable.
;type generate
(setf tone (osc 70 3)) ;a 3 second tone
;Find the length of "tone"
(setf duration (/ (snd-length tone ny:all) *sound-srate*))
(mult tone (stretch duration (hzosc 2)))
or more generally:
;type generate
(setf tone (osc 70 3)) ;a 3 second tone
(defun modulate (sig hz)
(let ((dur (/ (snd-length sig ny:all)(snd-srate sig))))
(mult sig (osc (hz-to-step hz) dur))))
(modulate tone 4)
I’d seen snd-length() but thought there was another way - in that I thought there was a WARP structure associated with the wave that I could access - rather than calculating the whole wave in memory.