I think that’s just a little “useful tip” from Edgar (the author) rather than a general recommendation.
In practice (in plug-ins) you would often be using variables rather than numbers. Taking your example:
(scale (/ 3 1.0 4) s)
If we new in advance that we wanted to use 3/4 (which we would need to know if we were to use numbers) then we would probably just write:
(scale 0.75 s)
However, if we wanted to use (for example) a quarter of some value (var):
here’s the basic code:
(scale (/ var 4) s)
but we know that if var is an integer then we have a problem.
Try this code:
(setq var 3)
(scale (/ var 4) s)
because var is an integer less than 4, var/4 =0
so the result is silence.
There are several solutions to this problem.
We could use Edgar’s tip and write:
(setq var 3)
(scale (/ var 1.0 4) s)
or we could ensure that var is a flonum (a floating point number)
(setq var 3.0)
(scale (/ var 4) s)
If we don’t know if var is an integer or a flonum, then we can either force var to be a flonum
(setq var (float var))
or we can force a floating point calculation with either
(scale (/ var 1.0 4) s)
or
(scale (/ var 4.0) s)
(personal opinion)
When setting a variable to a flonum value, I would always add .0 if the value was a whole number.
When setting a variable to an integer value I would always write the value as an integer (no decimal point).
This way it is easy to see whether the value is a flonum or an integer.
There’s a couple of ways that flonums can be converted to integers - you can either use the function ‘round’ or the function ‘truncate’
Truncate simply knocks off the decimal fraction to leave the integer, so (truncate 3.5) will return ‘3’ (which is an integer value).
http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-289.htm
I’ve not seen the ‘round’ function documented anywhere, but what it does is to round the value to the nearest integer, so (round 3.5) returns 4 (.5 is rounded up to the next integer value). The ‘round’ function is only available in recent versions of Audacity.
Example code for ‘truncate’ and ‘round’ functions (use the Debug button to see the output if using the Nyquist Prompt effect)
(setq var 0)
(dotimes (i 20)
(setq var (+ var 0.1))
(format T "var = ~a~%" var)
(format T "(truncate var) = ~a~%" (truncate var))
(format T "(round var) = ~a~%~%" (round var)))
(here’s a trick question - what’s going on when var = 1.0 ?)
For converting from integer to flonum the usual method would be to use (float var), but there are lots of alternative ways, for example:
(setq *float-format* "%f")
(setq var 3)
(format T "var = ~a~%" var)
(format T "(float var) = ~a~%" (float var))
(format T "(* 1.0 var) = ~a~%" (* 1.0 var))
(format T "(+ 0.0 var) = ~a~%" (+ 0.0 var))
(format T "(/ var 1.0) = ~a~%" (/ var 1.0))
I’m sure that you could think of some other ways.
BTW, (format T “string”) sends the string to the standard-output which by default for Audacity is the debug screen.
http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-121.htm