Basically the same as Robert has written…
fmosc takes two arguments and two optional arguments:
(fmosc pitch modulation [table phase])
The square brackets indicate that the enclosed arguments are optional, so you can use any of:
(fmosc pitch modulation)
(fmosc pitch modulation table)
(fmosc pitch modulation table phase)
Note that the first argument is “pitch” and not “frequency”, therefore your pitch value “pitch” (E4) should not be converted to Hz.
You wrote:
(fmosc (step-to-hz pitch) vibamp lfo)
so if we take out the “step-to-hz” conversion, that gives:
(fmosc pitch vibamp lfo)
but what is that third argument? You have written “lfo” as the third argument as if “lfo” was a variable and an argument of fmosc.
Then you multiply the result by (saw-table)
(mult (fmosc ...) (*saw-table*)
You have written "saw-table* in brackets, so Nyquist will try to interpret that as a function, but (saw-table) is not defined anywhere as a function. saw-table (no brackets) is defined in Nyquist as a global variable. The value of saw-table is one of the pre-defined look-up tables that is created by Nyquist http://www.cs.cmu.edu/~rbd/doc/nyquist/part2.html#index16
As Robert wrote, saw-table should be an argument of the function lfo.
The syntax for the function lfo is:
(lfo freq [duration table phase])
(I’m not sure why the manual does not show the square brackets - I think that is a misprint - duration, table and phase are optional arguments of lfo.
So Robert’s code is not quite right because he has missed out the optional “duration” argument before the optional “table” argument.
Going back to the original SAL code:
define function vibtone(pitch, vibamp)
return fmosc(pitch,
step-to-hz(pitch) * vibamp * 0.01 * lfo(6),
*saw-table*)
play vibtone(e5, 5)
we see that the function fmosc is given three arguments; “pitch”, a complex expression, and “saw-table”
So a partial translation into LISP would be:
(fmosc pitch
(complex-expression)
*saw-table*)
where “complex-expression” is defined as:
; SAL
step-to-hz(pitch) * vibamp * 0.01 * lfo(6)
; LISP
(mult (step-to-hz pitch) vibamp 0.01 (lfo 6))
Putting this all together:
(defun vibtone (pitch vibamp)
(fmosc pitch
(mult (step-to-hz pitch) vibamp 0.01 (lfo 6))
*saw-table*))
(vibtone E4 5)